devise_invitable 1.7.4 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise_invitable might be problematic. Click here for more details.

Files changed (83) hide show
  1. checksums.yaml +5 -5
  2. data/{CHANGELOG → CHANGELOG.md} +54 -19
  3. data/README.rdoc +98 -111
  4. data/app/controllers/devise/invitations_controller.rb +41 -41
  5. data/app/controllers/devise_invitable/registrations_controller.rb +11 -11
  6. data/app/views/devise/invitations/edit.html.erb +14 -8
  7. data/app/views/devise/invitations/new.html.erb +11 -7
  8. data/app/views/devise/mailer/invitation_instructions.html.erb +2 -2
  9. data/app/views/devise/mailer/invitation_instructions.text.erb +2 -2
  10. data/config/locales/ar.yml +23 -0
  11. data/config/locales/da.yml +41 -0
  12. data/config/locales/de.yml +31 -0
  13. data/config/locales/en.yml +1 -1
  14. data/config/locales/es.yml +31 -0
  15. data/config/locales/et.yml +23 -0
  16. data/config/locales/fa.yml +31 -0
  17. data/config/locales/fr.yml +34 -0
  18. data/config/locales/it.yml +31 -0
  19. data/config/locales/ja.yml +32 -0
  20. data/config/locales/ko.yml +24 -0
  21. data/config/locales/nl.yml +32 -0
  22. data/config/locales/no.yml +17 -0
  23. data/config/locales/pl.yml +31 -0
  24. data/config/locales/pt-BR.yml +23 -0
  25. data/config/locales/pt.yml +23 -0
  26. data/config/locales/ru.yml +23 -0
  27. data/config/locales/tr.yml +24 -0
  28. data/config/locales/ua.yml +31 -0
  29. data/config/locales/vi.yml +25 -0
  30. data/config/locales/zh-HK.yml +31 -0
  31. data/config/locales/zh-TW.yml +31 -0
  32. data/lib/devise_invitable.rb +5 -4
  33. data/lib/devise_invitable/controllers/helpers.rb +3 -4
  34. data/lib/devise_invitable/inviter.rb +4 -3
  35. data/lib/devise_invitable/mailer.rb +1 -1
  36. data/lib/devise_invitable/mapping.rb +6 -5
  37. data/lib/devise_invitable/models.rb +48 -32
  38. data/lib/devise_invitable/parameter_sanitizer.rb +18 -18
  39. data/lib/devise_invitable/routes.rb +5 -5
  40. data/lib/devise_invitable/version.rb +1 -1
  41. data/lib/generators/active_record/devise_invitable_generator.rb +3 -3
  42. data/lib/generators/active_record/templates/migration.rb +0 -1
  43. data/lib/generators/devise_invitable/devise_invitable_generator.rb +4 -8
  44. data/lib/generators/devise_invitable/install_generator.rb +11 -14
  45. data/lib/generators/devise_invitable/templates/simple_form_for/invitations/edit.html.erb +10 -6
  46. data/lib/generators/devise_invitable/templates/simple_form_for/invitations/new.html.erb +10 -6
  47. data/lib/generators/devise_invitable/views_generator.rb +6 -6
  48. data/test/functional/registrations_controller_test.rb +24 -25
  49. data/test/generators/views_generator_test.rb +7 -6
  50. data/test/generators_test.rb +3 -2
  51. data/test/integration/invitation_remove_test.rb +8 -8
  52. data/test/integration/invitation_test.rb +46 -46
  53. data/test/integration_tests_helper.rb +8 -9
  54. data/test/model_tests_helper.rb +5 -5
  55. data/test/models/invitable_test.rb +123 -108
  56. data/test/models_test.rb +3 -3
  57. data/test/orm/active_record.rb +5 -1
  58. data/test/orm/mongoid.rb +2 -2
  59. data/test/rails_app/app/controllers/admins_controller.rb +4 -3
  60. data/test/rails_app/app/controllers/application_controller.rb +11 -10
  61. data/test/rails_app/app/controllers/free_invitations_controller.rb +12 -9
  62. data/test/rails_app/app/controllers/users_controller.rb +2 -2
  63. data/test/rails_app/app/models/admin.rb +7 -10
  64. data/test/rails_app/app/models/octopussy.rb +4 -4
  65. data/test/rails_app/app/models/user.rb +20 -20
  66. data/test/rails_app/app/views/admins/new.html.erb +9 -5
  67. data/test/rails_app/app/views/devise/sessions/new.html.erb +14 -6
  68. data/test/rails_app/app/views/free_invitations/new.html.erb +9 -5
  69. data/test/rails_app/app/views/layouts/application.html.erb +3 -4
  70. data/test/rails_app/app/views/users/invitations/new.html.erb +15 -9
  71. data/test/rails_app/config/application.rb +7 -6
  72. data/test/rails_app/config/boot.rb +2 -2
  73. data/test/rails_app/config/credentials.yml.enc +1 -0
  74. data/test/rails_app/config/initializers/devise.rb +4 -3
  75. data/test/rails_app/config/initializers/secret_token.rb +3 -1
  76. data/test/rails_app/config/initializers/session_store.rb +1 -1
  77. data/test/rails_app/config/initializers/wrap_parameters.rb +1 -1
  78. data/test/rails_app/config/master.key +1 -0
  79. data/test/rails_app/config/routes.rb +3 -3
  80. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -2
  81. data/test/routes_test.rb +4 -4
  82. data/test/test_helper.rb +6 -19
  83. metadata +48 -23
