devise_invitable 1.3.2 → 1.3.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.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b829731496401b7e957dc0da6fb5c314104be6b1
4
+ data.tar.gz: 39abb9f0a58cc51c5a6f45e50189f4f2275d0743
5
+ SHA512:
6
+ metadata.gz: ce39f924778f62589d7eb7ad004074fe2d32cf7c5ac3efd5d0b1a9e8d39e36921dc79954932787e461b9dad121d9528520df869b34433f1f772cd1864f3250a3
7
+ data.tar.gz: 5c4f8c5eddc26ea113001257d6b4c33c4283807404a4d7aeb82cab7ed57cf21754b464debd404c549c41d84f299edaed7dad6aaf7ddcf6346b57d698a577f1e0
@@ -32,7 +32,7 @@ class Devise::InvitationsController < DeviseController
32
32
 
33
33
  # PUT /resource/invitation
34
34
  def update
35
- self.resource = resource_class.accept_invitation!(update_resource_params)
35
+ self.resource = accept_resource
36
36
 
37
37
  if resource.errors.empty?
38
38
  flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
@@ -56,6 +56,10 @@ class Devise::InvitationsController < DeviseController
56
56
  def invite_resource
57
57
  resource_class.invite!(invite_params, current_inviter)
58
58
  end
59
+
60
+ def accept_resource
61
+ resource_class.accept_invitation!(update_resource_params)
62
+ end
59
63
 
60
64
  def current_inviter
61
65
  @current_inviter ||= authenticate_inviter!
@@ -29,11 +29,15 @@ module Devise
29
29
 
30
30
  included do
31
31
  include ::DeviseInvitable::Inviter
32
- if Devise.invited_by_class_name
33
- belongs_to :invited_by, :class_name => Devise.invited_by_class_name
32
+ belongs_to_options = if Devise.invited_by_class_name
33
+ {:class_name => Devise.invited_by_class_name}
34
34
  else
35
- belongs_to :invited_by, :polymorphic => true
35
+ {:polymorphic => true}
36
+ end
37
+ if defined?(ActiveRecord) && self < ActiveRecord::Base
38
+ belongs_to_options.merge! :counter_cache => :invitations_count
36
39
  end
40
+ belongs_to :invited_by, belongs_to_options
37
41
 
38
42
  include ActiveSupport::Callbacks
39
43
  define_callbacks :invitation_accepted
@@ -81,12 +85,6 @@ module Devise
81
85
  end
82
86
  end
83
87
 
84
- # Verifies whether a user has accepted an invitation (or is accepting it), or was never invited
85
- def accepting_or_not_invited?
86
- ActiveSupport::Deprecation.warn "accepting_or_not_invited? is deprecated and will be removed from DeviseInvitable 1.1.0 (use accepted_or_not_invited? instead)"
87
- accepted_or_not_invited?
88
- end
89
-
90
88
  # Verifies whether a user has been invited or not
91
89
  def invited_to_sign_up?
92
90
  persisted? && invitation_token.present?
@@ -279,9 +277,6 @@ module Devise
279
277
  invitation_token = Devise.token_generator.digest(self, :invitation_token, original_token)
280
278
 
281
279
  invitable = find_or_initialize_with_error_by(:invitation_token, invitation_token)
282
- if !invitable.persisted? && Devise.allow_insecure_token_lookup
283
- invitable = find_or_initialize_with_error_by(:invitation_token, original_token)
284
- end
285
280
  invitable.errors.add(:invitation_token, :invalid) if invitable.invitation_token && invitable.persisted? && !invitable.valid_invitation?
286
281
  invitable.invitation_token = original_token
287
282
  invitable unless only_valid && invitable.errors.present?
@@ -1,3 +1,3 @@
1
1
  module DeviseInvitable
2
- VERSION = '1.3.2'
2
+ VERSION = '1.3.3'
3
3
  end
@@ -7,6 +7,8 @@ class DeviseInvitableAddTo<%= table_name.camelize %> < ActiveRecord::Migration
7
7
  t.datetime :invitation_accepted_at
8
8
  t.integer :invitation_limit
9
9
  t.references :invited_by, :polymorphic => true
