add support for dash 'to' in rewriterule tests
This commit is contained in:
parent
e0706fdded
commit
70edad9be0
@ -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
|
||||
|
@ -1,3 +1,3 @@
|
||||
module Apache
|
||||
VERSION = '0.2.7'
|
||||
VERSION = '0.2.8'
|
||||
end
|
||||
|
@ -1,4 +1,5 @@
|
||||
require 'spec_helper'
|
||||
require 'apache/config'
|
||||
|
||||
describe Apache::Config, "rewrites" do
|
||||
let(:apache) { Apache::Config }
|
||||
@ -71,26 +72,40 @@ describe Apache::MatchableThing, "something that can be matched" do
|
||||
end
|
||||
|
||||
describe Apache::RewriteRule, "a RewriteRule" do
|
||||
subject do
|
||||
rule = Apache::RewriteRule.new
|
||||
rule.cond('/%{REQUEST_FILENAME}', '^/test$')
|
||||
rule.rule(%r{^/test$}, '/test2', :last => true, :preserve_query_string => true)
|
||||
rule
|
||||
context 'basic' do
|
||||
subject do
|
||||
rule = Apache::RewriteRule.new
|
||||
rule.cond('/%{REQUEST_FILENAME}', '^/test$')
|
||||
rule.rule(%r{^/test$}, '/test2', :last => true, :preserve_query_string => true)
|
||||
rule
|
||||
end
|
||||
|
||||
its(:to_s) { should == 'RewriteRule "^/test$" "/test2" [L,QSA]' }
|
||||
its(:to_a) { should == [
|
||||
'',
|
||||
'RewriteCond "/%{REQUEST_FILENAME}" "^/test$"',
|
||||
'RewriteRule "^/test$" "/test2" [L,QSA]'
|
||||
] }
|
||||
|
||||
it "should not the test" do
|
||||
subject.test('/test', :request_filename => 'test').should == '/test2'
|
||||
end
|
||||
|
||||
it "should fail if opts is not provided" do
|
||||
lambda { subject.match?('test', nil) }.should raise_error
|
||||
end
|
||||
end
|
||||
|
||||
its(:to_s) { should == 'RewriteRule "^/test$" "/test2" [L,QSA]' }
|
||||
its(:to_a) { should == [
|
||||
'',
|
||||
'RewriteCond "/%{REQUEST_FILENAME}" "^/test$"',
|
||||
'RewriteRule "^/test$" "/test2" [L,QSA]'
|
||||
] }
|
||||
context 'dash' do
|
||||
subject {
|
||||
rule = Apache::RewriteRule.new
|
||||
rule.rule(%r{^/test$}, '-', :last => true)
|
||||
rule
|
||||
}
|
||||
|
||||
it "should not the test" do
|
||||
subject.test('/test', :request_filename => 'test').should == '/test2'
|
||||
end
|
||||
|
||||
it "should fail if opts is not provided" do
|
||||
lambda { subject.match?('test', nil) }.should raise_error
|
||||
it "should succeed and return itself" do
|
||||
subject.test('/test').should == '/test'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user