sort add_header values for vhost

This commit is contained in:
Stefan Baryakov 2015-01-23 14:33:49 +01:00
parent fa34755873
commit d909327380
2 changed files with 17 additions and 2 deletions

View file

@ -847,6 +847,21 @@ describe 'nginx::resource::vhost' do
it { is_expected.to contain_concat('/etc/nginx/sites-available/www_rspec-vhost_com.conf') }
end
context 'when add_hedar is set' do
let :params do default_params.merge({
:add_header => { 'header3' => 'test value 3', 'header2' => 'test value 2', 'header1' => 'test value 1' }
}) end
it 'should have correctly ordered entries in the config' do
is_expected.to contain_concat__fragment("#{title}-header").with_content(/
%r|
\s+add_header\s+header1 test value 1;\n
\s+add_header\s+header2 test value 2;\n
\s+add_header\s+header3 test value 3;\n
|/)
end
end
end
end
end

View file

@ -70,8 +70,8 @@ server {
resolver <% Array(@resolver).each do |r| %> <%= r %><% end %>;
<% end -%>
<% if @add_header -%>
<%- @add_header.each do |key,value| -%>
add_header <%= key %> <%= value %>;
<%- @add_header.keys.sort.each do |key| -%>
add_header <%= key %> <%= @add_header[key] %>;
<%- end -%>
<% end -%>
<% if @rewrite_to_https -%>