devise_invitable 1.7.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.rdoc +75 -82
  4. data/app/controllers/devise/invitations_controller.rb +10 -10
  5. data/app/controllers/devise_invitable/registrations_controller.rb +1 -1
  6. data/app/views/devise/invitations/edit.html.erb +14 -8
  7. data/app/views/devise/invitations/new.html.erb +11 -7
  8. data/lib/devise_invitable.rb +3 -3
  9. data/lib/devise_invitable/controllers/helpers.rb +1 -1
  10. data/lib/devise_invitable/mailer.rb +1 -1
  11. data/lib/devise_invitable/mapping.rb +1 -1
  12. data/lib/devise_invitable/models.rb +17 -17
  13. data/lib/devise_invitable/routes.rb +4 -4
  14. data/lib/devise_invitable/version.rb +1 -1
  15. data/lib/generators/active_record/devise_invitable_generator.rb +3 -3
  16. data/lib/generators/devise_invitable/devise_invitable_generator.rb +4 -8
  17. data/lib/generators/devise_invitable/install_generator.rb +7 -11
  18. data/lib/generators/devise_invitable/templates/simple_form_for/invitations/edit.html.erb +10 -6
  19. data/lib/generators/devise_invitable/templates/simple_form_for/invitations/new.html.erb +10 -6
  20. data/lib/generators/devise_invitable/views_generator.rb +6 -6
  21. data/test/functional/registrations_controller_test.rb +24 -25
  22. data/test/integration/invitation_remove_test.rb +8 -8
  23. data/test/integration/invitation_test.rb +46 -46
  24. data/test/integration_tests_helper.rb +8 -8
  25. data/test/model_tests_helper.rb +5 -5
  26. data/test/models/invitable_test.rb +110 -110
  27. data/test/models_test.rb +3 -3
  28. data/test/orm/active_record.rb +2 -2
  29. data/test/orm/mongoid.rb +2 -2
  30. data/test/rails_app/app/controllers/admins_controller.rb +1 -1
  31. data/test/rails_app/app/controllers/application_controller.rb +1 -1
  32. data/test/rails_app/app/controllers/users_controller.rb +2 -2
  33. data/test/rails_app/app/models/admin.rb +7 -10
  34. data/test/rails_app/app/models/octopussy.rb +4 -4
  35. data/test/rails_app/app/models/user.rb +20 -20
  36. data/test/rails_app/app/views/admins/new.html.erb +9 -5
  37. data/test/rails_app/app/views/devise/sessions/new.html.erb +14 -6
  38. data/test/rails_app/app/views/free_invitations/new.html.erb +9 -5
  39. data/test/rails_app/app/views/layouts/application.html.erb +3 -4
  40. data/test/rails_app/app/views/users/invitations/new.html.erb +15 -9
  41. data/test/rails_app/config/application.rb +6 -6
  42. data/test/rails_app/config/boot.rb +2 -2
  43. data/test/rails_app/config/credentials.yml.enc +1 -0
  44. data/test/rails_app/config/initializers/session_store.rb +1 -1
  45. data/test/rails_app/config/initializers/wrap_parameters.rb +1 -1
  46. data/test/rails_app/config/master.key +1 -0
  47. data/test/rails_app/config/routes.rb +3 -3
  48. data/test/routes_test.rb +4 -4
  49. data/test/test_helper.rb +2 -2
  50. metadata +22 -20
  51. data/test/rails_app/config/initializers/secret_token.rb +0 -7
@@ -3,7 +3,7 @@ class DeviseInvitable::RegistrationsController < Devise::RegistrationsController
3
3
 
4
4
  def build_resource(hash = {})
5
5
  if hash[:email]
6
- self.resource = resource_class.where(:email => hash[:email]).first
6
+ self.resource = resource_class.where(email: hash[:email]).first
7
7
  if self.resource && self.resource.respond_to?(:invited_to_sign_up?) && self.resource.invited_to_sign_up?
8
8
  self.resource.attributes = hash
