Class: UsersControllerTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
AuthenticatedTestHelper
Defined in:
vendor/plugins/authentication/test/functional/users_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/users_controller_test.rb', line 14

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

#test_should_activate_userObject



72
73
74
75
76
77
78
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 72

def test_should_activate_user
  assert_nil User.authenticate('aaron', 'test')
  get :activate, :activation_code => users(:aaron).activation_code
  assert_redirected_to '/'
  assert_not_nil flash[:notice]
  assert_equal users(:aaron), User.authenticate('aaron', 'test')
end

#test_should_allow_signupObject



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

def 
  assert_difference 'User.count' do
    create_user
    assert_response :redirect
  end
end

#test_should_not_activate_user_with_blank_keyObject



87
88
89
90
91
92
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 87

def test_should_not_activate_user_with_blank_key
  get :activate, :activation_code => ''
  assert_nil flash[:notice]
rescue ActionController::RoutingError
  # well played, sir
end

#test_should_not_activate_user_without_keyObject



80
81
82
83
84
85
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 80

def test_should_not_activate_user_without_key
  get :activate
  assert_nil flash[:notice]
rescue ActionController::RoutingError
  # in the event your routes deny this, we'll just bow out gracefully.
end

#test_should_require_email_on_signupObject



51
52
53
54
55
56
57
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 51

def 
  assert_no_difference 'User.count' do
    create_user(:email => nil)
    assert assigns(:user).errors.on(:email)
    assert_response :success
  end
end

#test_should_require_login_on_signupObject



27
28
29
30
31
32
33
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 27

def 
  assert_no_difference 'User.count' do
    create_user(:login => nil)
    assert assigns(:user).errors.on(:login)
    assert_response :success
  end
end

#test_should_require_password_confirmation_on_signupObject



43
44
45
46
47
48
49
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 43

def 
  assert_no_difference 'User.count' do
    create_user(:password_confirmation => nil)
    assert assigns(:user).errors.on(:password_confirmation)
    assert_response :success
  end
end

#test_should_require_password_on_signupObject



35
36
37
38
39
40
41
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 35

def 
  assert_no_difference 'User.count' do
    create_user(:password => nil)
    assert assigns(:user).errors.on(:password)
    assert_response :success
  end
end

#test_should_sign_up_user_in_pending_stateObject



59
60
61
62
63
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 59

def 
  create_user
  assigns(:user).reload
  assert assigns(:user).pending?
end

#test_should_sign_up_user_with_activation_codeObject



66
67
68
69
70
# File 'vendor/plugins/authentication/test/functional/users_controller_test.rb', line 66

def 
  create_user
  assigns(:user).reload
  assert_not_nil assigns(:user).activation_code
end