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

Commit

Permalink
Merge pull request #189 from codefirst/id/189
Browse files Browse the repository at this point in the history
ActionController::ActionControllerError: Cannot redirect to nil! refs #189
  • Loading branch information
mallowlabs committed Jun 10, 2014
2 parents d6fcf98 + b52fb6f commit c0fe7f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def logout
session.delete :cached_current_user
session.delete :current_user_id
end
redirect_to request.referer
redirect_to(request.referer || root_path)
end

def failure
Expand Down
25 changes: 18 additions & 7 deletions spec/controllers/login_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@

}
context "ログアウト後" do
before do
@user = User.new.tap{|user| user.save! }
session[:current_user_id] = @user.id
request.stub(:referer) { 'http://localhost' }
post :logout
context "referer is nil" do
before do
@user = User.new.tap{|user| user.save! }
session[:current_user_id] = @user.id
post :logout
end
subject { response }
it { should redirect_to root_path }
end
context "referer is not nil" do
before do
@user = User.new.tap{|user| user.save! }
session[:current_user_id] = @user.id
request.stub(:referer) { 'http://localhost' }
post :logout
end
subject { session }
its([:current_user_id]) { should be_nil }
end
subject { session }
its([:current_user_id]) { should be_nil }
end

context "callback" do
Expand Down

0 comments on commit c0fe7f5

Please sign in to comment.