9
9
  self.resource.send_confirmation_instructions if self.resource.confirmation_required_for_invited?
@@ -1,16 +1,22 @@
1
- <h2><%= t 'devise.invitations.edit.header' %></h2>
1
+ <h2><%= t "devise.invitations.edit.header" %></h2>
2
2
 
3
- <%= form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => { :method => :put } do |f| %>
4
- <%= devise_error_messages! %>
3
+ <%= form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put }) do |f| %>
4
+ <%= render "devise/shared/error_messages", resource: resource %>
5
5
  <%= f.hidden_field :invitation_token, readonly: true %>
6
6
 
7
7
  <% if f.object.class.require_password_on_accepting %>
8
- <p><%= f.label :password %><br />
9
- <%= f.password_field :password %></p>
8
+ <div class="field">
9
+ <%= f.label :password %><br />
10
+ <%= f.password_field :password %></p>
11
+ </div>
10
12
 
11
- <p><%= f.label :password_confirmation %><br />
12
- <%= f.password_field :password_confirmation %></p>
13
+ <div class="field">
14
+ <%= f.label :password_confirmation %><br />
15
+ <%= f.password_field :password_confirmation %>
16
+ </div>
13
17
  <% end %>
14
18
 
15
- <p><%= f.submit t("devise.invitations.edit.submit_button") %></p>
19
+ <div class="actions">
20
+ <%= f.submit t("devise.invitations.edit.submit_button") %>
21
+ </div>
16
22
  <% end %>
@@ -1,12 +1,16 @@
1
1
  <h2><%= t "devise.invitations.new.header" %></h2>
2
2
 
3
- <%= form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :post} do |f| %>
4
- <%= devise_error_messages! %>
3
+ <%= form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= render "devise/shared/error_messages", resource: resource %>
5
5
 
6
- <% resource.class.invite_key_fields.each do |field| -%>
7
- <p><%= f.label field %><br />
8
- <%= f.text_field field %></p>
9
- <% end -%>
6
+ <% resource.class.invite_key_fields.each do |field| -%>
7
+ <div class="field">
8
+ <%= f.label field %><br />
9
+ <%= f.text_field field %>
10
+ </div>
11
+ <% end -%>
10
12
 
11
- <p><%= f.submit t("devise.invitations.new.submit_button") %></p>
13
+ <div class="actions">
14
+ <%= f.submit t("devise.invitations.new.submit_button") %>
15
+ </div>
12
16
  <% end %>
@@ -44,9 +44,9 @@ module Devise
44
44
  #
45
45
  # Examples (in config/initializers/devise.rb)
46
46
  #
47
- # config.invite_key = {:email => /\A[^@]+@[^@]+\z/}
47
+ # config.invite_key = { email: /\A[^@]+@[^@]+\z/ }
48
48
  mattr_accessor :invite_key
49
- @@invite_key = {:email => Devise.email_regexp}
49
+ @@invite_key = { email: Devise.email_regexp }
50
50
 
51
51
  # Public: Resend invitation if user with invited status is invited again
52
52
  # (default: true)
@@ -84,4 +84,4 @@ module Devise
84
84
  @@require_password_on_accepting = true
85
85
  end
86
86
 
87
- Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/models', :route => {:invitation => [nil, :new, :accept]}
87
+ Devise.add_module :invitable, controller: :invitations, model: 'devise_invitable/models', route: { invitation: [nil, :new, :accept] }
@@ -15,7 +15,7 @@ module DeviseInvitable::Controllers::Helpers
15
15
  protected
16
16
 
17
17
  def authenticate_inviter!
18
- send(:"authenticate_#{resource_name}!", :force => true)
18
+ send(:"authenticate_#{resource_name}!", force: true)
19
19
  end
20
20
 
21
21
  end
@@ -4,7 +4,7 @@ module DeviseInvitable
4
4
  module Mailer
5
5
 
6
6
  # Deliver an invitation email
7
- def invitation_instructions(record, token, opts={})
7
+ def invitation_instructions(record, token, opts = {})
8
8
  @token = token