10
+ t.integer :invitations_count, default: 0
11
+ t.index :invitations_count
10
12
  t.index :invitation_token, :unique => true # for invitable
11
13
  t.index :invited_by_id
12
14
  end
@@ -11,6 +11,16 @@ class InvitableTest < ActiveSupport::TestCase
11
11
  assert_nil new_user.invitation_token
12
12
  end
13
13
 
14
+ test 'should update the invitations count counter cache' do
15
+ if defined?(ActiveRecord)
16
+ current_user = new_user
17
+ 2.times do |index|
18
+ User.invite!({:email => "valid#{index}@email.com"}, current_user)
19
+ end
20
+ assert_equal current_user.reload.invitations_count, 2
21
+ end
22
+ end
23
+
14
24
  test 'should not generate the raw invitation token after creating a record' do
15
25
  assert_nil new_user.raw_invitation_token
16
26
  end
@@ -27,15 +27,20 @@ class CreateTables < ActiveRecord::Migration
27
27
  t.integer :invitation_limit
28
28
  t.integer :invited_by_id
29
29
  t.string :invited_by_type
30
+ t.integer :invitations_count, :default => 0
30
31
 
31
32
  t.timestamps
32
33
  end
33
34
  add_index :users, :invitation_token, :unique => true
35
+ add_index :users, :invitations_count
34
36
 
35
37
  create_table :admins do |t|
36
38
  ## Database authenticatable
37
39
  t.string :email, :null => true, :default => ""
38
40
  t.string :encrypted_password, :null => true, :default => ""
41
+
42
+ t.integer :invitations_count, :default => 0
39
43
  end
44
+ add_index :admins, :invitations_count
40
45
  end
41
46
  end
metadata CHANGED
@@ -1,38 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_invitable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
5
- prerelease:
4
+ version: 1.3.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sergio Cambra
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-04 00:00:00.000000000 Z
11
+ date: 2014-01-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.1.0
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.1.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: actionmailer
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.2.6
38
34
  - - <
@@ -41,9 +37,8 @@ dependencies:
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
- - - ! '>='
41
+ - - '>='
47
42
  - !ruby/object:Gem::Version
48
43
  version: 3.2.6
49
44
  - - <
@@ -52,19 +47,17 @@ dependencies:
52
47
  - !ruby/object:Gem::Dependency
53
48
  name: devise
54
49
  requirement: !ruby/object:Gem::Requirement
55
- none: false
56
50
  requirements:
57
- - - ! '>='
51
+ - - '>='
58
52
  - !ruby/object:Gem::Version
59
- version: 3.1.0
53
+ version: 3.2.0
60
54
  type: :runtime
61
55
  prerelease: false
62
56
  version_requirements: !ruby/object:Gem::Requirement
63
- none: false
64
57
  requirements:
65
- - - ! '>='
58
+ - - '>='
66
59
  - !ruby/object:Gem::Version
67
- version: 3.1.0
60
+ version: 3.2.0
68
61
  description: It adds support for send invitations by email (it requires to be authenticated)
69
62
  and accept the invitation by setting a password.
70
63
  email:
@@ -154,6 +147,7 @@ files:
154
147
  homepage: https://github.com/scambra/devise_invitable
155
148
  licenses:
156
149
  - MIT
150
+ metadata: {}
157
151
  post_install_message:
158
152
  rdoc_options:
159
153
  - --main
@@ -162,22 +156,20 @@ rdoc_options:
162
156
  require_paths:
163
157
  - lib
164
158
  required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
159
  requirements:
167
- - - ! '>='
160
+ - - '>='
168
161
  - !ruby/object:Gem::Version
169
162
  version: 1.8.6
170
163
  required_rubygems_version: !ruby/object:Gem::Requirement
171
- none: false
172
164
  requirements:
173
- - - ! '>='
165
+ - - '>='
174
166
  - !ruby/object:Gem::Version
175
167
  version: 1.3.6
176
168
  requirements: []
177
169
  rubyforge_project:
178
- rubygems_version: 1.8.23
170
+ rubygems_version: 2.1.11
179
171
  signing_key:
180
- specification_version: 3
172
+ specification_version: 4
181
173
  summary: An invitation strategy for Devise
182
174
  test_files:
183
175
  - test/functional/controller_helpers_test.rb