@@ -10,37 +10,37 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
10
10
  # josevalim: you are required to do that because the routes sets this kind
11
11
  # of stuff automatically. But functional tests are not using the routes.
12
12
  # see https://github.com/plataformatec/devise/issues/1196
13
- @request.env["devise.mapping"] = Devise.mappings[:user]
13
+ @request.env['devise.mapping'] = Devise.mappings[:user]
14
14
  end
15
15
 
16
16
  test "invited users may still sign up directly by themselves" do
17
17
  # invite the invitee
18
18
  sign_in @issuer
19
- invitee_email = "invitee@example.org"
19
+ invitee_email = 'invitee@example.org'
20
20
 
21
- User.invite!(:email => invitee_email) do |u|
21
+ User.invite!(email: invitee_email) do |u|
22
22
  u.skip_invitation = true
23
23
  u.invited_by = @issuer
24
24
  end
25
25
  sign_out @issuer
26
26
 
27
- @invitee = User.where(:email => invitee_email).first
27
+ @invitee = User.where(email: invitee_email).first
28
28
  assert_nil @invitee.invitation_accepted_at
29
29
  assert_not_nil @invitee.invitation_token
30
30
  assert !@invitee.confirmed?
31
31
 
32
32
  # sign_up the invitee
33
33
  assert_difference('ActionMailer::Base.deliveries.size') do
34
- post :create, params: {:user => {:email => invitee_email, :password => "1password", :bio => '.'}}
34
+ post :create, params: { user: { email: invitee_email, password: '1password', bio: '.' } }
35
35
  end
36
36
 
37
- @invitee = User.where(:email => invitee_email).first
37
+ @invitee = User.where(email: invitee_email).first
38
38
 
39
39
  # do not send emails on model changes
40
40
  assert_difference('ActionMailer::Base.deliveries.size', 0) do
41
- @invitee.bio = "I am a robot"
41
+ @invitee.bio = 'I am a robot'
42
42
  @invitee.save!
43
- @invitee.bio = "I am a human"
43
+ @invitee.bio = 'I am a human'
44
44
  @invitee.save!
45
45
  end
46
46
 
@@ -54,20 +54,20 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
54
54
  end
55
55
 
56
56
  test "non-invited users may still sign up directly by themselves" do
57
- register_email = "invitee@example.org"
57
+ register_email = 'invitee@example.org'
58
58
  # sign_up the invitee
59
59
  assert_difference('ActionMailer::Base.deliveries.size') do
60
- post :create, params: {:user => {:email => register_email, :password => "1password", :bio => '.'}}
60
+ post :create, params: { user: { email: register_email, password: '1password', bio: '.' } }
61
61
  end
62
62
  assert_nil @controller.current_user
63
63
 
