better support for to dash

This commit is contained in:
John Bintz 2011-01-11 16:34:52 -05:00
parent 70edad9be0
commit cc30030c08
3 changed files with 31 additions and 10 deletions

View File

@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
apache-config-generator (0.2.7) apache-config-generator (0.2.8)
rainbow rainbow
GEM GEM

View File

@ -216,7 +216,6 @@ module Apache
def from_tester(from, opts) def from_tester(from, opts)
from = test(from, opts) from = test(from, opts)
from = @from if (@to == '-')
from = :http_forbidden if (forbidden?) from = :http_forbidden if (forbidden?)
from from
end end
@ -284,7 +283,9 @@ module Apache
result = from result = from
if match?(from, opts) if match?(from, opts)
result = super(from, opts) if !(@to == '-') if !(@to == '-')
result = super(from, opts)
end
end end
result.replace_placeholderize(opts) result.replace_placeholderize(opts)

View File

@ -97,14 +97,34 @@ describe Apache::RewriteRule, "a RewriteRule" do
end end
context 'dash' do context 'dash' do
subject { context 'no conditions' do
rule = Apache::RewriteRule.new subject {
rule.rule(%r{^/test$}, '-', :last => true) rule = Apache::RewriteRule.new
rule rule.rule(%r{^/test$}, '-', :last => true)
} rule
}
it "should succeed and return itself" do it "should succeed and return itself" do
subject.test('/test').should == '/test' 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 end
end end