Commit cd27ffa

mo khan <mo@mokhan.ca>
2014-04-10 03:53:46
redirect to login when not signed in.
1 parent 15dc7e8
Changed files (2)
app/controllers/application_controller.rb
@@ -16,9 +16,9 @@ class ApplicationController < ActionController::Base
 
   def ensure_valid_session
     unless session[:session_id] && @current_session = Session.find(session[:session_id])
-      render nothing: true, status: :unauthorized
+      redirect_to new_login_path
     end
   rescue ActiveRecord::RecordNotFound
-    render nothing: true, status: :unauthorized
+    redirect_to new_login_path
   end
 end
spec/controllers/application_controller_spec.rb
@@ -26,14 +26,14 @@ describe ApplicationController do
   context "when not signed in" do
     it "boots you out when their is no session_id" do
       get :index
-      response.status.should == 401
+      response.should redirect_to(new_login_path)
     end
 
     it "boots you out when the session id is not known" do
       Session.stub(:find).with(100).and_raise(ActiveRecord::RecordNotFound)
 
       get :index, {}, session_id: 100
-      response.status.should == 401
+      response.should redirect_to(new_login_path)
     end
   end
 end