64
- @user = User.where(:email => register_email).first
64
+ @user = User.where(email: register_email).first
65
65
 
66
66
  # do not send emails on model changes
67
67
  assert_no_difference('ActionMailer::Base.deliveries.size') do
68
- @user.bio = "I am a robot"
68
+ @user.bio = 'I am a robot'
69
69
  @user.save!
70
- @user.bio = "I am a human"
70
+ @user.bio = 'I am a human'
71
71
  @user.save!
72
72
  end
73
73
 
@@ -80,36 +80,35 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
80
80
  end
81
81
 
82
82
  test "not invitable resources can register" do
83
- @request.env["devise.mapping"] = Devise.mappings[:admin]
84
- invitee_email = "invitee@example.org"
83
+ @request.env['devise.mapping'] = Devise.mappings[:admin]
84
+ invitee_email = 'invitee@example.org'
85
85
 
86
- assert_nil Admin.where(:email => invitee_email).first
86
+ assert_nil Admin.where(email: invitee_email).first
87
87
 
88
- post :create, params: {:admin => {:email => invitee_email, :password => "1password"}}
88
+ post :create, params: { admin: { email: invitee_email, password: '1password' } }
89
89
 
90
- @invitee = Admin.where(:email => invitee_email).first
90
+ @invitee = Admin.where(email: invitee_email).first
91
91
  assert @invitee.encrypted_password.present?
92
92
  end
93
93
 
94
94
  test "not invitable resources are not logged in after sign up again" do
95
- @request.env["devise.mapping"] = Devise.mappings[:admin]
96
- invitee_email = "invitee@example.org"
95
+ @request.env['devise.mapping'] = Devise.mappings[:admin]
96
+ invitee_email = 'invitee@example.org'
97
97
 
98
- post :create, params: {:admin => {:email => invitee_email, :password => "1password"}}
98
+ post :create, params: { admin: { email: invitee_email, password: '1password' } }
99
99
  assert_response 302
100
100
 
101
- @invitee = Admin.where(:email => invitee_email).first
101
+ @invitee = Admin.where(email: invitee_email).first
102
102
  assert @invitee.encrypted_password.present?
103
103
 
104
104
  sign_out @invitee
105
- post :create, params: {:admin => {:email => invitee_email, :password => "2password"}}
105
+ post :create, params: { admin: { email: invitee_email, password: "2password" } }
106
106
  assert_response 200
107
- assert_equal @invitee.encrypted_password, Admin.where(:email => invitee_email).first.encrypted_password
107
+ assert_equal @invitee.encrypted_password, Admin.where(email: invitee_email).first.encrypted_password
108
108
  assert @controller.send(:resource).errors.present?
109
109
  end
110
110
 
111
111
  test "missing params on a create should not cause an error" do
112
-
113
112
  assert_nothing_raised { post :create }
114
113
  end
115
114
  end
@@ -28,13 +28,14 @@ class ViewsGeneratorTest < ::Rails::Generators::TestCase
28
28
  end
29
29
 
30
30
  private
31
- def assert_files
32
- assert views = { @invitations_path => %w/edit.html.erb new.html.erb/, @mailer_path => %w/invitation_instructions.html.erb/ }
33
31
 
34
- views.each do |path, files|
35
- files.each do |file|
36
- assert_file File.join path, file
32
+ def assert_files
33
+ assert views = { @invitations_path => %w/edit.html.erb new.html.erb/, @mailer_path => %w/invitation_instructions.html.erb/ }
34
+
35
+ views.each do |path, files|
36
+ files.each do |file|
37
+ assert_file File.join path, file
38
+ end
37
39
  end
38
40
  end
39
- end
40
41
  end
@@ -17,13 +17,14 @@ class GeneratorsTest < ActiveSupport::TestCase
17
17
 
18
18
  test "rails g devise_invitable:install" do
19
19
  @output = `cd #{RAILS_APP_PATH} && rails g devise_invitable:install -p`
20
- assert @output.match(%r{(inject|insert).* config/initializers/devise\.rb\n})
20
+ puts @output
21
+ assert @output.match(%r{(inject|insert|File unchanged! The supplied flag value not found!).* config/initializers/devise\.rb\n})
21
22
  assert @output.match(%r|create.* config/locales/devise_invitable\.en\.yml\n|)
