Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
Merge 616c78d into 63e9aa7
Browse files Browse the repository at this point in the history
  • Loading branch information
suer committed Oct 12, 2014
2 parents 63e9aa7 + 616c78d commit 262e06a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def logout
end

def failure
redirect_to :back, :alert => params[:message]
if request.env["HTTP_REFERER"]
redirect_to :back, :alert => params[:message]
else
redirect_to root_path, :alert => params[:message]
end
end
end
16 changes: 16 additions & 0 deletions spec/controllers/login_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@
its(:screen_name) { should == 'nickname' }
its(:profile_image_url) { should == 'http://example.com/a.jpg' }
end

context "login/failure" do
context "access from other page" do
before do
request.env["HTTP_REFERER"] = "http://example.com"
get :failure
end
it { should redirect_to "http://example.com" }
end
context "access directly" do
before do
get :failure
end
it { should redirect_to root_path }
end
end
end

0 comments on commit 262e06a

Please sign in to comment.