9
9
  devise_mail(record, :invitation_instructions, opts)
10
10
  end
@@ -3,7 +3,7 @@ module DeviseInvitable
3
3
  private
4
4
  def default_controllers(options)
5
5
  options[:controllers] ||= {}
6
- options[:controllers][:registrations] ||= "devise_invitable/registrations"
6
+ options[:controllers][:registrations] ||= 'devise_invitable/registrations'
7
7
  super
8
8
  end
9
9
  end
@@ -17,8 +17,8 @@ module Devise
17
17
  # Examples:
18
18
  #
19
19
  # User.find(1).invited_to_sign_up? # => true/false
20
- # User.invite!(:email => 'someone@example.com') # => send invitation
21
- # User.accept_invitation!(:invitation_token => '...') # => accept invitation with a token
20
+ # User.invite!(email: 'someone@example.com') # => send invitation
21
+ # User.accept_invitation!(invitation_token: '...') # => accept invitation with a token
22
22
  # User.find(1).accept_invitation! # => accept invitation
23
23
  # User.find(1).invite! # => reset invitation status and send invitation again
24
24
  module Invitable
@@ -31,19 +31,19 @@ module Devise
31
31
  included do
32
32
  include ::DeviseInvitable::Inviter
33
33
  belongs_to_options = if Devise.invited_by_class_name
34
- {:class_name => Devise.invited_by_class_name}
34
+ { class_name: Devise.invited_by_class_name }
35
35
  else
36
- {:polymorphic => true}
36
+ { polymorphic: true }
37
37
  end
38
38
  if fk = Devise.invited_by_foreign_key
39
39
  belongs_to_options[:foreign_key] = fk
40
40
  end
41
41
  if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && self < ActiveRecord::Base
42
42
  counter_cache = Devise.invited_by_counter_cache
43
- belongs_to_options.merge! :counter_cache => counter_cache if counter_cache
44
- belongs_to_options.merge! :optional => true if ActiveRecord::VERSION::MAJOR >= 5
43
+ belongs_to_options.merge! counter_cache: counter_cache if counter_cache
44
+ belongs_to_options.merge! optional: true if ActiveRecord::VERSION::MAJOR >= 5
45
45
  elsif defined?(Mongoid) && defined?(Mongoid::Document) && self < Mongoid::Document && Mongoid::VERSION >= '6.0.0'
46
- belongs_to_options.merge! :optional => true
46
+ belongs_to_options.merge! optional: true
47
47
  end
48
48
  belongs_to :invited_by, belongs_to_options
49
49
 
@@ -51,14 +51,14 @@ module Devise
51
51
  define_model_callbacks :invitation_created
52
52
  define_model_callbacks :invitation_accepted
53
53
 
54
- scope :no_active_invitation, lambda { where(:invitation_token => nil) }
54
+ scope :no_active_invitation, lambda { where(invitation_token: nil) }
55
55
  if defined?(Mongoid) && defined?(Mongoid::Document) && self < Mongoid::Document
56
56
  scope :created_by_invite, lambda { where(:invitation_created_at.ne => nil) }
57
- scope :invitation_not_accepted, lambda { where(:invitation_accepted_at => nil, :invitation_token.ne => nil) }
57
+ scope :invitation_not_accepted, lambda { where(invitation_accepted_at: nil, :invitation_token.ne => nil) }
58
58
  scope :invitation_accepted, lambda { where(:invitation_accepted_at.ne => nil) }
59
59
  else
60
60
  scope :created_by_invite, lambda { where(arel_table[:invitation_created_at].not_eq(nil)) }
61
- scope :invitation_not_accepted, lambda { where(arel_table[:invitation_token].not_eq(nil)).where(:invitation_accepted_at => nil) }
61
+ scope :invitation_not_accepted, lambda { where(arel_table[:invitation_token].not_eq(nil)).where(invitation_accepted_at: nil) }
62
62
  scope :invitation_accepted, lambda { where(arel_table[:invitation_accepted_at].not_eq(nil)) }
