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