Skip to content

Commit

Permalink
This commit fixes the refresh_pattern template
Browse files Browse the repository at this point in the history
When using a regexp (when case_sensitive is set to false)
the -i should be placed BEFORE the $name and not after
Also fixed that no space was used between the max and
options field, added rspec for options
  • Loading branch information
ralfbosz committed Feb 20, 2018
1 parent c32476f commit 4001565
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion spec/defines/refresh_pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+my_pattern:\s+1440\s+20%\s+10080$}) }
end # context 'when parameters are set'

context 'when parameters are set and options' do
let(:title) { 'my_pattern' }
let(:params) do
{
order: '06',
max: 10_080,
min: 1440,
percent: 20,
options: 'override-expire ignore-no-cache',
comment: 'Refresh Patterns'
}
end

fname = 'squid_refresh_pattern_my_pattern'
it { is_expected.to contain_concat_fragment(fname).with_target('/tmp/squid.conf') }
it { is_expected.to contain_concat_fragment(fname).with_order('45-06') }
it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+my_pattern:\s+1440\s+20%\s+10080\s+override-expire\s+ignore-no-cache$}) }
end

context 'when parameters are set and case insensitive' do
let(:title) { 'case_insensitive' }
let(:params) do
Expand All @@ -47,7 +66,7 @@
fname = 'squid_refresh_pattern_case_insensitive'
it { is_expected.to contain_concat_fragment(fname).with_target('/tmp/squid.conf') }
it { is_expected.to contain_concat_fragment(fname).with_order('45-07') }
it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+case_insensitive:\s+-i\s+0\s+0%\s+0$}) }
it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+-i\s+case_insensitive:\s+0\s+0%\s+0$}) }
end # context 'when parameters are set and case insensitive'
end
end
Expand Down
2 changes: 1 addition & 1 deletion templates/squid.conf.refresh_pattern.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# <%= @comment %>
refresh_pattern <%= @pattern %>: <%= @case_sensitive?'':'-i ' %><%= @min %> <%= @percent %>% <%= @max %><%= @options ? @options:'' %>
refresh_pattern <%= @case_sensitive?'':'-i ' %><%= @pattern %>: <%= @min %> <%= @percent %>% <%= @max %><% if @options != '' %> <%= @options %><% end %>

0 comments on commit 4001565

Please sign in to comment.