Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Feature/gzip support #158

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ GEM
mixlib-config (2.1.0)
mixlib-log (1.6.0)
mixlib-shellout (1.4.0)
multi_json (1.10.1)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
net-ssh (2.9.2)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.2.0)
Expand Down Expand Up @@ -120,28 +121,29 @@ GEM
faraday
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.4)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-its (1.0.1)
rspec-core (>= 2.99.0.beta1)
rspec-expectations (>= 2.99.0.beta1)
rspec-mocks (3.0.4)
rspec-support (~> 3.0.0)
rspec-support (3.0.4)
rspec-support (~> 3.1.0)
rspec-its (1.1.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
safe_yaml (1.0.4)
serverspec (2.0.1)
rspec (~> 3.0.0)
serverspec (2.7.1)
multi_json
rspec (~> 3.0)
rspec-its
specinfra (~> 2.0)
specinfra (~> 2.10)
slop (3.6.0)
specinfra (2.0.2)
specinfra (2.11.3)
net-scp
net-ssh
systemu (2.6.4)
Expand Down
8 changes: 8 additions & 0 deletions test/integration/full-stack/serverspec/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@
end

end

describe file("/etc/nginx/sites-available/intercity_sample_app.conf") do
it { should be_file }

its(:content) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you but a context block around this? so it tells a bit more about what you're testing. So you get something like:

describe file("/etc/nginx/sites-available/intercity_sample_app.conf") do
  it { should be_file }

  context "GZip support enabled" do
    its(:content) do
      should match /location ~ \^\/\(assets\)\/.*gzip_static on;/m
    end
  end
end

should match /location ~ \^\/\(assets\)\/.*gzip_static on;/m
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
location ~ ^/(assets)/ {
root <%= @server_root_public_path %>;
gzip_static on;
expires max;
add_header Cache-Control public;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking here, but the } is not placed correctly yet ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I've got some issues with rendering partials, the first line is always shifted 2 spaces right

Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<% server_root_public_path = "#{node['rails']['applications_root']}/#{@name}/current/public" %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to set this from the recipe instead of in the template? Somehow this feels a little hacky


<%= @custom_configuration["before_server"] %>

server {
listen <%= node['nginx']['port'] || '80' %>;
server_name <%= @domain_names.join(' ') %>;
root <%= node['rails']['applications_root'] %>/<%= @name %>/current/public;
root <%= server_root_public_path %>;

passenger_enabled on;
passenger_app_env <%= @rails_env %>;

<%= render '_app_nginx_location_assets.erb', variables: { server_root_public_path: server_root_public_path } %>

<%= @custom_configuration["server_main"] %>
}

Expand All @@ -23,7 +28,10 @@ server {

server_name <%= @domain_names.join(' ') %>;

root <%= node['rails']['applications_root'] %>/<%= @name %>/current/public;
root <%= server_root_public_path %>;

<%= render '_app_nginx_location_assets.erb', variables: { server_root_public_path: server_root_public_path } %>

<%= @custom_configuration["ssl_main"] %>
}

Expand Down