Class: SessionsControllerTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
AuthenticatedTestHelper
Defined in:
vendor/plugins/authentication/test/functional/sessions_controller_test.rb

Instance Method Summary collapse

Methods included from AuthenticatedTestHelper

#authorize_as, #login_as

Instance Method Details

#setupObject



14
15
16
17
18
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 14

def setup
  @controller = SessionsController.new
  @request    = ActionController::TestRequest.new
  @response   = ActionController::TestResponse.new
end

#test_should_delete_token_on_logoutObject



49
50
51
52
53
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 49

def test_should_delete_token_on_logout
   :quentin
  get :destroy
  assert_equal @response.cookies["auth_token"], []
end


70
71
72
73
74
75
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 70

def 
  users(:quentin).remember_me
  @request.cookies["auth_token"] = auth_token('invalid_auth_token')
  get :new
  assert !@controller.send(:logged_in?)
end


62
63
64
65
66
67
68
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 62

def 
  users(:quentin).remember_me
  users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago
  @request.cookies["auth_token"] = cookie_for(:quentin)
  get :new
  assert !@controller.send(:logged_in?)
end

#test_should_fail_login_and_not_redirectObject



26
27
28
29
30
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 26

def 
  post :create, :login => 'quentin', :password => 'bad password'
  assert_nil session[:user_id]
  assert_response :success
end

#test_should_login_and_redirectObject



20
21
22
23
24
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 20

def 
  post :create, :login => 'quentin', :password => 'test'
  assert session[:user_id]
  assert_response :redirect
end


55
56
57
58
59
60
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 55

def 
  users(:quentin).remember_me
  @request.cookies["auth_token"] = cookie_for(:quentin)
  get :new
  assert @controller.send(:logged_in?)
end

#test_should_logoutObject



32
33
34
35
36
37
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 32

def test_should_logout
   :quentin
  get :destroy
  assert_nil session[:user_id]
  assert_response :redirect
end

#test_should_not_remember_meObject



44
45
46
47
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 44

def test_should_not_remember_me
  post :create, :login => 'quentin', :password => 'test', :remember_me => "0"
  assert_nil @response.cookies["auth_token"]
end

#test_should_remember_meObject



39
40
41
42
# File 'vendor/plugins/authentication/test/functional/sessions_controller_test.rb', line 39

def test_should_remember_me
  post :create, :login => 'quentin', :password => 'test', :remember_me => "1"
  assert_not_nil @response.cookies["auth_token"]
end