63
63
 
64
64
  callbacks = [
@@ -158,7 +158,7 @@ module Devise
158
158
  self.downcase_keys if new_record_and_responds_to?(:downcase_keys)
159
159
  self.strip_whitespace if new_record_and_responds_to?(:strip_whitespace)
160
160
 
161
- if save(:validate => false)
161
+ if save(validate: false)
162
162
  self.invited_by.decrement_invitation_limit! if !was_invited and self.invited_by.present?
163
163
  deliver_invitation(options) unless skip_invitation
164
164
  end
@@ -274,7 +274,7 @@ module Devise
274
274
  end
275
275
 
276
276
  def generate_invitation_token!
277
- generate_invitation_token && save(:validate => false)
277
+ generate_invitation_token && save(validate: false)
278
278
  end
279
279
 
280
280
  def new_record_and_responds_to?(method)
@@ -298,7 +298,7 @@ module Devise
298
298
  # email is resent unless resend_invitation is set to false.
299
299
  # Attributes must contain the user's email, other attributes will be
300
300
  # set in the record
301
- def _invite(attributes={}, invited_by=nil, options = {}, &block)
301
+ def _invite(attributes = {}, invited_by = nil, options = {}, &block)
302
302
  invite_key_array = invite_key_fields
303
303
  attributes_hash = {}
304
304
  invite_key_array.each do |k,v|
@@ -328,12 +328,12 @@ module Devise
328
328
  [invitable, mail]
329
329
  end
330
330
 
331
- def invite!(attributes={}, invited_by=nil, options = {}, &block)
331
+ def invite!(attributes = {}, invited_by = nil, options = {}, &block)
332
332
  attr_hash = ActiveSupport::HashWithIndifferentAccess.new(attributes.to_h)
333
333
  _invite(attr_hash, invited_by, options, &block).first
334
334
  end
335
335
 
336
- def invite_mail!(attributes={}, invited_by=nil, options = {}, &block)
336
+ def invite_mail!(attributes = {}, invited_by = nil, options = {}, &block)
337
337
  _invite(attributes, invited_by, options, &block).last
338
338
  end
339
339
 
@@ -342,7 +342,7 @@ module Devise
342
342
  # the record. If not user is found, returns a new user containing an
343
343
  # error in invitation_token attribute.
344
344
  # Attributes must contain invitation_token, password and confirmation
345
- def accept_invitation!(attributes={})
345
+ def accept_invitation!(attributes = {})
346
346
  original_token = attributes.delete(:invitation_token)
347
347
  invitable = find_by_invitation_token(original_token, false)
348
348
  if invitable.errors.empty?
@@ -397,7 +397,7 @@ module Devise
397
397
  # lower + upper case, a digit and a symbol.
398
398
  # For more unusual rules, this method can be overridden.
399
399
  def random_password
400
- "aA1!" + Devise.friendly_token[0, 20]
400
+ 'aA1!' + Devise.friendly_token[0, 20]
401
401
  end
402
402
 
403
403
  end
@@ -3,10 +3,10 @@ module ActionDispatch::Routing
3
3
 
4
4
  protected
5
5
  def devise_invitation(mapping, controllers)
6
- resource :invitation, :only => [:new, :create, :update],
7
- :path => mapping.path_names[:invitation], :controller => controllers[:invitations] do
8
- get :edit, :path => mapping.path_names[:accept], :as => :accept
9
- get :destroy, :path => mapping.path_names[:remove], :as => :remove
6
+ resource :invitation, only: [:new, :create, :update],
7
+ path: mapping.path_names[:invitation], controller: controllers[:invitations] do
8
+ get :edit, path: mapping.path_names[:accept], as: :accept
9
+ get :destroy, path: mapping.path_names[:remove], as: :remove
10
10
  end
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module DeviseInvitable
2
- VERSION = '1.7.5'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -3,14 +3,14 @@ require 'rails/generators/active_record'
3
3
  module ActiveRecord
4
4
  module Generators
5
5
  class DeviseInvitableGenerator < ActiveRecord::Generators::Base
6
- source_root File.expand_path("../templates", __FILE__)
6
+ source_root File.expand_path('../templates', __FILE__)
7
7
 
8
8
  def copy_devise_migration
9
- migration_template "migration.rb", "db/migrate/devise_invitable_add_to_#{table_name}.rb", migration_version: migration_version
9
+ migration_template 'migration.rb', "db/migrate/devise_invitable_add_to_#{table_name}.rb", migration_version: migration_version
10
10
  end
11
11
 
12
12
  def migration_version
13
- if Rails.version.start_with? '5.'
13
+ if Rails::VERSION::MAJOR >= 5
14
14
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
15
15
  end
16
16
  end
@@ -1,17 +1,13 @@
1
1
  module DeviseInvitable
2
2
  module Generators
3
3
  class DeviseInvitableGenerator < Rails::Generators::NamedBase
4
- namespace "devise_invitable"
4
+ namespace 'devise_invitable'
5
5
 
6
- desc "Add :invitable directive in the given model. Also generate migration for ActiveRecord"
7
-
8
- # def devise_generate_model
9
- # invoke "devise", [name]
10
- # end
6
+ desc 'Add :invitable directive in the given model. Also generate migration for ActiveRecord'
11
7
 
12
8
  def inject_devise_invitable_content
13
- path = File.join("app", "models", "#{file_path}.rb")
14
- inject_into_file(path, "invitable, :", :after => "devise :") if File.exists?(path)
9
+ path = File.join('app', 'models', "#{file_path}.rb")
10
+ inject_into_file(path, 'invitable, :', after: 'devise :') if File.exists?(path)
15
11
  end
16
12
 
17
13
  hook_for :orm
@@ -1,22 +1,18 @@
1
1
  module DeviseInvitable
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path("../../templates", __FILE__)
5
- desc "Add DeviseInvitable config variables to the Devise initializer and copy DeviseInvitable locale files to your application."
6
-
7
- # def devise_install
8
- # invoke "devise:install"
9
- # end
4
+ source_root File.expand_path('../../templates', __FILE__)
5
+ desc 'Add DeviseInvitable config variables to the Devise initializer and copy DeviseInvitable locale files to your application.'
10
6
 
11
7
  def add_config_options_to_initializer
12
- devise_initializer_path = "config/initializers/devise.rb"
8
+ devise_initializer_path = 'config/initializers/devise.rb'
13
9
  if File.exist?(devise_initializer_path)
14
10
  old_content = File.read(devise_initializer_path)
15
11
 
16
12
  if old_content.match(Regexp.new(/^\s# ==> Configuration for :invitable\n/))
17
13
  false
18
14
  else
19
- inject_into_file(devise_initializer_path, :before => " # ==> Configuration for :confirmable\n") do
15
+ inject_into_file(devise_initializer_path, before: " # ==> Configuration for :confirmable\n") do
20
16
  <<-CONTENT
21
17
  # ==> Configuration for :invitable
22
18
  # The period the generated invitation token is valid, after
@@ -36,8 +32,8 @@ module DeviseInvitable
36
32
 
37
33
  # The key to be used to check existing users when sending an invitation
38
34
  # and the regexp used to test it when validate_on_invite is not set.
39
- # config.invite_key = {:email => /\\A[^@]+@[^@]+\\z/}
40
- # config.invite_key = {:email => /\\A[^@]+@[^@]+\\z/, :username => nil}
35
+ # config.invite_key = { email: /\\A[^@]+@[^@]+\\z/ }
36
+ # config.invite_key = { email: /\\A[^@]+@[^@]+\\z/, username: nil }
41
37
 
42
38
  # Flag that force a record to be valid before being actually invited
43
39
  # Default: false
@@ -73,7 +69,7 @@ CONTENT
73
69
  end
74
70
 
75
71
  def copy_locale
76
- copy_file "../../../config/locales/en.yml", "config/locales/devise_invitable.en.yml"
72
+ copy_file '../../../config/locales/en.yml', 'config/locales/devise_invitable.en.yml'
77
73
  end
78
74
 
79
75
  end
@@ -1,11 +1,15 @@
1
- <h2><%= t 'devise.invitations.edit.header' %></h2>
1
+ <h2><%= t "devise.invitations.edit.header" %></h2>
2
2
 
3
- <%= simple_form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put } do |f| %>
4
- <%= devise_error_messages! %>
3
+ <%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put }) do |f| %>
4
+ <%= f.error_notification %>
5
5
  <%= f.hidden_field :invitation_token %>
