devise_invitable 1.3.1 → 1.3.2

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.

@@ -63,7 +63,7 @@ or for a model that already exists, define a migration to add DeviseInvitable to
63
63
  def change
64
64
  add_column :users, :invitation_token, :string
65
65
  add_column :users, :invitation_created_at, :datetime
66
- add_column :users, :invitation_sent_at, :datetime
66
+ add_column :users, :invitation_sent_at, :datetime
67
67
  add_column :users, :invitation_accepted_at, :datetime
68
68
  add_column :users, :invitation_limit, :integer
69
69
  add_column :users, :invited_by_id, :integer
@@ -81,7 +81,7 @@ If you previously used devise_invitable with a :limit on :invitation_token, remo
81
81
  def up
82
82
  change_column :users, :invitation_token, :string, :limit => nil
83
83
  end
84
-
84
+
85
85
  def down
86
86
  change_column :users, :invitation_token, :string, :limit => 60
87
87
  end
@@ -196,8 +196,8 @@ Here is an example of what your application controller might need to include in
196
196
  :invitation_token)
197
197
  end
198
198
  end
199
-
200
-
199
+
200
+
201
201
  == Usage
202
202
 
203
203
  === Send an invitation
@@ -214,7 +214,7 @@ If you want to create the invitation but not send it, you can set <tt>skip_invit
214
214
  end
215
215
  # => the record will be created, but the invitation email will not be sent
216
216
 
217
- When skip_invitation is used, you must also then set the invitation_sent_at field when the user is sent their
217
+ When skip_invitation is used, you must also then set the invitation_sent_at field when the user is sent their
218
218
  token. Failure to do so will yield "Invalid invitation token" errors when the user attempts to accept the invite.
219
219
  You can set it like so:
220
220
 
