devise_invitable 1.7.0 → 1.7.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/README.rdoc +9 -15
- data/app/controllers/devise/invitations_controller.rb +1 -1
- data/lib/devise_invitable/model.rb +8 -4
- data/lib/devise_invitable/version.rb +1 -1
- data/test/models/invitable_test.rb +9 -4
- data/test/rails_app/config/environments/test.rb +1 -1
- data/test/test_helper.rb +9 -7
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b83b5f1ceec909cc73063d89575fce5bcf50c473
|
4
|
+
data.tar.gz: f495b7eeebe7e5c70d3181747b25ea802a8f656f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d27498b5bf7c89b29d8cb15b34df681a3aa3fdbb639ee6b73cbb93eaf61eccc5ff255b6016447d57b8b1ee54bd2fa6bd54d23c79f107d4dff21fe70b3489bcb8
|
7
|
+
data.tar.gz: cc70998322befe8502e6787d863e9ce0569d3c718eac7c6f7c31dcf17a0f1ad665eaf83f46ffb64719c961b20e8cfe968624d953387b04a0ed062bea42dc602d
|
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -70,13 +70,13 @@ or for a model that already exists, define a migration to add DeviseInvitable to
|
|
70
70
|
add_column :users, :invited_by_id, :integer
|
71
71
|
add_column :users, :invited_by_type, :string
|
72
72
|
add_index :users, :invitation_token, :unique => true
|
73
|
+
|
74
|
+
# Allow null encrypted_password
|
75
|
+
change_column_null :users, :encrypted_password, :string, true
|
76
|
+
# Allow null password_salt (add it if you are using Devise's encryptable module)
|
77
|
+
change_column_null :users, :password_salt, :string, true
|
73
78
|
end
|
74
79
|
|
75
|
-
# Allow null encrypted_password
|
76
|
-
change_column :users, :encrypted_password, :string, :null => true
|
77
|
-
# Allow null password_salt (add it if you are using Devise's encryptable module)
|
78
|
-
change_column :users, :password_salt, :string, :null => true
|
79
|
-
|
80
80
|
If you previously used devise_invitable with a :limit on :invitation_token, remove it:
|
81
81
|
|
82
82
|
def up
|
@@ -216,18 +216,12 @@ There are just two actions in DeviseInvitable that allows any set of parameters
|
|
216
216
|
|
217
217
|
Here is an example of what your application controller might need to include in order to add these parameters to the invitation view:
|
218
218
|
|
219
|
-
|
219
|
+
before_action :configure_permitted_parameters, if: :devise_controller?
|
220
220
|
|
221
221
|
protected
|
222
222
|
|
223
223
|
def configure_permitted_parameters
|
224
|
-
|
225
|
-
devise_parameter_sanitizer.for(:accept_invitation).concat [:first_name, :last_name, :phone]
|
226
|
-
# Override accepted parameters
|
227
|
-
devise_parameter_sanitizer.for(:accept_invitation) do |u|
|
228
|
-
u.permit(:first_name, :last_name, :phone, :password, :password_confirmation,
|
229
|
-
:invitation_token)
|
230
|
-
end
|
224
|
+
devise_parameter_sanitizer.permit(:accept_invitation, keys: [:first_name, :last_name, :phone])
|
231
225
|
end
|
232
226
|
|
233
227
|
|
@@ -415,9 +409,9 @@ https://github.com/scambra/devise_invitable/wiki
|
|
415
409
|
|
416
410
|
== Testing
|
417
411
|
|
418
|
-
To test DeviseInvitable for the ActiveRecord ORM with RVM, Ruby 2.
|
412
|
+
To test DeviseInvitable for the ActiveRecord ORM with RVM, Ruby 2.2.2:
|
419
413
|
|
420
|
-
rvm use 2.
|
414
|
+
rvm use 2.2.2
|
421
415
|
rvm gemset create devise_invitable
|
422
416
|
rvm gemset use devise_invitable
|
423
417
|
gem install bundler
|
@@ -44,7 +44,7 @@ class Devise::InvitationsController < DeviseController
|
|
44
44
|
|
45
45
|
# GET /resource/invitation/accept?invitation_token=abcdef
|
46
46
|
def edit
|
47
|
-
set_minimum_password_length
|
47
|
+
set_minimum_password_length
|
48
48
|
resource.invitation_token = params[:invitation_token]
|
49
49
|
render :edit
|
50
50
|
end
|
@@ -52,11 +52,11 @@ module Devise
|
|
52
52
|
|
53
53
|
scope :no_active_invitation, lambda { where(:invitation_token => nil) }
|
54
54
|
if defined?(Mongoid) && defined?(Mongoid::Document) && self < Mongoid::Document
|
55
|
-
scope :created_by_invite, lambda { where(:
|
55
|
+
scope :created_by_invite, lambda { where(:invitation_created_at.ne => nil) }
|
56
56
|
scope :invitation_not_accepted, lambda { where(:invitation_accepted_at => nil, :invitation_token.ne => nil) }
|
57
57
|
scope :invitation_accepted, lambda { where(:invitation_accepted_at.ne => nil) }
|
58
58
|
else
|
59
|
-
scope :created_by_invite, lambda { where(arel_table[:
|
59
|
+
scope :created_by_invite, lambda { where(arel_table[:invitation_created_at].not_eq(nil)) }
|
60
60
|
scope :invitation_not_accepted, lambda { where(arel_table[:invitation_token].not_eq(nil)).where(:invitation_accepted_at => nil) }
|
61
61
|
scope :invitation_accepted, lambda { where(arel_table[:invitation_accepted_at].not_eq(nil)) }
|
62
62
|
|
@@ -102,7 +102,7 @@ module Devise
|
|
102
102
|
|
103
103
|
# Verify wheather a user is created by invitation, irrespective to invitation status
|
104
104
|
def created_by_invite?
|
105
|
-
|
105
|
+
invitation_created_at.present?
|
106
106
|
end
|
107
107
|
|
108
108
|
# Verifies whether a user has been invited or not
|
@@ -306,7 +306,8 @@ module Devise
|
|
306
306
|
end
|
307
307
|
|
308
308
|
def invite!(attributes={}, invited_by=nil, options = {}, &block)
|
309
|
-
|
309
|
+
attr_hash = ActiveSupport::HashWithIndifferentAccess.new(attributes.to_h)
|
310
|
+
_invite(attr_hash, invited_by, options, &block).first
|
310
311
|
end
|
311
312
|
|
312
313
|
def invite_mail!(attributes={}, invited_by=nil, options = {}, &block)
|
@@ -359,6 +360,9 @@ module Devise
|
|
359
360
|
Devise::Models.config(self, :invitation_limit)
|
360
361
|
Devise::Models.config(self, :invite_key)
|
361
362
|
Devise::Models.config(self, :resend_invitation)
|
363
|
+
Devise::Models.config(self, :invited_by_class_name)
|
364
|
+
Devise::Models.config(self, :invited_by_foreign_key)
|
365
|
+
Devise::Models.config(self, :invited_by_counter_cache)
|
362
366
|
Devise::Models.config(self, :allow_insecure_sign_in_after_accept)
|
363
367
|
Devise::Models.config(self, :require_password_on_accepting)
|
364
368
|
|
@@ -136,14 +136,14 @@ class InvitableTest < ActiveSupport::TestCase
|
|
136
136
|
User.stubs(:invite_for).returns(nil)
|
137
137
|
user = User.invite!(:email => "valid@email.com")
|
138
138
|
|
139
|
-
|
139
|
+
assert_nil user.invitation_due_at
|
140
140
|
end
|
141
141
|
|
142
142
|
test 'should return nil for invitation due date when invite_for is 0' do
|
143
143
|
User.stubs(:invite_for).returns(0)
|
144
144
|
user = User.invite!(email: 'valid@email.com')
|
145
145
|
|
146
|
-
|
146
|
+
assert_nil user.invitation_due_at
|
147
147
|
end
|
148
148
|
|
149
149
|
test 'should never generate the same invitation token for different users' do
|
@@ -575,7 +575,7 @@ class InvitableTest < ActiveSupport::TestCase
|
|
575
575
|
test 'user.invite! should not set the invited_by attribute if not passed' do
|
576
576
|
user = new_user
|
577
577
|
user.invite!
|
578
|
-
|
578
|
+
assert_nil user.invited_by
|
579
579
|
end
|
580
580
|
|
581
581
|
test 'user.invite! should set the invited_by attribute if passed' do
|
@@ -628,7 +628,12 @@ class InvitableTest < ActiveSupport::TestCase
|
|
628
628
|
end
|
629
629
|
|
630
630
|
def assert_callbacks_status(callback, user, fired)
|
631
|
-
|
631
|
+
result = user.send("#{callback}_callback_works".to_sym)
|
632
|
+
if fired.nil?
|
633
|
+
assert_nil result
|
634
|
+
else
|
635
|
+
assert_equal fired, result
|
636
|
+
end
|
632
637
|
end
|
633
638
|
|
634
639
|
test "user.invite! should downcase the class's case_insensitive_keys" do
|
@@ -28,7 +28,7 @@ RailsApp::Application.configure do
|
|
28
28
|
# like if you have constraints or database-specific column types
|
29
29
|
# config.active_record.schema_format = :sql
|
30
30
|
|
31
|
-
if Rails.version
|
31
|
+
if Rails.version =~ /^4\.2/ && config.respond_to?(:active_record)
|
32
32
|
config.active_record.raise_in_transactional_callbacks = true
|
33
33
|
end
|
34
34
|
|
data/test/test_helper.rb
CHANGED
@@ -25,13 +25,15 @@ class ActionController::TestCase
|
|
25
25
|
else
|
26
26
|
include Devise::TestHelpers
|
27
27
|
end
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
if defined? ActiveRecord
|
29
|
+
if Rails.version >= '5.0.0'
|
30
|
+
self.use_transactional_tests = true
|
31
|
+
else
|
32
|
+
begin
|
33
|
+
require 'test_after_commit'
|
34
|
+
self.use_transactional_fixtures = true
|
35
|
+
rescue LoadError
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
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: 1.7.
|
4
|
+
version: 1.7.1
|
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: 2017-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
33
|
+
version: 4.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.
|
40
|
+
version: 4.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: devise
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
155
|
requirements:
|
156
156
|
- - ">="
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: 1.
|
158
|
+
version: 2.1.0
|
159
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
161
|
- - ">="
|