Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe "logged in as admin area user", :shared=>true do
- it 'should redirect to login if not logged in' do
- #overwrite the stub again to make it not logged in
- controller.stub!(:current_user).and_return(:false)
- do_action
- response.should redirect_to(new_admin_session_path)
- end
- def do_action
- %w(get post put delete).each do |action|
- self.send "do_#{action}" if self.respond_to?("do_#{action}")
- end
- end
- end
- describe 'admin user with administrative privileges', :shared=>true do
- it_should_behave_like "logged in as admin area user"
- it 'should respond with forbidden message if not admin' do
- controller.stub!(:current_user).and_return(mock_model(User, :login_required? =>true, :authorized? =>true, :is_enabled? => true, :is_admin? => false))
- do_action
- response.response_code.should == 403 #forbidden http status code
- end
- def do_action
- %w(get post put delete).each do |action|
- self.send "do_#{action}" if self.respond_to?("do_#{action}")
- end
- end
- end
Add Comment
Please, Sign In to add comment