loyal_devise 2.1.7 → 2.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/README.md +16 -46
  2. data/app/controllers/devise/passwords_controller.rb +1 -1
  3. data/app/controllers/devise/registrations_controller.rb +1 -1
  4. data/lib/devise/controllers/helpers.rb +3 -6
  5. data/lib/devise/failure_app.rb +1 -8
  6. data/lib/devise/hooks/lockable.rb +1 -1
  7. data/lib/devise/mapping.rb +6 -6
  8. data/lib/devise/models/authenticatable.rb +4 -4
  9. data/lib/devise/models/confirmable.rb +4 -12
  10. data/lib/devise/models/database_authenticatable.rb +1 -1
  11. data/lib/devise/models/lockable.rb +1 -1
  12. data/lib/devise/models/recoverable.rb +2 -7
  13. data/lib/devise/models/rememberable.rb +1 -1
  14. data/lib/devise/{parameter_filter.rb → param_filter.rb} +1 -1
  15. data/lib/devise/parameter_sanitizer.rb +3 -3
  16. data/lib/devise/version.rb +1 -1
  17. data/lib/devise.rb +1 -1
  18. data/lib/generators/templates/README +1 -1
  19. data/lib/loyal_devise.rb +1 -0
  20. metadata +65 -301
  21. data/.gitignore +0 -12
  22. data/.travis.yml +0 -20
  23. data/.yardopts +0 -9
  24. data/CHANGELOG.rdoc +0 -936
  25. data/CONTRIBUTING.md +0 -14
  26. data/Gemfile +0 -31
  27. data/Gemfile.lock +0 -160
  28. data/devise.gemspec +0 -26
  29. data/devise.png +0 -0
  30. data/gemfiles/Gemfile.rails-3.2.x +0 -31
  31. data/gemfiles/Gemfile.rails-3.2.x.lock +0 -156
  32. data/loyal_devise.gemspec +0 -29
  33. data/test/controllers/custom_strategy_test.rb +0 -62
  34. data/test/controllers/helpers_test.rb +0 -253
  35. data/test/controllers/internal_helpers_test.rb +0 -120
  36. data/test/controllers/passwords_controller_test.rb +0 -32
  37. data/test/controllers/sessions_controller_test.rb +0 -85
  38. data/test/controllers/url_helpers_test.rb +0 -59
  39. data/test/delegator_test.rb +0 -19
  40. data/test/devise_test.rb +0 -83
  41. data/test/failure_app_test.rb +0 -221
  42. data/test/generators/active_record_generator_test.rb +0 -73
  43. data/test/generators/devise_generator_test.rb +0 -39
  44. data/test/generators/install_generator_test.rb +0 -13
  45. data/test/generators/mongoid_generator_test.rb +0 -23
  46. data/test/generators/views_generator_test.rb +0 -67
  47. data/test/helpers/devise_helper_test.rb +0 -51
  48. data/test/integration/authenticatable_test.rb +0 -699
  49. data/test/integration/confirmable_test.rb +0 -299
  50. data/test/integration/database_authenticatable_test.rb +0 -84
  51. data/test/integration/http_authenticatable_test.rb +0 -115
  52. data/test/integration/lockable_test.rb +0 -242
  53. data/test/integration/omniauthable_test.rb +0 -133
  54. data/test/integration/recoverable_test.rb +0 -335
  55. data/test/integration/registerable_test.rb +0 -349
  56. data/test/integration/rememberable_test.rb +0 -165
  57. data/test/integration/timeoutable_test.rb +0 -150
  58. data/test/integration/token_authenticatable_test.rb +0 -205
  59. data/test/integration/trackable_test.rb +0 -92
  60. data/test/mailers/confirmation_instructions_test.rb +0 -111
  61. data/test/mailers/reset_password_instructions_test.rb +0 -92
  62. data/test/mailers/unlock_instructions_test.rb +0 -87
  63. data/test/mapping_test.rb +0 -127
  64. data/test/models/authenticatable_test.rb +0 -13
  65. data/test/models/confirmable_test.rb +0 -443
  66. data/test/models/database_authenticatable_test.rb +0 -226
  67. data/test/models/lockable_test.rb +0 -273
  68. data/test/models/omniauthable_test.rb +0 -7
  69. data/test/models/recoverable_test.rb +0 -222
  70. data/test/models/registerable_test.rb +0 -7
  71. data/test/models/rememberable_test.rb +0 -175
  72. data/test/models/serializable_test.rb +0 -49
  73. data/test/models/timeoutable_test.rb +0 -46
  74. data/test/models/token_authenticatable_test.rb +0 -55
  75. data/test/models/trackable_test.rb +0 -13
  76. data/test/models/validatable_test.rb +0 -127
  77. data/test/models_test.rb +0 -163
  78. data/test/omniauth/config_test.rb +0 -57
  79. data/test/omniauth/url_helpers_test.rb +0 -54
  80. data/test/orm/active_record.rb +0 -10
  81. data/test/orm/mongoid.rb +0 -13
  82. data/test/parameter_sanitizer_test.rb +0 -51
  83. data/test/rails_app/Rakefile +0 -6
  84. data/test/rails_app/app/active_record/admin.rb +0 -6
  85. data/test/rails_app/app/active_record/shim.rb +0 -2
  86. data/test/rails_app/app/active_record/user.rb +0 -6
  87. data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -6
  88. data/test/rails_app/app/controllers/admins_controller.rb +0 -11
  89. data/test/rails_app/app/controllers/application_controller.rb +0 -9
  90. data/test/rails_app/app/controllers/home_controller.rb +0 -25
  91. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -2
  92. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -2
  93. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -14
  94. data/test/rails_app/app/controllers/users_controller.rb +0 -31
  95. data/test/rails_app/app/helpers/application_helper.rb +0 -3
  96. data/test/rails_app/app/mailers/users/mailer.rb +0 -12
  97. data/test/rails_app/app/mongoid/admin.rb +0 -29
  98. data/test/rails_app/app/mongoid/shim.rb +0 -23
  99. data/test/rails_app/app/mongoid/user.rb +0 -42
  100. data/test/rails_app/app/views/admins/index.html.erb +0 -1
  101. data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
  102. data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
  103. data/test/rails_app/app/views/home/index.html.erb +0 -1
  104. data/test/rails_app/app/views/home/join.html.erb +0 -1
  105. data/test/rails_app/app/views/home/private.html.erb +0 -1
  106. data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
  107. data/test/rails_app/app/views/layouts/application.html.erb +0 -24
  108. data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
  109. data/test/rails_app/app/views/users/index.html.erb +0 -1
  110. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
  111. data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
  112. data/test/rails_app/bin/bundle +0 -3
  113. data/test/rails_app/bin/rails +0 -4
  114. data/test/rails_app/bin/rake +0 -4
  115. data/test/rails_app/config/application.rb +0 -40
  116. data/test/rails_app/config/boot.rb +0 -8
  117. data/test/rails_app/config/database.yml +0 -18
  118. data/test/rails_app/config/environment.rb +0 -5
  119. data/test/rails_app/config/environments/development.rb +0 -34
  120. data/test/rails_app/config/environments/production.rb +0 -84
  121. data/test/rails_app/config/environments/test.rb +0 -36
  122. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  123. data/test/rails_app/config/initializers/devise.rb +0 -178
  124. data/test/rails_app/config/initializers/inflections.rb +0 -2
  125. data/test/rails_app/config/initializers/secret_token.rb +0 -8
  126. data/test/rails_app/config/initializers/session_store.rb +0 -1
  127. data/test/rails_app/config/routes.rb +0 -104
  128. data/test/rails_app/config.ru +0 -4
  129. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -74
  130. data/test/rails_app/db/schema.rb +0 -52
  131. data/test/rails_app/lib/shared_admin.rb +0 -14
  132. data/test/rails_app/lib/shared_user.rb +0 -25
  133. data/test/rails_app/public/404.html +0 -26
  134. data/test/rails_app/public/422.html +0 -26
  135. data/test/rails_app/public/500.html +0 -26
  136. data/test/rails_app/public/favicon.ico +0 -0
  137. data/test/routes_test.rb +0 -250
  138. data/test/support/assertions.rb +0 -40
  139. data/test/support/helpers.rb +0 -91
  140. data/test/support/integration.rb +0 -92
  141. data/test/support/locale/en.yml +0 -4
  142. data/test/support/webrat/integrations/rails.rb +0 -24
  143. data/test/test_helper.rb +0 -34
  144. data/test/test_helpers_test.rb +0 -151
  145. data/test/test_models.rb +0 -26
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SerializableTest < ActiveSupport::TestCase
4
- setup do
5
- @user = create_user
6
- end
7
-
8
- test 'should not include unsafe keys on XML' do
9
- assert_match(/email/, @user.to_xml)
10
- assert_no_match(/confirmation-token/, @user.to_xml)
11
- end
12
-
13
- test 'should not include unsafe keys on XML even if a new except is provided' do
14
- assert_no_match(/email/, @user.to_xml(:except => :email))
15
- assert_no_match(/confirmation-token/, @user.to_xml(:except => :email))
16
- end
17
-
18
- test 'should include unsafe keys on XML if a force_except is provided' do
19
- assert_no_match(/<email/, @user.to_xml(:force_except => :email))
20
- assert_match(/confirmation-token/, @user.to_xml(:force_except => :email))
21
- end
22
-
23
- test 'should not include unsafe keys on JSON' do
24
- keys = from_json().keys.select{ |key| !key.include?("id") }
25
- assert_equal %w(created_at email facebook_token updated_at username), keys.sort
26
- end
27
-
28
- test 'should not include unsafe keys on JSON even if a new except is provided' do
29
- assert_no_key "email", from_json(:except => :email)
30
- assert_no_key "confirmation_token", from_json(:except => :email)
31
- end
32
-
33
- test 'should include unsafe keys on JSON if a force_except is provided' do
34
- assert_no_key "email", from_json(:force_except => :email)
35
- assert_key "confirmation_token", from_json(:force_except => :email)
36
- end
37
-
38
- def assert_key(key, subject)
39
- assert subject.key?(key), "Expected #{subject.inspect} to have key #{key.inspect}"
40
- end
41
-
42
- def assert_no_key(key, subject)
43
- assert !subject.key?(key), "Expected #{subject.inspect} to not have key #{key.inspect}"
44
- end
45
-
46
- def from_json(options=nil)
47
- ActiveSupport::JSON.decode(@user.to_json(options))["user"]
48
- end
49
- end
@@ -1,46 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TimeoutableTest < ActiveSupport::TestCase
4
-
5
- test 'should be expired' do
6
- assert new_user.timedout?(31.minutes.ago)
7
- end
8
-
9
- test 'should not be expired' do
10
- assert_not new_user.timedout?(29.minutes.ago)
11
- end
12
-
13
- test 'should not be expired when params is nil' do
14
- assert_not new_user.timedout?(nil)
15
- end
16
-
17
- test 'should use timeout_in method' do
18
- user = new_user
19
- user.instance_eval { def timeout_in; 10.minutes end }
20
-
21
- assert user.timedout?(12.minutes.ago)
22
- assert_not user.timedout?(8.minutes.ago)
23
- end
24
-
25
- test 'should not be expired when timeout_in method returns nil' do
26
- user = new_user
27
- user.instance_eval { def timeout_in; nil end }
28
- assert_not user.timedout?(10.hours.ago)
29
- end
30
-
31
- test 'fallback to Devise config option' do
32
- swap Devise, :timeout_in => 1.minute do
33
- user = new_user
34
- assert user.timedout?(2.minutes.ago)
35
- assert_not user.timedout?(30.seconds.ago)
36
-
37
- Devise.timeout_in = 5.minutes
38
- assert_not user.timedout?(2.minutes.ago)
39
- assert user.timedout?(6.minutes.ago)
40
- end
41
- end
42
-
43
- test 'required_fields should contain the fields that Devise uses' do
44
- assert_same_content Devise::Models::Timeoutable.required_fields(User), []
45
- end
46
- end
@@ -1,55 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TokenAuthenticatableTest < ActiveSupport::TestCase
4
-
5
- test 'should reset authentication token' do
6
- user = new_user
7
- user.reset_authentication_token
8
- previous_token = user.authentication_token
9
- user.reset_authentication_token
10
- assert_not_equal previous_token, user.authentication_token
11
- end
12
-
13
- test 'should ensure authentication token' do
14
- user = new_user
15
- user.ensure_authentication_token
16
- previous_token = user.authentication_token
17
- user.ensure_authentication_token
18
- assert_equal previous_token, user.authentication_token
19
- end
20
-
21
- test 'should authenticate a valid user with authentication token and return it' do
22
- user = create_user
23
- user.ensure_authentication_token!
24
- user.confirm!
25
- authenticated_user = User.find_for_token_authentication(:auth_token => user.authentication_token)
26
- assert_equal authenticated_user, user
27
- end
28
-
29
- test 'should return nil when authenticating an invalid user by authentication token' do
30
- user = create_user
31
- user.ensure_authentication_token!
32
- user.confirm!
33
- authenticated_user = User.find_for_token_authentication(:auth_token => user.authentication_token.reverse)
34
- assert_nil authenticated_user
35
- end
36
-
37
- test 'should not be subject to injection' do
38
- user1 = create_user
39
- user1.ensure_authentication_token!
40
- user1.confirm!
41
-
42
- user2 = create_user
43
- user2.ensure_authentication_token!
44
- user2.confirm!
45
-
46
- user = User.find_for_token_authentication(:auth_token => {'$ne' => user1.authentication_token})
47
- assert_nil user
48
- end
49
-
50
- test 'required_fields should contain the fields that Devise uses' do
51
- assert_same_content Devise::Models::TokenAuthenticatable.required_fields(User), [
52
- :authentication_token
53
- ]
54
- end
55
- end
@@ -1,13 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TrackableTest < ActiveSupport::TestCase
4
- test 'required_fields should contain the fields that Devise uses' do
5
- assert_same_content Devise::Models::Trackable.required_fields(User), [
6
- :current_sign_in_at,
7
- :current_sign_in_ip,
8
- :last_sign_in_at,
9
- :last_sign_in_ip,
10
- :sign_in_count
11
- ]
12
- end
13
- end
@@ -1,127 +0,0 @@
1
- # encoding: UTF-8
2
- require 'test_helper'
3
-
4
- class ValidatableTest < ActiveSupport::TestCase
5
- test 'should require email to be set' do
6
- user = new_user(:email => nil)
7
- assert user.invalid?
8
- assert user.errors[:email]
9
- assert_equal 'can\'t be blank', user.errors[:email].join
10
- end
11
-
12
- test 'should require uniqueness of email if email has changed, allowing blank' do
13
- existing_user = create_user
14
-
15
- user = new_user(:email => '')
16
- assert user.invalid?
17
- assert_no_match(/taken/, user.errors[:email].join)
18
-
19
- user.email = existing_user.email
20
- assert user.invalid?
21
- assert_match(/taken/, user.errors[:email].join)
22
-
23
- user.save(:validate => false)
24
- assert user.valid?
25
- end
26
-
27
- test 'should require correct email format if email has changed, allowing blank' do
28
- user = new_user(:email => '')
29
- assert user.invalid?
30
- assert_not_equal 'is invalid', user.errors[:email].join
31
-
32
- %w{invalid_email_format 123 $$$ () ☃ bla@bla.}.each do |email|
33
- user.email = email
34
- assert user.invalid?, 'should be invalid with email ' << email
35
- assert_equal 'is invalid', user.errors[:email].join
36
- end
37
-
38
- user.save(:validate => false)
39
- assert user.valid?
40
- end
41
-
42
- test 'should accept valid emails' do
43
- %w(a.b.c@example.com test_mail@gmail.com any@any.net email@test.br 123@mail.test 1☃3@mail.test).each do |email|
44
- user = new_user(:email => email)
45
- assert user.valid?, 'should be valid with email ' << email
46
- assert_blank user.errors[:email]
47
- end
48
- end
49
-
50
- test 'should require password to be set when creating a new record' do
51
- user = new_user(:password => '', :password_confirmation => '')
52
- assert user.invalid?
53
- assert_equal 'can\'t be blank', user.errors[:password].join
54
- end
55
-
56
- test 'should require confirmation to be set when creating a new record' do
57
- user = new_user(:password => 'new_password', :password_confirmation => 'blabla')
58
- assert user.invalid?
59
-
60
- if Devise.rails4?
61
- assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
62
- else
63
- assert_equal 'doesn\'t match confirmation', user.errors[:password].join
64
- end
65
- end
66
-
67
- test 'should require password when updating/resetting password' do
68
- user = create_user
69
-
70
- user.password = ''
71
- user.password_confirmation = ''
72
-
73
- assert user.invalid?
74
- assert_equal 'can\'t be blank', user.errors[:password].join
75
- end
76
-
77
- test 'should require confirmation when updating/resetting password' do
78
- user = create_user
79
- user.password_confirmation = 'another_password'
80
- assert user.invalid?
81
-
82
- if Devise.rails4?
83
- assert_equal 'doesn\'t match Password', user.errors[:password_confirmation].join
84
- else
85
- assert_equal 'doesn\'t match confirmation', user.errors[:password].join
86
- end
87
- end
88
-
89
- test 'should require a password with minimum of 6 characters' do
90
- user = new_user(:password => '12345', :password_confirmation => '12345')
91
- assert user.invalid?
92
- assert_equal 'is too short (minimum is 6 characters)', user.errors[:password].join
93
- end
94
-
95
- test 'should require a password with maximum of 128 characters long' do
96
- user = new_user(:password => 'x'*129, :password_confirmation => 'x'*129)
97
- assert user.invalid?
98
- assert_equal 'is too long (maximum is 128 characters)', user.errors[:password].join
99
- end
100
-
101
- test 'should not require password length when it\'s not changed' do
102
- user = create_user.reload
103
- user.password = user.password_confirmation = nil
104
- assert user.valid?
105
-
106
- user.password_confirmation = 'confirmation'
107
- assert user.invalid?
108
- assert_not (user.errors[:password].join =~ /is too long/)
109
- end
110
-
111
- test 'should complain about length even if password is not required' do
112
- user = new_user(:password => 'x'*129, :password_confirmation => 'x'*129)
113
- user.stubs(:password_required?).returns(false)
114
- assert user.invalid?
115
- assert_equal 'is too long (maximum is 128 characters)', user.errors[:password].join
116
- end
117
-
118
- test 'should not be included in objects with invalid API' do
119
- assert_raise RuntimeError do
120
- Class.new.send :include, Devise::Models::Validatable
121
- end
122
- end
123
-
124
- test 'required_fields should be an empty array' do
125
- assert_equal Devise::Models::Validatable.required_fields(User), []
126
- end
127
- end
data/test/models_test.rb DELETED
@@ -1,163 +0,0 @@
1
- require 'test_helper'
2
- require 'test_models'
3
-
4
- class ActiveRecordTest < ActiveSupport::TestCase
5
- def include_module?(klass, mod)
6
- klass.devise_modules.include?(mod) &&
7
- klass.included_modules.include?(Devise::Models::const_get(mod.to_s.classify))
8
- end
9
-
10
- def assert_include_modules(klass, *modules)
11
- modules.each do |mod|
12
- assert include_module?(klass, mod)
13
- end
14
-
15
- (Devise::ALL - modules).each do |mod|
16
- assert_not include_module?(klass, mod)
17
- end
18
- end
19
-
20
- test 'can cherry pick modules' do
21
- assert_include_modules Admin, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :confirmable
22
- end
23
-
24
- test 'validations options are not applied too late' do
25
- validators = WithValidation.validators_on :password
26
- length = validators.find { |v| v.kind == :length }
27
- assert_equal 2, length.options[:minimum]
28
- assert_equal 6, length.options[:maximum]
29
- end
30
-
31
- test 'validations are applied just once' do
32
- validators = Several.validators_on :password
33
- assert_equal 1, validators.select{ |v| v.kind == :length }.length
34
- end
35
-
36
- test 'chosen modules are inheritable' do
37
- assert_include_modules Inheritable, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :confirmable
38
- end
39
-
40
- test 'order of module inclusion' do
41
- correct_module_order = [:database_authenticatable, :recoverable, :registerable, :confirmable, :lockable, :timeoutable]
42
- incorrect_module_order = [:database_authenticatable, :timeoutable, :registerable, :recoverable, :lockable, :confirmable]
43
-
44
- assert_include_modules Admin, *incorrect_module_order
45
-
46
- # get module constants from symbol list
47
- module_constants = correct_module_order.collect { |mod| Devise::Models::const_get(mod.to_s.classify) }
48
-
49
- # confirm that they adhere to the order in ALL
50
- # get included modules, filter out the noise, and reverse the order
51
- assert_equal module_constants, (Admin.included_modules & module_constants).reverse
52
- end
53
-
54
- test 'raise error on invalid module' do
55
- assert_raise NameError do
56
- # Mix valid an invalid modules.
57
- Configurable.class_eval { devise :database_authenticatable, :doesnotexit }
58
- end
59
- end
60
-
61
- test 'set a default value for stretches' do
62
- assert_equal 15, Configurable.stretches
63
- end
64
-
65
- test 'set a default value for pepper' do
66
- assert_equal 'abcdef', Configurable.pepper
67
- end
68
-
69
- test 'set a default value for allow_unconfirmed_access_for' do
70
- assert_equal 5.days, Configurable.allow_unconfirmed_access_for
71
- end
72
-
73
- test 'set a default value for remember_for' do
74
- assert_equal 7.days, Configurable.remember_for
75
- end
76
-
77
- test 'set a default value for timeout_in' do
78
- assert_equal 15.minutes, Configurable.timeout_in
79
- end
80
-
81
- test 'set a default value for unlock_in' do
82
- assert_equal 10.days, Configurable.unlock_in
83
- end
84
-
85
- test 'set null fields on migrations' do
86
- # Ignore email sending since no email exists.
87
- klass = Class.new(Admin) do
88
- def send_devise_notification(*); end
89
- end
90
-
91
- klass.create!
92
- end
93
- end
94
-
95
- class CheckFieldsTest < ActiveSupport::TestCase
96
- test 'checks if the class respond_to the required fields' do
97
- Player = Class.new do
98
- extend Devise::Models
99
-
100
- def self.before_validation(instance)
101
- end
102
-
103
- devise :database_authenticatable
104
-
105
- attr_accessor :encrypted_password, :email
106
- end
107
-
108
- assert_nothing_raised Devise::Models::MissingAttribute do
109
- Devise::Models.check_fields!(Player)
110
- end
111
- end
112
-
113
- test 'raises Devise::Models::MissingAtrribute and shows the missing attribute if the class doesn\'t respond_to one of the attributes' do
114
- Clown = Class.new do
115
- extend Devise::Models
116
-
117
- def self.before_validation(instance)
118
- end
119
-
120
- devise :database_authenticatable
121
-
122
- attr_accessor :encrypted_password
123
- end
124
-
125
- assert_raise_with_message Devise::Models::MissingAttribute, "The following attribute(s) is (are) missing on your model: email" do
126
- Devise::Models.check_fields!(Clown)
127
- end
128
- end
129
-
130
- test 'raises Devise::Models::MissingAtrribute with all the missing attributes if there is more than one' do
131
- Magician = Class.new do
132
- extend Devise::Models
133
-
134
- def self.before_validation(instance)
135
- end
136
-
137
- devise :database_authenticatable
138
- end
139
-
140
- assert_raise_with_message Devise::Models::MissingAttribute, "The following attribute(s) is (are) missing on your model: encrypted_password, email" do
141
- Devise::Models.check_fields!(Magician)
142
- end
143
- end
144
-
145
- test "doesn't raise a NoMethodError exception when the module doesn't have a required_field(klass) class method" do
146
- driver = Class.new do
147
- extend Devise::Models
148
-
149
- def self.before_validation(instance)
150
- end
151
-
152
- attr_accessor :encrypted_password, :email
153
-
154
- devise :database_authenticatable
155
- end
156
-
157
- swap_module_method_existence Devise::Models::DatabaseAuthenticatable, :required_fields do
158
- assert_deprecated do
159
- Devise::Models.check_fields!(driver)
160
- end
161
- end
162
- end
163
- end
@@ -1,57 +0,0 @@
1
- require 'test_helper'
2
-
3
- class OmniAuthConfigTest < ActiveSupport::TestCase
4
- class MyStrategy
5
- include OmniAuth::Strategy
6
- end
7
-
8
- test 'strategy_name returns provider if no options given' do
9
- config = Devise::OmniAuth::Config.new :facebook, [{}]
10
- assert_equal :facebook, config.strategy_name
11
- end
12
-
13
- test 'strategy_name returns provider if no name option are given' do
14
- config = Devise::OmniAuth::Config.new :facebook, [{ :other => :option }]
15
- assert_equal :facebook, config.strategy_name
16
- end
17
-
18
- test 'returns name option when have a name' do
19
- config = Devise::OmniAuth::Config.new :facebook, [{ :name => :github }]
20
- assert_equal :github, config.strategy_name
21
- end
22
-
23
- test "finds contrib strategies" do
24
- config = Devise::OmniAuth::Config.new :facebook, [{}]
25
- assert_equal OmniAuth::Strategies::Facebook, config.strategy_class
26
- end
27
-
28
- test "finds the strategy in OmniAuth's list by name" do
29
- NamedTestStrategy = Class.new
30
- NamedTestStrategy.send :include, OmniAuth::Strategy
31
- NamedTestStrategy.option :name, :the_one
32
-
33
- config = Devise::OmniAuth::Config.new :the_one, [{}]
34
- assert_equal NamedTestStrategy, config.strategy_class
35
- end
36
-
37
- test "finds the strategy in OmniAuth's list by class name" do
38
- UnNamedTestStrategy = Class.new
39
- UnNamedTestStrategy.send :include, OmniAuth::Strategy
40
-
41
- config = Devise::OmniAuth::Config.new :un_named_test_strategy, [{}]
42
- assert_equal UnNamedTestStrategy, config.strategy_class
43
- end
44
-
45
- test 'raises an error if strategy cannot be found' do
46
- config = Devise::OmniAuth::Config.new :my_other_strategy, [{}]
47
- assert_raise Devise::OmniAuth::StrategyNotFound do
48
- config.strategy_class
49
- end
50
- end
51
-
52
- test 'allows the user to define a custom require path' do
53
- config = Devise::OmniAuth::Config.new :my_strategy, [{:strategy_class => MyStrategy}]
54
- config_class = config.strategy_class
55
- assert_equal MyStrategy, config_class
56
- end
57
- end
@@ -1,54 +0,0 @@
1
- require 'test_helper'
2
-
3
- class OmniAuthRoutesTest < ActionController::TestCase
4
- ExpectedUrlGeneratiorError = Devise.rails4? ?
5
- ActionController::UrlGenerationError : ActionController::RoutingError
6
-
7
- tests ApplicationController
8
-
9
- def assert_path(action, provider, with_param=true)
10
- # Resource param
11
- assert_equal @controller.send(action, :user, provider),
12
- @controller.send("user_#{action}", provider)
13
-
14
- # With an object
15
- assert_equal @controller.send(action, User.new, provider),
16
- @controller.send("user_#{action}", provider)
17
-
18
- if with_param
19
- # Default url params
20
- assert_equal @controller.send(action, :user, provider, :param => 123),
21
- @controller.send("user_#{action}", provider, :param => 123)
22
- end
23
- end
24
-
25
- test 'should alias omniauth_callback to mapped user auth_callback' do
26
- assert_path :omniauth_callback_path, :facebook
27
- end
28
-
29
- test 'should alias omniauth_authorize to mapped user auth_authorize' do
30
- assert_path :omniauth_authorize_path, :facebook, false
31
- end
32
-
33
- test 'should generate authorization path' do
34
- assert_match "/users/auth/facebook", @controller.omniauth_authorize_path(:user, :facebook)
35
-
36
- assert_raise ExpectedUrlGeneratiorError do
37
- @controller.omniauth_authorize_path(:user, :github)
38
- end
39
- end
40
-
41
- test 'should generate authorization path for named open_id omniauth' do
42
- assert_match "/users/auth/google", @controller.omniauth_authorize_path(:user, :google)
43
- end
44
-
45
- test 'should generate authorization path with params' do
46
- assert_match "/users/auth/openid?openid_url=http%3A%2F%2Fyahoo.com",
47
- @controller.omniauth_authorize_path(:user, :openid, :openid_url => "http://yahoo.com")
48
- end
49
-
50
- test 'should not add a "?" if no param was sent' do
51
- assert_equal "/users/auth/openid",
52
- @controller.omniauth_authorize_path(:user, :openid)
53
- end
54
- end
@@ -1,10 +0,0 @@
1
- ActiveRecord::Migration.verbose = false
2
- ActiveRecord::Base.logger = Logger.new(nil)
3
- ActiveRecord::Base.include_root_in_json = true
4
-
5
- ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
6
-
7
- class ActiveSupport::TestCase
8
- self.use_transactional_fixtures = true
9
- self.use_instantiated_fixtures = false
10
- end
data/test/orm/mongoid.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'mongoid/version'
2
-
3
- Mongoid.configure do |config|
4
- config.connect_to("devise-test-suite")
5
- config.use_utc = true
6
- config.include_root_in_json = true
7
- end
8
-
9
- class ActiveSupport::TestCase
10
- setup do
11
- Mongoid.purge!
12
- end
13
- end
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
- require 'devise/parameter_sanitizer'
3
-
4
- class BaseSanitizerTest < ActiveSupport::TestCase
5
- def sanitizer
6
- Devise::BaseSanitizer.new(User, :user, { user: { "email" => "jose" } })
7
- end
8
-
9
- test 'returns chosen params' do
10
- assert_equal({ "email" => "jose" }, sanitizer.for(:sign_in))
11
- end
12
- end
13
-
14
- if defined?(ActionController::StrongParameters)
15
- require 'active_model/forbidden_attributes_protection'
16
-
17
- class ParameterSanitizerTest < ActiveSupport::TestCase
18
- def sanitizer(params)
19
- params = ActionController::Parameters.new(params)
20
- Devise::ParameterSanitizer.new(User, :user, params)
21
- end
22
-
23
- test 'filters some parameters on sign in by default' do
24
- sanitizer = sanitizer(user: { "email" => "jose", "password" => "invalid" })
25
- assert_equal({ "email" => "jose" }, sanitizer.for(:sign_in))
26
- end
27
-
28
- test 'filters some parameters on sign up by default' do
29
- sanitizer = sanitizer(user: { "email" => "jose", "role" => "invalid" })
30
- assert_equal({ "email" => "jose" }, sanitizer.for(:sign_up))
31
- end
32
-
33
- test 'filters some parameters on account update by default' do
34
- sanitizer = sanitizer(user: { "email" => "jose", "role" => "invalid" })
35
- assert_equal({ "email" => "jose" }, sanitizer.for(:account_update))
36
- end
37
-
38
- test 'allows custom hooks' do
39
- sanitizer = sanitizer(user: { "email" => "jose", "password" => "invalid" })
40
- sanitizer.for(:sign_in) { |user| user.permit(:email, :password) }
41
- assert_equal({ "email" => "jose", "password" => "invalid" }, sanitizer.for(:sign_in))
42
- end
43
-
44
- test 'raises on unknown hooks' do
45
- sanitizer = sanitizer(user: { "email" => "jose", "password" => "invalid" })
46
- assert_raise NotImplementedError do
47
- sanitizer.for(:unknown)
48
- end
49
- end
50
- end
51
- end
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
@@ -1,6 +0,0 @@
1
- require 'shared_admin'
2
-
3
- class Admin < ActiveRecord::Base
4
- include Shim
5
- include SharedAdmin
6
- end
@@ -1,2 +0,0 @@
1
- module Shim
2
- end
@@ -1,6 +0,0 @@
1
- require 'shared_user'
2
-
3
- class User < ActiveRecord::Base
4
- include Shim
5
- include SharedUser
6
- end
@@ -1,6 +0,0 @@
1
- class Admins::SessionsController < Devise::SessionsController
2
- def new
3
- flash[:special] = "Welcome to #{controller_path.inspect} controller!"
4
- super
5
- end
6
- end