-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix rewrite rules being ignored #2330
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me, but it'd be great if we have a test case to prevent future regressions.
|
@ekohl |
|
I would probably take this example: puppetlabs-apache/spec/defines/vhost_spec.rb Lines 1723 to 1736 in 77255d6
Then copy it and pass some parameters that triggers the behavior you want to test. Note you can also test the whole file: it {
is_expected.to contain_concat__fragment('rspec.example.com-rewrite').with_content <<~CONTENT
Here you can write the full content
And use multiple lines
CONTENT
} |
spec/defines/vhost_spec.rb
Outdated
| @@ -741,7 +741,10 @@ | |||
| it { is_expected.to contain_concat__fragment('rspec.example.com-redirect') } | |||
| it { | |||
| is_expected.to contain_concat__fragment('rspec.example.com-rewrite').with( | |||
| content: %r{^\s+RewriteEngine On$}, | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't test this way (as the action indicates), but you can chain it: .with(content: ...).with(content: ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
@trefzer Hey sorry to bother you, just checking in on when you'll have time to finish with the sped test? |
In 7b22dae the default value for $rewrites was changed from undef to [] in manifests/vhost.pp. This results in templates_vhost/_rewrite.erb always evaluating to false (boolean check on an empty array variable is still true) unless $rewrites is explicitly set to undef. This results in the content of $rewrite_rule being ignored. closes: #2318
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes should make the test suite work.
spec/defines/vhost_spec.rb
Outdated
| .with_content(%r{^\s+RewriteOptions Inherit$}), | ||
| .with_content(%r{^\s+RewriteBase /}), | ||
| .with_content(%r{^\s+RewriteRule ^index\.html$ welcome.html$}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .with_content(%r{^\s+RewriteOptions Inherit$}), | |
| .with_content(%r{^\s+RewriteBase /}), | |
| .with_content(%r{^\s+RewriteRule ^index\.html$ welcome.html$}), | |
| .with_content(%r{^\s+RewriteOptions Inherit$}) | |
| .with_content(%r{^\s+RewriteBase /}) | |
| .with_content(%r{^\s+RewriteRule ^index\.html$ welcome.html$}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ups :) missed them.
templates/vhost/_rewrite.erb
Outdated
| @@ -1,4 +1,4 @@ | |||
| <%- if @rewrites -%> | |||
| <%- if @rewrite_inherit or not @rewrites.empty? -%> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <%- if @rewrite_inherit or not @rewrites.empty? -%> | |
| <%- if @rewrite_inherit or !@rewrites.empty? -%> |
spec/defines/vhost_spec.rb
Outdated
| .with_content(%r{^\s+RewriteEngine On$}) | ||
| .with_content(%r{^\s+RewriteOptions Inherit$}) | ||
| .with_content(%r{^\s+RewriteBase /}) | ||
| .with_content(%r{^\s+RewriteRule ^index\.html$ welcome.html$}) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should make it valid Ruby
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ekohl Just checking you're good with the changes you requested?
If so will merge in and release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm good. All my comments were there to make the test suite pass (we'll ignore mend for now) so 👍 to merging this.
Thanks @trefzer for your efforts! And it was great to collaborate on a PR in person again. That was a long time ago for me
|
Good good good Should be released by end of day |
In 7b22dae the default value for $rewrites was changed from undef to [] in manifests/vhost.pp. This results in templates_vhost/_rewrite.erb always evaluating to false (boolean check on an empty array variable is still true) unless $rewrites is explicitly set to undef. This results in the content of $rewrite_rule being ignored.
closes: #2318