add support for dash 'to' in rewriterule tests

This commit is contained in:
John Bintz 2011-01-11 10:39:52 -05:00
parent e0706fdded
commit 70edad9be0
3 changed files with 36 additions and 19 deletions

View File

@ -283,7 +283,9 @@ module Apache
opts[:request_uri] = from
result = from
result = super(from, opts) if match?(from, opts)
if match?(from, opts)
result = super(from, opts) if !(@to == '-')
end
result.replace_placeholderize(opts)
end

View File

@ -1,3 +1,3 @@
module Apache
VERSION = '0.2.7'
VERSION = '0.2.8'
end

View File

@ -1,4 +1,5 @@
require 'spec_helper'
require 'apache/config'
describe Apache::Config, "rewrites" do
let(:apache) { Apache::Config }
@ -71,6 +72,7 @@ describe Apache::MatchableThing, "something that can be matched" do
end
describe Apache::RewriteRule, "a RewriteRule" do
context 'basic' do
subject do
rule = Apache::RewriteRule.new
rule.cond('/%{REQUEST_FILENAME}', '^/test$')
@ -92,6 +94,19 @@ describe Apache::RewriteRule, "a RewriteRule" do
it "should fail if opts is not provided" do
lambda { subject.match?('test', nil) }.should raise_error
end
end
context 'dash' 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'
end
end
end
describe Apache::RewriteCondition, "a RewriteCond" do