@@ -374,4 +374,4 @@ Special thanks to rymai[http://github.com/rymai] for the Rails 3 support, his fo
374
374
 
375
375
  == Copyright
376
376
 
377
- Copyright (c) 2012 Sergio Cambra. See LICENSE for details.
377
+ Copyright (c) 2014 Sergio Cambra. See LICENSE for details.
@@ -7,6 +7,7 @@ class DeviseInvitable::RegistrationsController < Devise::RegistrationsController
7
7
  self.resource = resource_class.where(:email => hash[:email], :encrypted_password => '').first
8
8
  if self.resource
9
9
  self.resource.attributes = hash
10
+ self.resource.send_confirmation_instructions if self.resource.confirmation_required_for_invited?
10
11
  self.resource.accept_invitation
11
12
  end
12
13
  end
@@ -4,7 +4,6 @@ module DeviseInvitable
4
4
  autoload :Mapping, 'devise_invitable/mapping'
5
5
  autoload :ParameterSanitizer, 'devise_invitable/parameter_sanitizer'
6
6
  module Controllers
7
- autoload :UrlHelpers, 'devise_invitable/controllers/url_helpers'
8
7
  autoload :Registrations, 'devise_invitable/controllers/registrations'
9
8
  autoload :Helpers, 'devise_invitable/controllers/helpers'
10
9
  end
@@ -64,4 +63,4 @@ module Devise
64
63
  @@invited_by_class_name = nil
65
64
  end
66
65
 
67
- Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/model', :route => :invitation
66
+ Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/model', :route => {:invitation => [nil, :new, :accept]}
@@ -37,8 +37,6 @@ module Devise
37
37
 
38
38
  include ActiveSupport::Callbacks
39
39
  define_callbacks :invitation_accepted
40
- before_update :generate_confirmation_token, :if => :confirmation_required_for_invited?
41
- after_update :send_on_create_confirmation_instructions, :if => :confirmation_required_for_invited?
42
40
 
43
41
  attr_writer :skip_password
44
42
 
@@ -164,16 +162,17 @@ module Devise
164
162
  self.invitation_token
165
163
  end
166
164
 
165
+ def confirmation_required_for_invited?
166
+ respond_to?(:confirmation_required?, true) && confirmation_required?
167
+ end
168
+
167
169
  protected
168
170
  # Overriding the method in Devise's :validatable module so password is not required on inviting
169
171
  def password_required?
170
172
  !@skip_password && super
171
173
  end
172
174
 
173
- def confirmation_required_for_invited?
174
- respond_to?(:confirmation_required?, true) && confirmation_required? && invitation_accepted?
175
- end
176
-
175
+
177
176
  # Checks if the invitation for the user is within the limit time.
178
177
  # We do this by calculating if the difference between today and the
179
178
  # invitation sent date does not exceed the invite for time configured.
@@ -1,11 +1,11 @@
1
1
  module DeviseInvitable
2
2
  module ParameterSanitizer
3
3
  def invite
4
- default_params.permit self.for(:invite)
4
+ permit self.for(:invite)
5
5
  end
6
6
 
7
7
  def accept_invitation
8
- default_params.permit self.for(:accept_invitation)
8
+ permit self.for(:accept_invitation)
9
9
  end
10
10
 
11
11
  def self.included(base)
@@ -13,6 +13,10 @@ module DeviseInvitable
13
13
  end
14
14
 
15
15
  private
16
+ def permit(keys)
17
+ default_params.permit(*Array(keys))
18
+ end
19
+
16
20
  def attributes_for_with_invitable(kind)
17
21
  case kind
18
22
  when :invite
@@ -2,10 +2,8 @@ module DeviseInvitable
2
2
  class Engine < ::Rails::Engine
3
3
 
4
4
  ActiveSupport.on_load(:action_controller) do
5
- include DeviseInvitable::Controllers::UrlHelpers
6
5
  include DeviseInvitable::Controllers::Helpers
7
6
  end
8
- ActiveSupport.on_load(:action_view) { include DeviseInvitable::Controllers::UrlHelpers }
9
7
 
10
8
  # We use to_prepare instead of after_initialize here because Devise is a Rails engine; its
11
9
  # mailer is reloaded like the rest of the user's app. Got to make sure that our mailer methods
@@ -1,3 +1,3 @@
1
1
  module DeviseInvitable
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
@@ -33,6 +33,15 @@ class DeviseInvitable::RegistrationsControllerTest < ActionController::TestCase
33
33
  end
34
34
 
35
35
  @invitee = User.where(:email => invitee_email).first
36
+
37
+ # do not send emails on model changes
38
+ assert_difference('ActionMailer::Base.deliveries.size', 0) do
39
+ @invitee.bio = "I am a robot"
40
+ @invitee.save!
41
+ @invitee.bio = "I am a human"
42
+ @invitee.save!
43
+ end
44
+
36
45
  assert_present @invitee.encrypted_password
37
46
  assert_not_nil @invitee.invitation_accepted_at
38
47
  assert_nil @invitee.invitation_token
metadata CHANGED
@@ -1,59 +1,78 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: devise_invitable
3
- version: !ruby/object:Gem::Version
4
- version: 1.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.2
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Sergio Cambra
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2013-11-05 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+ date: 2014-01-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
21
  version: 1.1.0
22
22
  type: :development
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
25
- name: actionmailer
26
23
  prerelease: false
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: actionmailer
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
31
37
  version: 3.2.6
32
38
  - - <
33
- - !ruby/object:Gem::Version
34
- version: "5"
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
35
41
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: devise
39
42
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: 3.2.6
49
+ - - <
50
+ - !ruby/object:Gem::Version
51
+ version: '5'
52
+ - !ruby/object:Gem::Dependency
53
+ name: devise
54
+ requirement: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
44
59
  version: 3.1.0
45
60
  type: :runtime
46
- version_requirements: *id003
47
- description: It adds support for send invitations by email (it requires to be authenticated) and accept the invitation by setting a password.
48
- email:
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: 3.1.0
68
+ description: It adds support for send invitations by email (it requires to be authenticated)
69
+ and accept the invitation by setting a password.
70
+ email:
49
71
  - sergio@entrecables.com
50
72
  executables: []
51
-
52
73
  extensions: []
53
-
54
74
  extra_rdoc_files: []
55
-
56
- files:
75
+ files:
57
76
  - app/controllers/devise/invitations_controller.rb
58
77
  - app/controllers/devise_invitable/registrations_controller.rb
59
78
  - app/views/devise/invitations/edit.html.erb
@@ -62,7 +81,6 @@ files:
62
81
  - config/locales/en.yml
63
82
  - lib/devise_invitable.rb
64
83
  - lib/devise_invitable/controllers/helpers.rb
65
- - lib/devise_invitable/controllers/url_helpers.rb
66
84
  - lib/devise_invitable/inviter.rb
67
85
  - lib/devise_invitable/mailer.rb
68
86
  - lib/devise_invitable/mapping.rb
@@ -134,35 +152,34 @@ files:
134
152
  - test/routes_test.rb
135
153
  - test/test_helper.rb
136
154
  homepage: https://github.com/scambra/devise_invitable
137
- licenses:
155
+ licenses:
138
156
  - MIT
139
- metadata: {}
140
-
141
157
  post_install_message:
142
- rdoc_options:
158
+ rdoc_options:
143
159
  - --main
144
160
  - README.rdoc
145
161
  - --charset=UTF-8
146
- require_paths:
162
+ require_paths:
147
163
  - lib
148
- required_ruby_version: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
152
169
  version: 1.8.6
153
- required_rubygems_version: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
157
175
  version: 1.3.6
158
176
  requirements: []
159
-
160
177
  rubyforge_project:
161
- rubygems_version: 2.0.7
178
+ rubygems_version: 1.8.23
162
179
  signing_key:
163
- specification_version: 4
180
+ specification_version: 3
164
181
  summary: An invitation strategy for Devise
165
- test_files:
182
+ test_files:
166
183
  - test/functional/controller_helpers_test.rb
167
184
  - test/functional/registrations_controller_test.rb
168
185
  - test/generators/views_generator_test.rb
@@ -214,4 +231,3 @@ test_files:
214
231
  - test/rails_app/script/rails
215
232
  - test/routes_test.rb
216
233
  - test/test_helper.rb
217
- has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA512:
3
- metadata.gz: f63e9220602bf9934658384637404fdf89b2dfcd4f7b2b7ed77c31cddfbab70e6ca7fa89a2fa2dccf489db7b2e80ff6634cfadf320ee366769b42000da4e9ac5
4
- data.tar.gz: d54dfb69ad95bf58f8a69c5c358ba64e9cfdf569536682f6e8614cc2f10550984657cb74353ab64a9fd59e1fed16991b9e8e4e5d120ec3583ad01f36b961bd1c
5
- SHA1:
6
- metadata.gz: 861482f2cb8845f6335441e94c3da04912511e1b
7
- data.tar.gz: 54799f3b072ffc7dcd3080d5f394fa2c62e64990
@@ -1,24 +0,0 @@
1
- module DeviseInvitable
2
- module Controllers
3
- module UrlHelpers
4
- [:path, :url].each do |path_or_url|
5
- [nil, :new_, :accept_].each do |action|
6
- class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
7
- def #{action}invitation_#{path_or_url}(resource, *args)
8
- resource = case resource
9
- when Symbol, String
10
- resource
11
- when Class
12
- resource.name.underscore
13
- else
14
- resource.class.name.underscore
15
- end
16
-
17
- send("#{action}\#{resource}_invitation_#{path_or_url}", *args)
18
- end
19
- URL_HELPERS
20
- end
21
- end
22
- end
23
- end
24
- end