6
6
 
7
- <%= f.input :password %>
8
- <%= f.input :password_confirmation %>
7
+ <div class="form-inputs">
8
+ <%= f.input :password %>
9
+ <%= f.input :password_confirmation %>
10
+ </div>
9
11
 
10
- <%= f.button :submit, t("devise.invitations.edit.submit_button") %>
12
+ <div class="form-actions">
13
+ <%= f.button :submit, t("devise.invitations.edit.submit_button") %>
14
+ </div>
11
15
  <% end %>
@@ -1,11 +1,15 @@
1
1
  <h2><%= t "devise.invitations.new.header" %></h2>
2
2
 
3
- <%= simple_form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post} do |f| %>
4
- <%= devise_error_messages! %>
3
+ <%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= f.error_notification %>
5
5
 
6
- <% resource.class.invite_key_fields.each do |field| -%>
7
- <%= f.input field %>
8
- <% end -%>
6
+ <% resource.class.invite_key_fields.each do |field| -%>
7
+ <div class="form-inputs">
8
+ <%= f.input field %>
9
+ </div>
10
+ <% end -%>
9
11
 
10
- <%= f.button :submit, t("devise.invitations.new.submit_button") %>
12
+ <div class="form-actions">
13
+ <%= f.button :submit, t("devise.invitations.new.submit_button") %>
14
+ </div>
11
15
  <% end %>
