Optional setting of status code on redirect
This commit is contained in:
parent
facd4f143b
commit
6b9f34cb61
|
@ -71,8 +71,8 @@ module Zero
|
|||
#
|
||||
# @param [String] location Redirect URL
|
||||
#
|
||||
def redirect(location)
|
||||
self.status = 302
|
||||
def redirect(location, status = 302)
|
||||
self.status = status
|
||||
self.header['Location'] = location
|
||||
end
|
||||
|
||||
|
|
|
@ -133,6 +133,14 @@ describe Zero::Response do
|
|||
value[0].should eq(302)
|
||||
value[1]['Location'].should eq('http://foo.bar/relocated/thingy')
|
||||
end
|
||||
|
||||
it "sets the given status code and the given Location" do
|
||||
subject.redirect('http://foo.bar/relocated/other_thingy', 307)
|
||||
value = subject.to_a
|
||||
|
||||
value[0].should eq(307)
|
||||
value[1]['Location'].should eq('http://foo.bar/relocated/other_thingy')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user