diff --git a/Gemfile.lock b/Gemfile.lock index 369c5b9..b8a62fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - apache-config-generator (0.2.7) + apache-config-generator (0.2.8) rainbow GEM diff --git a/lib/apache/rewrites.rb b/lib/apache/rewrites.rb index f58f1db..6b1c5b5 100644 --- a/lib/apache/rewrites.rb +++ b/lib/apache/rewrites.rb @@ -216,7 +216,6 @@ module Apache def from_tester(from, opts) from = test(from, opts) - from = @from if (@to == '-') from = :http_forbidden if (forbidden?) from end @@ -284,7 +283,9 @@ module Apache result = from if match?(from, opts) - result = super(from, opts) if !(@to == '-') + if !(@to == '-') + result = super(from, opts) + end end result.replace_placeholderize(opts) diff --git a/spec/apache/rewrites_spec.rb b/spec/apache/rewrites_spec.rb index 6ff4dd7..b865c28 100644 --- a/spec/apache/rewrites_spec.rb +++ b/spec/apache/rewrites_spec.rb @@ -97,14 +97,34 @@ describe Apache::RewriteRule, "a RewriteRule" do end context 'dash' do - subject { - rule = Apache::RewriteRule.new - rule.rule(%r{^/test$}, '-', :last => true) - rule - } + context 'no conditions' do + subject { + rule = Apache::RewriteRule.new + rule.rule(%r{^/test$}, '-', :last => true) + rule + } - it "should succeed and return itself" do - subject.test('/test').should == '/test' + it "should succeed and return itself" do + subject.test('/test').should == '/test' + subject.test('/fail').should == '/fail' + end + end + + context 'conditions' do + subject do + rule = Apache::RewriteRule.new + rule.cond('/%{REQUEST_FILENAME}', '^/test$') + rule.rule(%r{^/test$}, '-', :last => true) + rule + end + + it "should fail" do + subject.test('/test', :request_filename => 'cats').should == '/test' + end + + it "should succeed" do + subject.test('/test', :request_filename => 'test').should == '/test' + end end end end