Permalink
Browse files

sort vhost_cfg_append in vhost_ssl_footer

  • Loading branch information...
1 parent 4af2087 commit e1c4c7470b942a83561b55ff7fa66e545c7dc0ff @3flex 3flex committed Nov 22, 2013
Showing with 11 additions and 26 deletions.
  1. +10 −25 spec/defines/resource_vhost_spec.rb
  2. +1 −1 templates/vhost/vhost_ssl_footer.erb
@@ -429,16 +429,16 @@
'include /file2;',
],
},
- #{
- # :title => 'should contain ordered appended directives',
- # :attr => 'vhost_cfg_append',
- # :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
- # :match => [
- # ' allow test value 3;',
- # ' test1 test value 1;',
- # ' test2 test value 2;',
- # ]
- #},
+ {
+ :title => 'should contain ordered appended directives',
+ :attr => 'vhost_cfg_append',
+ :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
+ :match => [
+ ' allow test value 3;',
+ ' test1 test value 1;',
+ ' test2 test value 2;',
+ ]
+ },
{
:title => 'should contain www to non-www rewrite',
:attr => 'rewrite_www_to_non_www',
@@ -604,21 +604,6 @@
it { should contain_file("/tmp/nginx.d/#{title}-700-ssl").with_content( /passenger_set_cgi_param test2 test value 2;/ ) }
it { should contain_file("/tmp/nginx.d/#{title}-700-ssl").with_content( /passenger_set_cgi_param test3 test value 3;/ ) }
end
-
- context 'when vhost_cfg_append is set and ssl => true' do
- let :params do default_params.merge({
- :vhost_cfg_append => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
- :ssl => true,
- :ssl_key => 'dummy.key',
- :ssl_cert => 'dummy.cert',
- }) end
-
- #TODO: reenable disabled test above and remove this block entirely if template is updated to order
- #these as for the other templates
- it { should contain_file("/tmp/nginx.d/#{title}-999-ssl").with_content( /test1 test value 1;/ ) }
- it { should contain_file("/tmp/nginx.d/#{title}-999-ssl").with_content( /test2 test value 2;/ ) }
- it { should contain_file("/tmp/nginx.d/#{title}-999-ssl").with_content( /allow test value 3;/ ) }
- end
end
end
end
@@ -1,7 +1,7 @@
<% if @include_files %><% @include_files.each do |file| -%>
include <%= file %>;
<% end -%><% end -%>
-<% if @vhost_cfg_append -%><% @vhost_cfg_append.each do |key,value| -%>
+<% if @vhost_cfg_append -%><% @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
<%= key %> <%= value %>;
<% end -%>
<% end -%>

0 comments on commit e1c4c74

Please sign in to comment.