@@ -11,17 +11,17 @@ module DeviseInvitable
11
11
  end
12
12
 
13
13
  class SimpleFormForGenerator < InvitationViewsGenerator
14
- source_root File.expand_path("../templates/simple_form_for", __FILE__)
14
+ source_root File.expand_path('../templates/simple_form_for', __FILE__)
15
15
  end
16
16
 
17
17
  class FormForGenerator < InvitationViewsGenerator
18
- source_root File.expand_path("../../../../app/views/devise", __FILE__)
18
+ source_root File.expand_path('../../../../app/views/devise', __FILE__)
19
19
  end
20
20
 
21
21
  class MailerViewsGenerator < Rails::Generators::Base
22
22
  include ::Devise::Generators::ViewPathTemplates
23
- source_root File.expand_path("../../../../app/views/devise", __FILE__)
24
- desc "Copies Devise mail erb views to your application."
23
+ source_root File.expand_path('../../../../app/views/devise', __FILE__)
24
+ desc 'Copies Devise mail erb views to your application.'
25
25
  hide!
26
26
 
27
27
  def copy_views
@@ -31,11 +31,11 @@ module DeviseInvitable
31
31
 
32
32
  class ViewsGenerator < Rails::Generators::Base
33
33
  desc 'Copies all DeviseInvitable views to your application.'
34
- argument :scope, :required => false, :default => nil, :desc => "The scope to copy views to"
34
+ argument :scope, required: false, default: nil, desc: 'The scope to copy views to'
35
35
 
36
36
  invoke MailerViewsGenerator
37
37
 
38
- hook_for :form_builder, :aliases => "-b", :desc => "Form builder to be used", :default => defined?(SimpleForm) ? "simple_form_for" : "form_for"
38
+ hook_for :form_builder, aliases: '-b', desc: 'Form builder to be used', default: defined?(SimpleForm) ? 'simple_form_for' : 'form_for'
39
39
  end
40
40
  end
41
41
  end
@@ -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