Support for /my/preferences to automatically redirect to the logged in

user.
This commit is contained in:
Robin Ward
2014-04-21 11:52:11 -04:00
parent 61e6eae728
commit b9ca124756
4 changed files with 45 additions and 1 deletions

View File

@ -1323,4 +1323,27 @@ describe UsersController do
end
end
describe '.my_redirect' do
it "returns 404 if the user is not logged in" do
get :my_redirect, path: "wat"
response.should_not be_success
response.should_not be_redirect
end
context "when the user is logged in" do
let!(:user) { log_in }
it "will not redirect to an invalid path" do
get :my_redirect, path: "wat/..password.txt"
response.should_not be_redirect
end
it "will redirect to an valid path" do
get :my_redirect, path: "preferences"
response.should be_redirect
end
end
end
end