Guest User

Untitled

a guest
Apr 13th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. require File.dirname(__FILE__) + '/../spec_helper'
  2. require File.dirname(__FILE__) + '/../helpers/controller_spec_helper'
  3.  
  4. describe SessionController, 'handling POST /sessions' do
  5. before(:each) do
  6. @user = User.new
  7. User.stub!(:authenticate).and_return(@user)
  8.  
  9. @controller.stub!(:current_user).and_return(@user)
  10. @user.stub!(:permissions_hash).and_return('permissions')
  11. end
  12.  
  13. def do_post
  14. post :create, :username => 'admin', :password => 'password'
  15. end
  16.  
  17. it 'should authenticate user and set to current user' do
  18. User.should_receive(:authenticate).with('admin', 'password').and_return(@user)
  19. do_post
  20. end
  21.  
  22. it 'should store permissions hash in session' do
  23. do_post
  24. @session = mock('session')
  25. controller.stub!(:session).and_return(@session)
  26. @session.should_receive(:[]=)
  27. end
  28.  
  29. it 'should set cookie code if requested'
  30.  
  31. it 'should set cookie if requested'
  32.  
  33. it 'should redirect to dashboard index'
  34.  
  35. it 'should redirect to requested page where necessary'
  36.  
  37. it 'should raise a login error when authentication fails'
  38.  
  39. it 'should render new when authentication fails'
  40. end
Add Comment
Please, Sign In to add comment