From 8216781067d3e7e1735e41d59b319b2982a9ae3d Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Tue, 6 Mar 2012 21:29:07 +0100 Subject: [PATCH] Use store_location in Unauthorized handler --- app/controllers/application_controller.rb | 1 + spec/controllers/application_controller_spec.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 508a3ce..b140f64 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -52,6 +52,7 @@ class ApplicationController < ActionController::Base if request.xhr? render :json => "Unauthorized", :status => 401 else + store_location redirect_to login_path, :notice => "Please login" end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index a10ef50..712492a 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -43,6 +43,8 @@ describe FakeController do context "when typical request" do it "redirects to login_path" do + @controller.should_receive(:store_location) + get :foo flash[:notice].should == "Please login"