devise_invitable 2.0.6 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.rdoc +5 -3
- data/app/controllers/devise/invitations_controller.rb +3 -3
- data/config/locales/ca.yml +32 -0
- data/config/locales/es.yml +1 -1
- data/config/locales/fr.yml +3 -5
- data/config/locales/id.yml +31 -0
- data/lib/devise_invitable/controllers/helpers.rb +4 -0
- data/lib/devise_invitable/mapping.rb +4 -2
- data/lib/devise_invitable/models.rb +2 -2
- data/lib/devise_invitable/version.rb +1 -1
- data/lib/generators/devise_invitable/devise_invitable_generator.rb +1 -1
- data/test/functional/controller_helpers_test.rb +10 -0
- data/test/integration/invitation_test.rb +1 -1
- data/test/mailers/invitation_mail_test.rb +1 -1
- data/test/model_tests_helper.rb +1 -1
- data/test/models/invitable_test.rb +64 -11
- data/test/orm/active_record.rb +6 -1
- data/test/test_helper.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8ff92d4a82378780e01c6d3cfe57ff0808b08d49a619e3a899e94a86e7ec46c
|
4
|
+
data.tar.gz: 174e7982212230032987ad9b6b1ed572b98fda73fc0652e095ae71c1b6282436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25a25c7ec4df1183ef43d399f73cb7a4b661cc33df172d660dd551f658bebce01ac552c837608affeac59aeaaa85b137ad56247278fbe5a436ea15d03131b1e3
|
7
|
+
data.tar.gz: 07a394b356fb623ab7a8ca48486acd935ea5c69b86969ccae667d414bc6d7319ec2e5fe90c0cdc8ff2a9f46eace35bfd517df659fc445088f4e43a0f6536590c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
+
## 2.0.9
|
2
|
+
- Do not accept expired invitation on password reset ([#897](https://github.com/scambra/devise_invitable/pull/897))
|
3
|
+
|
4
|
+
## 2.0.8
|
5
|
+
- Fix for turbo stream
|
6
|
+
|
7
|
+
## 2.0.7
|
8
|
+
- Allow customizing invalid_token_path_for, the path to redirect users who try to accept with invalid token
|
9
|
+
- Don't override registrations controller in routes if module option is used
|
10
|
+
- Fix typo in spanish translation, add Catalan translation ([#857](https://github.com/scambra/devise_invitable/pull/857))
|
11
|
+
- Fix for ruby 3.2.0
|
12
|
+
|
1
13
|
## 2.0.6
|
2
14
|
- Fix submit form failure with turbolinks, fixes ([#865](https://github.com/scambra/devise_invitable/issues/865))
|
3
15
|
- Fix obsolete symbols in German translation ([#864](https://github.com/scambra/devise_invitable/pull/864))
|
16
|
+
- Allow to provide validate option to the instance method "invite!", default to follow the setting validate_on_invite
|
4
17
|
|
5
18
|
## 2.0.5
|
6
19
|
- Fix NoMethodError in random_password when validatable is not used ([#850](https://github.com/scambra/devise_invitable/pull/850))
|
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= DeviseInvitable
|
2
|
-
{<img src="https://badge.fury.io/rb/devise_invitable.svg"/>}[http://badge.fury.io/rb/devise_invitable]
|
2
|
+
{<img src="https://badge.fury.io/rb/devise_invitable.svg"/>}[http://badge.fury.io/rb/devise_invitable]
|
3
|
+
{<img src="https://github.com/scambra/devise_invitable/actions/workflows/ci.yml/badge.svg"/>}[https://github.com/scambra/devise_invitable/actions/workflows/ci.yml]
|
4
|
+
{<img src="https://codeclimate.com/github/scambra/devise_invitable/badges/gpa.svg"/>}[https://codeclimate.com/github/scambra/devise_invitable]
|
3
5
|
|
4
6
|
It adds support to Devise[https://github.com/plataformatec/devise] for sending invitations by email (it requires to be authenticated) and accept the invitation setting the password.
|
5
7
|
|
@@ -339,7 +341,7 @@ To accept an invitation with a token use the <tt>accept_invitation!</tt> class m
|
|
339
341
|
=== Callbacks
|
340
342
|
|
341
343
|
A callback event is fired before and after an invitation is created (User#invite!) or accepted (User#accept_invitation!). For example, in your resource model you can add:
|
342
|
-
|
344
|
+
# Note: callbacks should be placed after devise: :invitable is specified.
|
343
345
|
before_invitation_created :email_admins
|
344
346
|
after_invitation_accepted :email_invited_by
|
345
347
|
|
@@ -370,7 +372,7 @@ After an invitation is created and sent, the inviter will be redirected to <tt>a
|
|
370
372
|
|
371
373
|
After an invitation is accepted, the invitee will be redirected to <tt>after_accept_path_for(resource)</tt>, which is the same path as <tt>signed_in_root_path</tt> by default. If you want to override the path, override invitations controller and define <tt>after_accept_path_for</tt> method. This is useful in the common case that a user is invited to a specific location in your application. More on {Devise's README}[https://github.com/plataformatec/devise], "Controller filters and helpers" section.
|
372
374
|
|
373
|
-
The invitation email includes a link to accept the invitation that looks like this: <tt>/users/invitation/accept?invitation_token=abcd123</tt>. When clicked, the invited must set a password in order to accept its invitation. Note that if the <tt>invitation_token</tt> is not present or not valid, the invited is redirected to <tt>after_sign_out_path_for(resource_name)</tt>.
|
375
|
+
The invitation email includes a link to accept the invitation that looks like this: <tt>/users/invitation/accept?invitation_token=abcd123</tt>. When clicked, the invited must set a password in order to accept its invitation. Note that if the <tt>invitation_token</tt> is not present or not valid, the invited is redirected to <tt>invalid_token_path_for(resource_name)</tt>, which by default is <tt>after_sign_out_path_for(resource_name)</tt>.
|
374
376
|
|
375
377
|
The controller sets the <tt>invited_by_id</tt> attribute for the new user to the current user. This will let you easily keep track of who invited whom.
|
376
378
|
|
@@ -31,7 +31,7 @@ class Devise::InvitationsController < DeviseController
|
|
31
31
|
respond_with resource, location: after_invite_path_for(current_inviter, resource)
|
32
32
|
end
|
33
33
|
else
|
34
|
-
|
34
|
+
respond_with(resource)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -63,7 +63,7 @@ class Devise::InvitationsController < DeviseController
|
|
63
63
|
end
|
64
64
|
else
|
65
65
|
resource.invitation_token = raw_invitation_token
|
66
|
-
|
66
|
+
respond_with(resource)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -99,7 +99,7 @@ class Devise::InvitationsController < DeviseController
|
|
99
99
|
def resource_from_invitation_token
|
100
100
|
unless params[:invitation_token] && self.resource = resource_class.find_by_invitation_token(params[:invitation_token], true)
|
101
101
|
set_flash_message(:alert, :invitation_token_invalid) if is_flashing_format?
|
102
|
-
redirect_to
|
102
|
+
redirect_to invalid_token_path_for(resource_name)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
ca:
|
3
|
+
devise:
|
4
|
+
failure:
|
5
|
+
invited: "Tens una invitació pendent, accepta-la per acabar de crear el teu compte."
|
6
|
+
invitations:
|
7
|
+
send_instructions: "S'ha enviat una invitació a %{email}."
|
8
|
+
invitation_token_invalid: "La invitació no es vàlida!"
|
9
|
+
updated: "S'ha configurat la seva contrasenya i s'ha ingressat al sistema"
|
10
|
+
updated_not_active: "La seva contrasenya s'ha configurat correctament."
|
11
|
+
no_invitations_remaining: "No queden invitacions"
|
12
|
+
invitation_removed: "S'ha retirat la seva invitació"
|
13
|
+
new:
|
14
|
+
header: "Enviar Invitació"
|
15
|
+
submit_button: "Envia una invitació"
|
16
|
+
edit:
|
17
|
+
header: "Establir contrasenya"
|
18
|
+
submit_button: "Guardar la meva contrasenya"
|
19
|
+
mailer:
|
20
|
+
invitation_instructions:
|
21
|
+
subject: "Instruccions de la invitació"
|
22
|
+
hello: "Hola %{email}"
|
23
|
+
someone_invited_you: "Has estat invitat a %{url}, pots acceptar-ho seguint el següent enllaç"
|
24
|
+
accept: "Aceptar la invitació"
|
25
|
+
accept_until: "Aquesta invitació expirarà en %{due_date}."
|
26
|
+
ignore: "Si no li interessa aquesta invitació, simplement ignori aquest correu. No es crearà el teu compte fins que accedeixis a l'anterior enllaç i creïs una contrasenya"
|
27
|
+
time:
|
28
|
+
formats:
|
29
|
+
devise:
|
30
|
+
mailer:
|
31
|
+
invitation_instructions:
|
32
|
+
accept_until_format: "%d de %B de %Y, %H:%M"
|
data/config/locales/es.yml
CHANGED
@@ -17,7 +17,7 @@ es:
|
|
17
17
|
submit_button: "Guardar mi contraseña"
|
18
18
|
mailer:
|
19
19
|
invitation_instructions:
|
20
|
-
subject: "
|
20
|
+
subject: "Instrucciones de la invitación"
|
21
21
|
hello: "Hola %{email}"
|
22
22
|
someone_invited_you: "Has sido invitado a %{url}, puedes aceptarlo siguiendo el siguiente enlace"
|
23
23
|
accept: "Aceptar la invitación"
|
data/config/locales/fr.yml
CHANGED
@@ -14,10 +14,8 @@ fr:
|
|
14
14
|
legend: Envoyer l’invitation
|
15
15
|
submit_button: Envoyer
|
16
16
|
edit:
|
17
|
-
header:
|
18
|
-
submit_button:
|
19
|
-
new_password: Mot de passe
|
20
|
-
new_password_confirmation: Confirmation du mot de passe
|
17
|
+
header: Définissez votre mot de passe
|
18
|
+
submit_button: Définir mon mot de passe
|
21
19
|
mailer:
|
22
20
|
invitation_instructions:
|
23
21
|
subject: 'Vous avez reçu une invitation'
|
@@ -31,4 +29,4 @@ fr:
|
|
31
29
|
devise:
|
32
30
|
mailer:
|
33
31
|
invitation_instructions:
|
34
|
-
accept_until_format: "%B %d, %Y %I:%M %p"
|
32
|
+
accept_until_format: "%B %d, %Y %I:%M %p"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
id:
|
2
|
+
devise:
|
3
|
+
failure:
|
4
|
+
invited: "Anda memiliki undangan yang tertunda, harap terima undangan tersebut untuk menyelesaikan pembuatan akun Anda."
|
5
|
+
invitations:
|
6
|
+
send_instructions: "Email undangan telah dikirim ke %{email}."
|
7
|
+
invitation_token_invalid: "Token undangan yang diberikan tidak valid!"
|
8
|
+
updated: "Kata sandi Anda telah berhasil diatur. Anda sudah masuk."
|
9
|
+
updated_not_active: "Kata sandi Anda telah berhasil diatur."
|
10
|
+
no_invitations_remaining: "Tidak ada undangan tersisa."
|
11
|
+
invitation_removed: "Undangan Anda telah dihapus."
|
12
|
+
new:
|
13
|
+
header: "Kirim Undangan"
|
14
|
+
submit_button: "Kirim undangan"
|
15
|
+
edit:
|
16
|
+
header: "Atur kata sandi Anda"
|
17
|
+
submit_button: "Atur kata sandi"
|
18
|
+
mailer:
|
19
|
+
invitation_instructions:
|
20
|
+
subject: "Instruksi Undangan"
|
21
|
+
hello: "Halo %{email}"
|
22
|
+
someone_invited_you: "Seseorang telah mengundang Anda ke %{url}. Anda dapat menerima undangan ini melalui tautan di bawah ini."
|
23
|
+
accept: "Terima Undangan"
|
24
|
+
accept_until: "Undangan ini akan berakhir pada %{due_date}."
|
25
|
+
ignore: "Jika Anda tidak ingin menerima undangan ini, silakan abaikan email ini. Akun Anda tidak akan dibuat sampai Anda mengakses tautan di atas dan mengatur kata sandi Anda."
|
26
|
+
time:
|
27
|
+
formats:
|
28
|
+
devise:
|
29
|
+
mailer:
|
30
|
+
invitation_instructions:
|
31
|
+
accept_until_format: "%d %B %Y %H:%M:%S"
|
@@ -3,8 +3,10 @@ module DeviseInvitable
|
|
3
3
|
private
|
4
4
|
|
5
5
|
def default_controllers(options)
|
6
|
-
options[:
|
7
|
-
|
6
|
+
unless options[:module]
|
7
|
+
options[:controllers] ||= {}
|
8
|
+
options[:controllers][:registrations] ||= 'devise_invitable/registrations'
|
9
|
+
end
|
8
10
|
super
|
9
11
|
end
|
10
12
|
end
|
@@ -195,7 +195,7 @@ module Devise
|
|
195
195
|
def clear_reset_password_token
|
196
196
|
reset_password_token_present = reset_password_token.present?
|
197
197
|
super
|
198
|
-
accept_invitation! if reset_password_token_present &&
|
198
|
+
accept_invitation! if reset_password_token_present && valid_invitation?
|
199
199
|
end
|
200
200
|
|
201
201
|
def clear_errors_on_valid_keys
|
@@ -231,7 +231,7 @@ module Devise
|
|
231
231
|
def add_taken_error(key)
|
232
232
|
errors.add(key, :taken)
|
233
233
|
end
|
234
|
-
|
234
|
+
|
235
235
|
def invitation_taken?
|
236
236
|
!invited_to_sign_up?
|
237
237
|
end
|
@@ -7,7 +7,7 @@ module DeviseInvitable
|
|
7
7
|
|
8
8
|
def inject_devise_invitable_content
|
9
9
|
path = File.join('app', 'models', "#{file_path}.rb")
|
10
|
-
inject_into_file(path, 'invitable, :', after: 'devise :') if File.
|
10
|
+
inject_into_file(path, 'invitable, :', after: 'devise :') if File.exist?(path)
|
11
11
|
end
|
12
12
|
|
13
13
|
hook_for :orm
|
@@ -41,4 +41,14 @@ class ControllerHelpersTest < ActionController::TestCase
|
|
41
41
|
assert Devise::InvitationsController.method_defined? :after_accept_path_for
|
42
42
|
assert !Devise::InvitationsController.instance_methods(false).include?(:after_accept_path_for)
|
43
43
|
end
|
44
|
+
|
45
|
+
test 'invalid token path defaults to after sign out path' do
|
46
|
+
assert_equal @controller.send(:after_sign_out_path_for, :user), @controller.invalid_token_path_for(:user)
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'invalid token path is customizable from application controller' do
|
50
|
+
custom_path = 'customized/invalid/token/path'
|
51
|
+
@controller.instance_eval "def invalid_token_path_for(resource_name) '#{custom_path}' end"
|
52
|
+
assert_equal @controller.invalid_token_path_for(:user), custom_path
|
53
|
+
end
|
44
54
|
end
|
@@ -98,7 +98,7 @@ class InvitationTest < ActionDispatch::IntegrationTest
|
|
98
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
|
101
|
+
assert page.has_css?('#error_explanation li', text: /Password .*doesn['’]t match/)
|
102
102
|
assert !user.confirmed?
|
103
103
|
end
|
104
104
|
|
@@ -102,7 +102,7 @@ class InvitationMailTest < ActionMailer::TestCase
|
|
102
102
|
def initialize(*args); end
|
103
103
|
def deliver; end
|
104
104
|
end
|
105
|
-
Devise.mailer = CustomMailer
|
105
|
+
Devise.mailer = 'InvitationMailTest::CustomMailer'
|
106
106
|
|
107
107
|
User.invite!({ email: 'valid@email.com' }, nil, { invited_at: Time.now })
|
108
108
|
end
|
data/test/model_tests_helper.rb
CHANGED
@@ -89,12 +89,12 @@ class InvitableTest < ActiveSupport::TestCase
|
|
89
89
|
user.invite!
|
90
90
|
old_invitation_created_at = 3.days.ago
|
91
91
|
old_invitation_sent_at = 3.days.ago
|
92
|
-
user.
|
92
|
+
user.update(invitation_sent_at: old_invitation_sent_at, invitation_created_at: old_invitation_created_at)
|
93
93
|
3.times do
|
94
94
|
user.invite!
|
95
95
|
refute_equal old_invitation_sent_at, user.invitation_sent_at
|
96
96
|
refute_equal old_invitation_created_at, user.invitation_created_at
|
97
|
-
user.
|
97
|
+
user.update(invitation_sent_at: old_invitation_sent_at, invitation_created_at: old_invitation_created_at)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -279,6 +279,23 @@ class InvitableTest < ActiveSupport::TestCase
|
|
279
279
|
refute_predicate user, :invited_to_sign_up?
|
280
280
|
end
|
281
281
|
|
282
|
+
test 'should not accept expired invitation while resetting the password' do
|
283
|
+
User.stubs(:invite_for).returns(1.day)
|
284
|
+
user = User.invite!(email: 'valid@email.com')
|
285
|
+
assert user.invited_to_sign_up?
|
286
|
+
user.invitation_created_at = Time.now.utc - 2.days
|
287
|
+
token, user.reset_password_token = Devise.token_generator.generate(User, :reset_password_token)
|
288
|
+
user.reset_password_sent_at = Time.now.utc
|
289
|
+
user.save
|
290
|
+
|
291
|
+
assert user.reset_password_token.present?
|
292
|
+
assert user.invitation_token.present?
|
293
|
+
User.reset_password_by_token(reset_password_token: token, password: '123456789', password_confirmation: '123456789')
|
294
|
+
assert_nil user.reload.reset_password_token
|
295
|
+
assert user.reload.invitation_token.present?
|
296
|
+
assert user.reload.invited_to_sign_up?
|
297
|
+
end
|
298
|
+
|
282
299
|
test 'should not accept invitation on failing to reset the password' do
|
283
300
|
user = User.invite!(email: 'valid@email.com')
|
284
301
|
assert user.invited_to_sign_up?
|
@@ -366,15 +383,51 @@ class InvitableTest < ActiveSupport::TestCase
|
|
366
383
|
User.validate_on_invite = validate_on_invite
|
367
384
|
end
|
368
385
|
|
386
|
+
test 'should not validate other attributes when validate_on_invite is disabled (for instance method)' do
|
387
|
+
validate_on_invite = User.validate_on_invite
|
388
|
+
User.validate_on_invite = false
|
389
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
390
|
+
user.invite!(nil, validate: false)
|
391
|
+
assert_empty user.errors
|
392
|
+
User.validate_on_invite = validate_on_invite
|
393
|
+
end
|
394
|
+
|
395
|
+
test 'should validate other attributes when validate_on_invite is disabled and validate option is enabled (for instance method)' do
|
396
|
+
validate_on_invite = User.validate_on_invite
|
397
|
+
User.validate_on_invite = false
|
398
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
399
|
+
user.invite!(nil, validate: true)
|
400
|
+
refute_empty user.errors[:username]
|
401
|
+
User.validate_on_invite = validate_on_invite
|
402
|
+
end
|
403
|
+
|
404
|
+
test 'should validate other attributes when validate_on_invite is enabled and validate option is disabled (for instance method)' do
|
405
|
+
validate_on_invite = User.validate_on_invite
|
406
|
+
User.validate_on_invite = true
|
407
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
408
|
+
user.invite!
|
409
|
+
refute_empty user.errors[:username]
|
410
|
+
User.validate_on_invite = validate_on_invite
|
411
|
+
end
|
412
|
+
|
413
|
+
test 'should validate other attributes when validate_on_invite is enabled and validate option is disabled explicitly (for instance method)' do
|
414
|
+
validate_on_invite = User.validate_on_invite
|
415
|
+
User.validate_on_invite = true
|
416
|
+
user = new_user(email: 'valid@email.com', username: 'a' * 50)
|
417
|
+
user.invite!(nil, validate: false)
|
418
|
+
assert_empty user.errors
|
419
|
+
User.validate_on_invite = validate_on_invite
|
420
|
+
end
|
421
|
+
|
369
422
|
test 'should return a record with errors if user was found by e-mail' do
|
370
423
|
existing_user = User.new(email: 'valid@email.com')
|
371
424
|
existing_user.save(validate: false)
|
372
425
|
user = User.invite!(email: 'valid@email.com')
|
373
426
|
assert_equal user, existing_user
|
374
|
-
assert_equal [
|
427
|
+
assert_equal [{error: :taken}], user.errors.details[:email]
|
375
428
|
same_user = User.invite!(email: 'valid@email.com')
|
376
429
|
assert_equal same_user, existing_user
|
377
|
-
assert_equal [
|
430
|
+
assert_equal [{error: :taken}], same_user.errors.details[:email]
|
378
431
|
end
|
379
432
|
|
380
433
|
test 'should return a record with errors if user with pending invitation was found by e-mail' do
|
@@ -388,7 +441,7 @@ class InvitableTest < ActiveSupport::TestCase
|
|
388
441
|
|
389
442
|
user = User.invite!(email: 'valid@email.com')
|
390
443
|
assert_equal user, existing_user
|
391
|
-
assert_equal [
|
444
|
+
assert_equal [{error: :taken}], user.errors.details[:email]
|
392
445
|
ensure
|
393
446
|
User.resend_invitation = resend_invitation
|
394
447
|
end
|
@@ -402,7 +455,7 @@ class InvitableTest < ActiveSupport::TestCase
|
|
402
455
|
existing_user.save(validate: false)
|
403
456
|
user = User.invite!(email: 'valid@email.com', username: 'a' * 50)
|
404
457
|
assert_equal user, existing_user
|
405
|
-
assert_equal [
|
458
|
+
assert_equal [{error: :taken}], user.errors.details[:email]
|
406
459
|
refute_empty user.errors[:username]
|
407
460
|
ensure
|
408
461
|
User.validate_on_invite = validate_on_invite
|
@@ -412,13 +465,13 @@ class InvitableTest < ActiveSupport::TestCase
|
|
412
465
|
test 'should return a new record with errors if e-mail is blank' do
|
413
466
|
invited_user = User.invite!(email: '')
|
414
467
|
assert invited_user.new_record?
|
415
|
-
assert_equal [
|
468
|
+
assert_equal [{error: :blank}], invited_user.errors.details[:email]
|
416
469
|
end
|
417
470
|
|
418
471
|
test 'should return a new record with errors if e-mail is invalid' do
|
419
472
|
invited_user = User.invite!(email: 'invalid_email')
|
420
473
|
assert invited_user.new_record?
|
421
|
-
assert_equal [
|
474
|
+
assert_equal [{error: :invalid}], invited_user.errors.details[:email]
|
422
475
|
end
|
423
476
|
|
424
477
|
test 'should set all attributes with errors if e-mail is invalid' do
|
@@ -438,13 +491,13 @@ class InvitableTest < ActiveSupport::TestCase
|
|
438
491
|
test 'should return a new record with errors if no invitation_token is found' do
|
439
492
|
invited_user = User.accept_invitation!(invitation_token: 'invalid_token')
|
440
493
|
assert invited_user.new_record?
|
441
|
-
assert_equal [
|
494
|
+
assert_equal [{error: :invalid}], invited_user.errors.details[:invitation_token]
|
442
495
|
end
|
443
496
|
|
444
497
|
test 'should return a new record with errors if invitation_token is blank' do
|
445
498
|
invited_user = User.accept_invitation!(invitation_token: '')
|
446
499
|
assert invited_user.new_record?
|
447
|
-
assert_equal [
|
500
|
+
assert_equal [{error: :blank}], invited_user.errors.details[:invitation_token]
|
448
501
|
end
|
449
502
|
|
450
503
|
test 'should return record with errors if invitation_token has expired' do
|
@@ -454,7 +507,7 @@ class InvitableTest < ActiveSupport::TestCase
|
|
454
507
|
invited_user.save(validate: false)
|
455
508
|
user = User.accept_invitation!(invitation_token: Thread.current[:token])
|
456
509
|
assert_equal user, invited_user
|
457
|
-
assert_equal [
|
510
|
+
assert_equal [{error: :invalid}], user.errors.details[:invitation_token]
|
458
511
|
end
|
459
512
|
|
460
513
|
test 'should allow record modification using block' do
|
data/test/orm/active_record.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
ActiveRecord::Migration.verbose = false
|
2
2
|
ActiveRecord::Base.logger = Logger.new(nil)
|
3
3
|
|
4
|
-
if
|
4
|
+
if ActiveRecord::VERSION::MAJOR >= 6
|
5
|
+
ActiveRecord::MigrationContext.new(
|
6
|
+
File.expand_path('../../rails_app/db/migrate/', __FILE__),
|
7
|
+
ActiveRecord::Base.connection.schema_migration
|
8
|
+
).migrate
|
9
|
+
elsif defined? ActiveRecord::MigrationContext # rails >= 5.2
|
5
10
|
ActiveRecord::MigrationContext.new(File.expand_path('../../rails_app/db/migrate/', __FILE__)).migrate
|
6
11
|
else
|
7
12
|
ActiveRecord::Migrator.migrate(File.expand_path('../../rails_app/db/migrate/', __FILE__))
|
data/test/test_helper.rb
CHANGED
@@ -7,7 +7,7 @@ require "rails_app/config/environment"
|
|
7
7
|
require 'rails/test_help'
|
8
8
|
require "orm/#{DEVISE_ORM}"
|
9
9
|
require 'capybara/rails'
|
10
|
-
require 'mocha/
|
10
|
+
require 'mocha/minitest'
|
11
11
|
|
12
12
|
ActionMailer::Base.delivery_method = :test
|
13
13
|
ActionMailer::Base.perform_deliveries = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_invitable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- app/views/devise/mailer/invitation_instructions.html.erb
|
71
71
|
- app/views/devise/mailer/invitation_instructions.text.erb
|
72
72
|
- config/locales/ar.yml
|
73
|
+
- config/locales/ca.yml
|
73
74
|
- config/locales/da.yml
|
74
75
|
- config/locales/de.yml
|
75
76
|
- config/locales/en.yml
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- config/locales/et.yml
|
78
79
|
- config/locales/fa.yml
|
79
80
|
- config/locales/fr.yml
|
81
|
+
- config/locales/id.yml
|
80
82
|
- config/locales/it.yml
|
81
83
|
- config/locales/ja.yml
|
82
84
|
- config/locales/ko.yml
|
@@ -186,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
188
|
- !ruby/object:Gem::Version
|
187
189
|
version: '0'
|
188
190
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.3.7
|
190
192
|
signing_key:
|
191
193
|
specification_version: 4
|
192
194
|
summary: An invitation strategy for Devise
|