22
23
  end
23
24
 
24
25
  test "rails g devise_invitable Octopussy" do
25
26
  @output = `cd #{RAILS_APP_PATH} && rails g devise_invitable Octopussy -p`
26
- assert @output.match(%r{(inject|insert).* app/models/octopussy\.rb\n})
27
+ assert @output.match(%r{(inject|insert|File unchanged! The supplied flag value not found!).* app/models/octopussy\.rb\n})
27
28
  assert @output.match(%r|invoke.* #{DEVISE_ORM}\n|)
28
29
  if DEVISE_ORM == :active_record
29
30
  assert @output.match(%r|create.* db/migrate/\d{14}_devise_invitable_add_to_octopussies\.rb\n|)
@@ -4,26 +4,26 @@ require 'integration_tests_helper'
4
4
  class InvitationRemoveTest < ActionDispatch::IntegrationTest
5
5
 
6
6
  test 'invited user can choose to remove his account/invite' do
7
- User.invite!(:email => "valid@email.com")
7
+ User.invite!(email: 'valid@email.com')
8
8
 
9
9
  # remove!
10
- visit remove_user_invitation_path(:invitation_token => Thread.current[:token])
10
+ visit remove_user_invitation_path(invitation_token: Thread.current[:token])
11
11
  assert_equal root_path, current_path
12
- assert page.has_css?('p#notice', :text => 'Your invitation was removed.')
12
+ assert page.has_css?('p#notice', text: 'Your invitation was removed.')
13
13
 
14
14
  # try to remove again!
15
- visit remove_user_invitation_path(:invitation_token => Thread.current[:token])
15
+ visit remove_user_invitation_path(invitation_token: Thread.current[:token])
16
16
  assert_equal root_path, current_path
17
- assert page.has_css?('p#alert', :text => 'The invitation token provided is not valid!')
17
+ assert page.has_css?('p#alert', text: 'The invitation token provided is not valid!')
18
18
  end
19
19
 
20
20
  test 'accepted user cannot remove his account (by using the original invitation token)' do
21
- user = User.invite!(:email => "valid@email.com")
21
+ user = User.invite!(email: 'valid@email.com')
22
22
  saved_token = Thread.current[:token]
23
23
  user.accept_invitation!
24
24
 
25
- visit remove_user_invitation_path(:invitation_token => saved_token)
25
+ visit remove_user_invitation_path(invitation_token: saved_token)
26
26
  assert_equal root_path, current_path
27
- assert page.has_css?('p#alert', :text => 'The invitation token provided is not valid!')
27
+ assert page.has_css?('p#alert', text: 'The invitation token provided is not valid!')
28
28
  end
29
29
  end
@@ -9,18 +9,18 @@ class InvitationTest < ActionDispatch::IntegrationTest
9
9
  def send_invitation(url = new_user_invitation_path, &block)
10
10
  visit url
11
11
 
12
- fill_in 'user_email', :with => 'user@test.com'
12
+ fill_in 'user_email', with: 'user@test.com'
13
13
  yield if block_given?
14
14
  click_button 'Send an invitation'
15
15
  end
16
16
 
17
- def set_password(options={}, &block)
17
+ def set_password(options = {}, &block)
18
18
  unless options[:visit] == false
19
- visit accept_user_invitation_path(:invitation_token => options[:invitation_token])
19
+ visit accept_user_invitation_path(invitation_token: options[:invitation_token])
20
20
  end
21
21
 
22
- fill_in 'user_password', :with => '987654321'
23
- fill_in 'user_password_confirmation', :with => '987654321'
22
+ fill_in 'user_password', with: '987654321'
23
+ fill_in 'user_password_confirmation', with: '987654321'
24
24
  yield if block_given?
25
25
  click_button options[:button] || 'Set my password'
26
26
  end
@@ -28,7 +28,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
28
28
  test 'not authenticated user should be able to send a free invitation' do
29
29
  send_invitation new_free_invitation_path
30
30
  assert_equal root_path, current_path
31
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
31
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
32
32
  end
33
33
 
34
34
  test 'not authenticated user should not be able to send an invitation' do
@@ -41,19 +41,19 @@ class InvitationTest < ActionDispatch::IntegrationTest
41
41
 
42
42
  send_invitation
43
43
  assert_equal root_path, current_path
44
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
44
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
45
45
  end
46
46
 
47
47
  test 'authenticated user with existing email should receive an error message' do
48
48
  user = create_full_user
49
49
  sign_in_as_user(user)
50
50
  send_invitation do
51
- fill_in 'user_email', :with => user.email
51
+ fill_in 'user_email', with: user.email
52
52
  end
53
53
 
54
54
  assert_equal user_invitation_path, current_path
55
55
  assert page.has_css?("input[type=text][value='#{user.email}']")
56
- assert page.has_css?('#error_explanation li', :text => 'Email has already been taken')
56
+ assert page.has_css?('#error_explanation li', text: 'Email has already been taken')
57
57
  end
58
58
 
59
59
  test 'authenticated user should not be able to visit edit invitation page' do
@@ -65,63 +65,63 @@ class InvitationTest < ActionDispatch::IntegrationTest
65
65
  end
66
66
 
67
67
  test 'invited user without password should not be able to sign in' do
68
- user = User.invite!(:email => "valid@email.com")
68
+ user = User.invite!(email: 'valid@email.com')
69
69
  user.password = 'test'
70
70
  sign_in_as_user user
71
71
 
72
72
  assert_equal new_user_session_path, current_path
73
- assert page.has_css?('p#alert', :text => 'You have a pending invitation, accept it to finish creating your account.')
73
+ assert page.has_css?('p#alert', text: 'You have a pending invitation, accept it to finish creating your account.')
74
74
  end
75
75
 
76
76
  test 'invited user with password should not be able to sign in' do
77
- user = User.invite!(:email => "valid@email.com")
77
+ user = User.invite!(email: 'valid@email.com')
78
78
  user.password = '987654321'
79
79
  user.save
80
80
  sign_in_as_user user
81
81
 
82
82
  assert_equal new_user_session_path, current_path
83
- assert page.has_css?('p#alert', :text => 'You have a pending invitation, accept it to finish creating your account.')
83
+ assert page.has_css?('p#alert', text: 'You have a pending invitation, accept it to finish creating your account.')
84
84
  end
85
85
 
86
86
  test 'not authenticated user with invalid invitation token should not be able to set his password' do
87
- user = User.invite!(:email => "valid@email.com")
87
+ user = User.invite!(email: 'valid@email.com')
88
88
  user.accept_invitation!
89
- visit accept_user_invitation_path(:invitation_token => 'invalid_token')
89
+ visit accept_user_invitation_path(invitation_token: 'invalid_token')
90
90
 
91
91
  assert_equal root_path, current_path
92
- assert page.has_css?('p#alert', :text => 'The invitation token provided is not valid!')
92
+ assert page.has_css?('p#alert', text: 'The invitation token provided is not valid!')
93
93
  end
94
94
 
95
95
  test 'not authenticated user with valid invitation token but invalid password should not be able to set his password' do
96
- user = User.invite!(:email => "valid@email.com")
97
- set_password :invitation_token => Thread.current[:token] do
98
- fill_in 'Password confirmation', :with => 'other_password'
96
+ user = User.invite!(email: 'valid@email.com')
97
+ set_password invitation_token: Thread.current[:token] do
98
+ fill_in 'Password confirmation', with: 'other_password'
99
99
  end
100
100
  assert_equal user_invitation_path, current_path
101
- assert page.has_css?('#error_explanation li', :text => /Password .*doesn\'t match/)
101
+ assert page.has_css?('#error_explanation li', text: /Password .*doesn\'t match/)
102
102
  assert !user.confirmed?
103
103
  end
104
104
 
105
105
  test 'not authenticated user with valid data should be able to change his password' do
106
- user = User.invite!(:email => "valid@email.com")
107
- set_password :invitation_token => Thread.current[:token]
106
+ user = User.invite!(email: 'valid@email.com')
107
+ set_password invitation_token: Thread.current[:token]
108
108
 
109
109
  assert_equal root_path, current_path
110
- assert page.has_css?('p#notice', :text => 'Your password was set successfully. You are now signed in.')
110
+ assert page.has_css?('p#notice', text: 'Your password was set successfully. You are now signed in.')
111
111
  assert user.reload.valid_password?('987654321')
112
112
  assert user.confirmed?
113
113
  end
114
114
 
115
115
  test 'after entering invalid data user should still be able to set his password' do
116
- user = User.invite!(:email => "valid@email.com")
117
- set_password :invitation_token => Thread.current[:token] do
118
- fill_in 'Password confirmation', :with => 'other_password'
116
+ user = User.invite!(email: 'valid@email.com')
117
+ set_password invitation_token: Thread.current[:token] do
118
+ fill_in 'Password confirmation', with: 'other_password'
119
119
  end
120
120
  assert_equal user_invitation_path, current_path
121
121
  assert page.has_css?('#error_explanation')
122
122
 
123
- set_password :visit => false
124
- assert page.has_css?('p#notice', :text => 'Your password was set successfully. You are now signed in.')
123
+ set_password visit: false
124
+ assert page.has_css?('p#notice', text: 'Your password was set successfully. You are now signed in.')
125
125
  assert user.reload.valid_password?('987654321')
126
126
  end
127
127
 
@@ -129,8 +129,8 @@ class InvitationTest < ActionDispatch::IntegrationTest
129
129
  original_option_value = Devise.allow_insecure_sign_in_after_accept
130
130
  Devise.allow_insecure_sign_in_after_accept = true
131
131
 
132
- User.invite!(:email => "valid@email.com")
133
- set_password :invitation_token => Thread.current[:token]
132
+ User.invite!(email: 'valid@email.com')
133
+ set_password invitation_token: Thread.current[:token]
134
134
 
135
135
  assert_equal root_path, current_path
136
136
  Devise.allow_insecure_sign_in_after_accept = original_option_value
@@ -140,22 +140,22 @@ class InvitationTest < ActionDispatch::IntegrationTest
140
140
  original_option_value = Devise.allow_insecure_sign_in_after_accept
141
141
  Devise.allow_insecure_sign_in_after_accept = false
142
142
 
143
- User.invite!(:email => "valid@email.com")
144
- set_password :invitation_token => Thread.current[:token]
143
+ User.invite!(email: 'valid@email.com')
144
+ set_password invitation_token: Thread.current[:token]
145
145
 
146
146
  assert_equal new_user_session_path, current_path
147
147
  Devise.allow_insecure_sign_in_after_accept = original_option_value
148
148
  end
149
149
 
150
150
  test 'clear token and set invitation_accepted_at after recover password instead of accept_invitation' do
151
- user = User.invite!(:email => "valid@email.com")
151
+ user = User.invite!(email: 'valid@email.com')
152
152
 
153
153
  visit new_user_password_path
154
- fill_in 'user_email', :with => 'valid@email.com'
154
+ fill_in 'user_email', with: 'valid@email.com'
155
155
  click_button 'Send me reset password instructions'
156
156
 
157
- visit edit_user_password_path(:reset_password_token => Thread.current[:token])
158
- set_password :visit => false, :button => 'Change my password'
157
+ visit edit_user_password_path(reset_password_token: Thread.current[:token])
158
+ set_password visit: false, button: 'Change my password'
159
159
 
160
160
  user.reload
161
161
  assert_nil user.invitation_token
@@ -174,7 +174,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
174
174
  send_invitation
175
175
  end
176
176
  assert_equal root_path, current_path
177
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
177
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
178
178
  user = User.find(user.id)
179
179
  assert !user.has_invitations_left?
180
180
  end
@@ -191,7 +191,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
191
191
  send_invitation
192
192
  end
193
193
  assert_equal user_invitation_path, current_path
194
- assert page.has_css?('p#alert', :text => 'No invitations remaining')
194
+ assert page.has_css?('p#alert', text: 'No invitations remaining')
195
195
  end
196
196
 
197
197
  test 'user with nil invitation_limit should default to User.invitation_limit' do
@@ -204,7 +204,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
204
204
 
205
205
  send_invitation
206
206
  assert_equal root_path, current_path
207
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
207
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
208
208
  user = User.find(user.id)
209
209
  assert_equal 2, user.invitation_limit
210
210
  end
@@ -219,13 +219,13 @@ class InvitationTest < ActionDispatch::IntegrationTest
219
219
 
220
220
  send_invitation
221
221
  assert_equal root_path, current_path
222
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
222
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
223
223
  user = User.find(user.id)
224
224
  assert_equal 2, user.invitation_limit
225
225
 
226
226
  send_invitation
227
227
  assert_equal root_path, current_path
228
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
228
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
229
229
  user = User.find(user.id)
230
230
  assert_equal 2, user.invitation_limit
231
231
  end
@@ -235,7 +235,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
235
235
  sign_in_as_user(user)
236
236
  send_invitation
237
237
 
238
- invited_user = User.where(:email => 'user@test.com').first
238
+ invited_user = User.where(email: 'user@test.com').first
239
239
  assert invited_user
240
240
  assert_equal user, invited_user.invited_by
241
241
  end
@@ -248,20 +248,20 @@ class InvitationTest < ActionDispatch::IntegrationTest
248
248
  end
249
249
 
250
250
  test 'authenticated admin should be able to send an admin invitation' do
251
- admin = Admin.create(:email => 'admin@test.com', :password => '123456', :password_confirmation => '123456')
251
+ admin = Admin.create(email: 'admin@test.com', password: '123456', password_confirmation: '123456')
252
252
  sign_in_as_user admin
253
253
 
254
254
  send_invitation new_admin_path
255
255
  assert_equal root_path, current_path
256
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
256
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
257
257
  end
258
258
 
259
259
  test 'authenticated admin should be redirected to own page after send a free invitation' do
260
- admin = Admin.create(:email => 'admin@test.com', :password => '123456', :password_confirmation => '123456')
260
+ admin = Admin.create(email: 'admin@test.com', password: '123456', password_confirmation: '123456')
261
261
  sign_in_as_user admin
262
262
 
263
263
  send_invitation new_free_invitation_path
264
264
  assert_equal root_path, current_path
265
- assert page.has_css?('p#notice', :text => 'An invitation email has been sent to user@test.com.')
265
+ assert page.has_css?('p#notice', text: 'An invitation email has been sent to user@test.com.')
266
266
  end
267
267
  end
@@ -7,11 +7,11 @@ class ActionDispatch::IntegrationTest
7
7
  def create_full_user
8
8
  @user ||= begin
9
9
  user = User.create!(
10
- :username => 'usertest',
11
- :email => 'fulluser@test.com',
12
- :password => '123456',
13
- :password_confirmation => '123456',
14
- :created_at => Time.now.utc
10
+ username: 'usertest',
11
+ email: 'fulluser@test.com',
12
+ password: '123456',
13
+ password_confirmation: '123456',
14
+ created_at: Time.now.utc,
15
15
  )
16
16
  user.confirm
17
17
  user
@@ -22,20 +22,19 @@ class ActionDispatch::IntegrationTest
22
22
  user ||= create_full_user
23
23
  resource_name = user.class.name.underscore
24
24
  visit send("new_#{resource_name}_session_path")
25
- fill_in "#{resource_name}_email", :with => user.email
26
- fill_in "#{resource_name}_password", :with => user.password
25
+ fill_in "#{resource_name}_email", with: user.email
26
+ fill_in "#{resource_name}_password", with: user.password
27
27
  click_button 'Log in'
28
28
  end
29
29
 
30
30
  # Fix assert_redirect_to in integration sessions because they don't take into
31
31
  # account Middleware redirects.
32
- #
33
32
  def assert_redirected_to(url)
34
33
  assert [301, 302].include?(@integration_session.status),
35
34
  "Expected status to be 301 or 302, got #{@integration_session.status}"
36
35
 
37
36
  url = prepend_host(url)
38
- location = prepend_host(@integration_session.headers["Location"])
37
+ location = prepend_host(@integration_session.headers['Location'])
39
38
  assert_equal url, location
40
39
  end
41
40