Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added spec for application controller

  • Loading branch information...
commit 7158b3c870d229b5670aadfa4521aef6391e351e 1 parent b1d96a4
@tomcz tomcz authored
View
3  app/controllers/application_controller.rb
@@ -13,7 +13,8 @@ class ApplicationController < ActionController::Base
protected
def authorize
- unless User.find_by_uuid(session[:user_id])
+ user_id = session[:user_id]
+ unless user_id and User.find_by_uuid(user_id)
session[:original_uri] = request.request_uri
redirect_to :controller => 'admin', :action => 'login'
end
View
20 spec/controllers/admin_controller_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe AdminController do
+
+ context 'not logged in' do
+ it 'should redirect to login when asked for index page' do
+ get :index
+ response.should redirect_to(:controller => 'admin', :action => 'login')
+ end
+ end
+
+ context 'logged in as administrator' do
+ it 'should render index page'do
+ User.should_receive(:find_by_uuid).with('foo').and_return(mock_model(User))
+ get :index, {}, {:user_id => 'foo'}
+ response.should render_template('index')
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.