devise 1.4.2 → 1.4.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 might be problematic. Click here for more details.
- data/.gitignore +3 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.rdoc +16 -1
- data/Gemfile +4 -2
- data/README.rdoc +2 -2
- data/Rakefile +1 -1
- data/app/controllers/devise/confirmations_controller.rb +7 -1
- data/app/controllers/devise/registrations_controller.rb +8 -2
- data/app/controllers/devise/sessions_controller.rb +6 -4
- data/app/views/devise/confirmations/new.html.erb +3 -3
- data/app/views/devise/passwords/edit.html.erb +5 -5
- data/app/views/devise/passwords/new.html.erb +3 -3
- data/app/views/devise/registrations/edit.html.erb +9 -9
- data/app/views/devise/registrations/new.html.erb +7 -7
- data/app/views/devise/sessions/new.html.erb +6 -6
- data/app/views/devise/unlocks/new.html.erb +3 -3
- data/config/locales/en.yml +4 -0
- data/devise.gemspec +1 -1
- data/lib/devise.rb +11 -6
- data/lib/devise/controllers/helpers.rb +1 -0
- data/lib/devise/controllers/url_helpers.rb +20 -11
- data/lib/devise/hooks/timeoutable.rb +1 -1
- data/lib/devise/mailers/helpers.rb +9 -2
- data/lib/devise/mapping.rb +8 -1
- data/lib/devise/models/authenticatable.rb +9 -0
- data/lib/devise/models/confirmable.rb +8 -3
- data/lib/devise/models/database_authenticatable.rb +3 -0
- data/lib/devise/models/lockable.rb +5 -5
- data/lib/devise/models/recoverable.rb +10 -3
- data/lib/devise/models/trackable.rb +1 -1
- data/lib/devise/models/validatable.rb +1 -1
- data/lib/devise/rails.rb +13 -0
- data/lib/devise/rails/routes.rb +22 -10
- data/lib/devise/rails/warden_compat.rb +5 -10
- data/lib/devise/schema.rb +5 -3
- data/lib/devise/strategies/token_authenticatable.rb +5 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/devise_generator.rb +10 -5
- data/lib/generators/active_record/templates/migration_existing.rb +34 -0
- data/lib/generators/devise/orm_helpers.rb +8 -0
- data/lib/generators/templates/devise.rb +12 -5
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +3 -3
- data/test/controllers/helpers_test.rb +1 -1
- data/test/generators/active_record_generator_test.rb +13 -0
- data/test/generators/mongoid_generator_test.rb +4 -3
- data/test/helpers/devise_helper_test.rb +10 -2
- data/test/integration/authenticatable_test.rb +17 -0
- data/test/integration/confirmable_test.rb +10 -1
- data/test/integration/lockable_test.rb +1 -1
- data/test/integration/recoverable_test.rb +12 -3
- data/test/integration/registerable_test.rb +10 -2
- data/test/integration/token_authenticatable_test.rb +11 -0
- data/test/mailers/confirmation_instructions_test.rb +6 -0
- data/test/mailers/reset_password_instructions_test.rb +6 -0
- data/test/mailers/unlock_instructions_test.rb +6 -0
- data/test/models/confirmable_test.rb +2 -2
- data/test/models/encryptable_test.rb +4 -2
- data/test/models/validatable_test.rb +3 -2
- data/test/models_test.rb +9 -11
- data/test/orm/mongoid.rb +3 -0
- data/test/rails_app/app/active_record/user.rb +0 -2
- data/test/rails_app/app/mailers/users/mailer.rb +3 -0
- data/test/rails_app/app/mongoid/shim.rb +0 -5
- data/test/rails_app/config/application.rb +1 -0
- data/test/rails_app/config/initializers/devise.rb +3 -2
- data/test/rails_app/config/routes.rb +1 -1
- data/test/rails_app/lib/shared_user.rb +1 -0
- metadata +12 -12
- data/Gemfile.lock +0 -158
- data/lib/devise/email.rb +0 -23
@@ -4,7 +4,7 @@
|
|
4
4
|
<%= f.error_notification %>
|
5
5
|
|
6
6
|
<div class="inputs">
|
7
|
-
<%= f.input :email, :autofocus => true %>
|
7
|
+
<%= f.input :email, :required => true, :autofocus => true %>
|
8
8
|
<%= f.input :password, :hint => "leave it blank if you don't want to change it", :required => false %>
|
9
9
|
<%= f.input :password_confirmation, :required => false %>
|
10
10
|
<%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %>
|
@@ -4,9 +4,9 @@
|
|
4
4
|
<%= f.error_notification %>
|
5
5
|
|
6
6
|
<div class="inputs">
|
7
|
-
<%= f.input :email, :autofocus => true %>
|
8
|
-
<%= f.input :password %>
|
9
|
-
<%= f.input :password_confirmation %>
|
7
|
+
<%= f.input :email, :required => true, :autofocus => true %>
|
8
|
+
<%= f.input :password, :required => true %>
|
9
|
+
<%= f.input :password_confirmation, :required => true %>
|
10
10
|
</div>
|
11
11
|
|
12
12
|
<div class="actions">
|
@@ -106,7 +106,7 @@ class ControllerAuthenticatableTest < ActionController::TestCase
|
|
106
106
|
user = User.new
|
107
107
|
@mock_warden.expects(:user).returns(user)
|
108
108
|
@mock_warden.expects(:set_user).never
|
109
|
-
@controller.sign_in(user)
|
109
|
+
assert @controller.sign_in(user)
|
110
110
|
end
|
111
111
|
|
112
112
|
test 'sign in again when the user is already in only if force is given' do
|
@@ -13,9 +13,22 @@ if DEVISE_ORM == :active_record
|
|
13
13
|
assert_file "app/models/monster.rb", /devise/, /attr_accessible (:[a-z_]+(, )?)+/
|
14
14
|
assert_migration "db/migrate/devise_create_monsters.rb"
|
15
15
|
end
|
16
|
+
|
17
|
+
test "update model migration when model exists" do
|
18
|
+
run_generator %w(monster)
|
19
|
+
assert_file "app/models/monster.rb"
|
20
|
+
run_generator %w(monster)
|
21
|
+
assert_migration "db/migrate/add_devise_to_monsters.rb"
|
22
|
+
end
|
16
23
|
|
17
24
|
test "all files are properly deleted" do
|
18
25
|
run_generator %w(monster)
|
26
|
+
run_generator %w(monster)
|
27
|
+
assert_migration "db/migrate/devise_create_monsters.rb"
|
28
|
+
assert_migration "db/migrate/add_devise_to_monsters.rb"
|
29
|
+
run_generator %w(monster), :behavior => :revoke
|
30
|
+
assert_no_migration "db/migrate/add_devise_to_monsters.rb"
|
31
|
+
assert_migration "db/migrate/devise_create_monsters.rb"
|
19
32
|
run_generator %w(monster), :behavior => :revoke
|
20
33
|
assert_no_file "app/models/monster.rb"
|
21
34
|
assert_no_migration "db/migrate/devise_create_monsters.rb"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
if DEVISE_ORM == :
|
4
|
-
require "generators/
|
3
|
+
if DEVISE_ORM == :mongoid
|
4
|
+
require "generators/mongoid/devise_generator"
|
5
5
|
|
6
6
|
class MongoidGeneratorTest < Rails::Generators::TestCase
|
7
7
|
tests Mongoid::Generators::DeviseGenerator
|
@@ -19,4 +19,5 @@ if DEVISE_ORM == :mongo_id
|
|
19
19
|
assert_no_file "app/models/monster.rb"
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
23
|
+
|
@@ -2,13 +2,16 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class DeviseHelperTest < ActionController::IntegrationTest
|
4
4
|
setup do
|
5
|
+
model_labels = { :models => { :user => "utilisateur" } }
|
6
|
+
|
5
7
|
I18n.backend.store_translations :fr,
|
6
8
|
{
|
7
9
|
:errors => { :messages => { :not_saved => {
|
8
10
|
:one => "Erreur lors de l'enregistrement de '%{resource}': 1 erreur.",
|
9
11
|
:other => "Erreur lors de l'enregistrement de '%{resource}': %{count} erreurs."
|
10
12
|
} } },
|
11
|
-
:activerecord =>
|
13
|
+
:activerecord => model_labels,
|
14
|
+
:mongoid => model_labels
|
12
15
|
}
|
13
16
|
|
14
17
|
I18n.locale = 'fr'
|
@@ -30,6 +33,10 @@ class DeviseHelperTest < ActionController::IntegrationTest
|
|
30
33
|
end
|
31
34
|
|
32
35
|
test 'test errors.messages.not_saved with multiple errors from i18n' do
|
36
|
+
# Dirty tracking behavior prevents email validations from being applied:
|
37
|
+
# https://github.com/mongoid/mongoid/issues/756
|
38
|
+
(pending "Fails on Mongoid < 2.1"; break) if defined?(Mongoid) && Mongoid::VERSION.to_f < 2.1
|
39
|
+
|
33
40
|
get new_user_registration_path
|
34
41
|
|
35
42
|
fill_in 'email', :with => 'invalid_email'
|
@@ -40,4 +47,5 @@ class DeviseHelperTest < ActionController::IntegrationTest
|
|
40
47
|
assert_have_selector '#error_explanation'
|
41
48
|
assert_contain "Erreur lors de l'enregistrement de 'utilisateur': 2 erreurs"
|
42
49
|
end
|
43
|
-
end
|
50
|
+
end
|
51
|
+
|
@@ -454,6 +454,23 @@ class AuthenticationOthersTest < ActionController::IntegrationTest
|
|
454
454
|
end
|
455
455
|
end
|
456
456
|
|
457
|
+
class AuthenticationKeysTest < ActionController::IntegrationTest
|
458
|
+
test 'missing authentication keys cause authentication to abort' do
|
459
|
+
swap Devise, :authentication_keys => [:subdomain] do
|
460
|
+
sign_in_as_user
|
461
|
+
assert_contain "Invalid email or password."
|
462
|
+
assert_not warden.authenticated?(:user)
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
test 'missing authentication keys cause authentication to abort unless marked as not required' do
|
467
|
+
swap Devise, :authentication_keys => { :email => true, :subdomain => false } do
|
468
|
+
sign_in_as_user
|
469
|
+
assert warden.authenticated?(:user)
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
457
474
|
class AuthenticationRequestKeysTest < ActionController::IntegrationTest
|
458
475
|
test 'request keys are used on authentication' do
|
459
476
|
host! 'foo.bar.baz'
|
@@ -37,6 +37,15 @@ class ConfirmationTest < ActionController::IntegrationTest
|
|
37
37
|
assert user.reload.confirmed?
|
38
38
|
end
|
39
39
|
|
40
|
+
test 'user should be redirected to a custom path after confirmation' do
|
41
|
+
Devise::ConfirmationsController.any_instance.stubs(:after_confirmation_path_for).returns("/?custom=1")
|
42
|
+
|
43
|
+
user = create_user(:confirm => false)
|
44
|
+
visit_user_confirmation_with_token(user.confirmation_token)
|
45
|
+
|
46
|
+
assert_current_url "/?custom=1"
|
47
|
+
end
|
48
|
+
|
40
49
|
test 'already confirmed user should not be able to confirm the account again' do
|
41
50
|
user = create_user(:confirm => false)
|
42
51
|
user.confirmed_at = Time.now
|
@@ -60,7 +69,7 @@ class ConfirmationTest < ActionController::IntegrationTest
|
|
60
69
|
assert_contain 'already confirmed'
|
61
70
|
end
|
62
71
|
|
63
|
-
test 'sign in user automatically after confirming
|
72
|
+
test 'sign in user automatically after confirming its email' do
|
64
73
|
user = create_user(:confirm => false)
|
65
74
|
visit_user_confirmation_with_token(user.confirmation_token)
|
66
75
|
|
@@ -73,7 +73,7 @@ class LockTest < ActionController::IntegrationTest
|
|
73
73
|
assert_not user.reload.access_locked?
|
74
74
|
end
|
75
75
|
|
76
|
-
test "sign in user automatically after unlocking
|
76
|
+
test "sign in user automatically after unlocking its account" do
|
77
77
|
user = create_user(:locked => true)
|
78
78
|
visit_user_unlock_with_token(user.unlock_token)
|
79
79
|
assert warden.authenticated?(:user)
|
@@ -166,7 +166,7 @@ class PasswordTest < ActionController::IntegrationTest
|
|
166
166
|
assert user.reload.valid_password?('987654321')
|
167
167
|
end
|
168
168
|
|
169
|
-
test 'sign in user automatically after changing
|
169
|
+
test 'sign in user automatically after changing its password' do
|
170
170
|
user = create_user
|
171
171
|
request_forgot_password
|
172
172
|
reset_password :reset_password_token => user.reload.reset_password_token
|
@@ -174,8 +174,8 @@ class PasswordTest < ActionController::IntegrationTest
|
|
174
174
|
assert warden.authenticated?(:user)
|
175
175
|
end
|
176
176
|
|
177
|
-
test 'does not sign in user automatically after changing
|
178
|
-
user = create_user(:
|
177
|
+
test 'does not sign in user automatically after changing its password if it\'s locked' do
|
178
|
+
user = create_user(:locked => true)
|
179
179
|
request_forgot_password
|
180
180
|
reset_password :reset_password_token => user.reload.reset_password_token
|
181
181
|
|
@@ -183,6 +183,15 @@ class PasswordTest < ActionController::IntegrationTest
|
|
183
183
|
assert !warden.authenticated?(:user)
|
184
184
|
end
|
185
185
|
|
186
|
+
test 'sign in user automatically and confirm after changing its password if it\'s not confirmed' do
|
187
|
+
user = create_user(:confirm => false)
|
188
|
+
request_forgot_password
|
189
|
+
reset_password :reset_password_token => user.reload.reset_password_token
|
190
|
+
|
191
|
+
assert warden.authenticated?(:user)
|
192
|
+
assert user.reload.confirmed?
|
193
|
+
end
|
194
|
+
|
186
195
|
test 'reset password request with valid E-Mail in XML format should return valid response' do
|
187
196
|
create_user
|
188
197
|
post user_password_path(:format => 'xml'), :user => {:email => "user@test.com"}
|
@@ -69,6 +69,10 @@ class RegistrationTest < ActionController::IntegrationTest
|
|
69
69
|
end
|
70
70
|
|
71
71
|
test 'a guest user cannot sign up with invalid information' do
|
72
|
+
# Dirty tracking behavior prevents email validations from being applied:
|
73
|
+
# https://github.com/mongoid/mongoid/issues/756
|
74
|
+
(pending "Fails on Mongoid < 2.1"; break) if defined?(Mongoid) && Mongoid::VERSION.to_f < 2.1
|
75
|
+
|
72
76
|
get new_user_registration_path
|
73
77
|
|
74
78
|
fill_in 'email', :with => 'invalid_email'
|
@@ -87,6 +91,10 @@ class RegistrationTest < ActionController::IntegrationTest
|
|
87
91
|
end
|
88
92
|
|
89
93
|
test 'a guest should not sign up with email/password that already exists' do
|
94
|
+
# Dirty tracking behavior prevents email validations from being applied:
|
95
|
+
# https://github.com/mongoid/mongoid/issues/756
|
96
|
+
(pending "Fails on Mongoid < 2.1"; break) if defined?(Mongoid) && Mongoid::VERSION.to_f < 2.1
|
97
|
+
|
90
98
|
user = create_user
|
91
99
|
get new_user_registration_path
|
92
100
|
|
@@ -211,14 +219,14 @@ class RegistrationTest < ActionController::IntegrationTest
|
|
211
219
|
get new_user_registration_path(:format => 'xml')
|
212
220
|
assert_response :success
|
213
221
|
assert_match %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>), response.body
|
214
|
-
assert_no_match(/<confirmation-token/, response.body)
|
222
|
+
assert_no_match(/<confirmation-token/, response.body)
|
215
223
|
end
|
216
224
|
|
217
225
|
test 'a user with JSON sign up stub' do
|
218
226
|
get new_user_registration_path(:format => 'json')
|
219
227
|
assert_response :success
|
220
228
|
assert_match %({"user":), response.body
|
221
|
-
assert_no_match(/"confirmation_token"/, response.body)
|
229
|
+
assert_no_match(/"confirmation_token"/, response.body)
|
222
230
|
end
|
223
231
|
|
224
232
|
test 'an admin sign up with valid information in XML format should return valid response' do
|
@@ -13,6 +13,17 @@ class TokenAuthenticationTest < ActionController::IntegrationTest
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
test 'authenticate with valid authentication token key and value through params, when params with the same key as scope exist' do
|
17
|
+
swap Devise, :token_authentication_key => :secret_token do
|
18
|
+
user = create_user_with_authentication_token
|
19
|
+
post exhibit_user_path(user), Devise.token_authentication_key => user.authentication_token, :user => { :some => "data" }
|
20
|
+
|
21
|
+
assert_response :success
|
22
|
+
assert_contain 'User is authenticated'
|
23
|
+
assert warden.authenticated?(:user)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
16
27
|
test 'authenticate with valid authentication token key but does not store if stateless' do
|
17
28
|
swap Devise, :token_authentication_key => :secret_token, :stateless_token => true do
|
18
29
|
sign_in_as_new_user_with_token
|
@@ -4,6 +4,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
setup_mailer
|
7
|
+
Devise.mailer = 'Devise::Mailer'
|
7
8
|
Devise.mailer_sender = 'test@example.com'
|
8
9
|
end
|
9
10
|
|
@@ -35,6 +36,11 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
|
35
36
|
assert_equal ['test@example.com'], mail.from
|
36
37
|
end
|
37
38
|
|
39
|
+
test 'setup sender from custom mailer defaults' do
|
40
|
+
Devise.mailer = 'Users::Mailer'
|
41
|
+
assert_equal ['custom@example.com'], mail.from
|
42
|
+
end
|
43
|
+
|
38
44
|
test 'setup reply to as copy from sender' do
|
39
45
|
assert_equal ['test@example.com'], mail.reply_to
|
40
46
|
end
|
@@ -4,6 +4,7 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
setup_mailer
|
7
|
+
Devise.mailer = 'Devise::Mailer'
|
7
8
|
Devise.mailer_sender = 'test@example.com'
|
8
9
|
end
|
9
10
|
|
@@ -38,6 +39,11 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
|
38
39
|
assert_equal ['test@example.com'], mail.from
|
39
40
|
end
|
40
41
|
|
42
|
+
test 'setup sender from custom mailer defaults' do
|
43
|
+
Devise.mailer = 'Users::Mailer'
|
44
|
+
assert_equal ['custom@example.com'], mail.from
|
45
|
+
end
|
46
|
+
|
41
47
|
test 'setup reply to as copy from sender' do
|
42
48
|
assert_equal ['test@example.com'], mail.reply_to
|
43
49
|
end
|
@@ -4,6 +4,7 @@ class UnlockInstructionsTest < ActionMailer::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
setup_mailer
|
7
|
+
Devise.mailer = 'Devise::Mailer'
|
7
8
|
Devise.mailer_sender = 'test@example.com'
|
8
9
|
end
|
9
10
|
|
@@ -38,6 +39,11 @@ class UnlockInstructionsTest < ActionMailer::TestCase
|
|
38
39
|
assert_equal ['test@example.com'], mail.from
|
39
40
|
end
|
40
41
|
|
42
|
+
test 'setup sender from custom mailer defaults' do
|
43
|
+
Devise.mailer = 'Users::Mailer'
|
44
|
+
assert_equal ['custom@example.com'], mail.from
|
45
|
+
end
|
46
|
+
|
41
47
|
test 'setup reply to as copy from sender' do
|
42
48
|
assert_equal ['test@example.com'], mail.reply_to
|
43
49
|
end
|
@@ -121,7 +121,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
121
121
|
assert_equal "not found", confirmation_user.errors[:email].join
|
122
122
|
end
|
123
123
|
|
124
|
-
test 'should send email instructions for the user confirm
|
124
|
+
test 'should send email instructions for the user confirm its email' do
|
125
125
|
user = create_user
|
126
126
|
assert_email_sent do
|
127
127
|
User.send_confirmation_instructions(:email => user.email)
|
@@ -219,7 +219,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
219
219
|
assert user.reload.active_for_authentication?
|
220
220
|
end
|
221
221
|
|
222
|
-
test 'should find a user to send email instructions for the user confirm
|
222
|
+
test 'should find a user to send email instructions for the user confirm its email by authentication_keys' do
|
223
223
|
swap Devise, :authentication_keys => [:username, :email] do
|
224
224
|
user = create_user
|
225
225
|
confirm_user = User.send_confirmation_instructions(:email => user.email, :username => user.username)
|
@@ -31,8 +31,10 @@ class EncryptableTest < ActiveSupport::TestCase
|
|
31
31
|
|
32
32
|
test 'should generate a base64 hash using SecureRandom for password salt' do
|
33
33
|
swap_with_encryptor Admin, :sha1 do
|
34
|
-
SecureRandom.expects(:base64).with(15).returns('
|
35
|
-
|
34
|
+
SecureRandom.expects(:base64).with(15).returns('01lI')
|
35
|
+
salt = create_admin.password_salt
|
36
|
+
assert_not_equal '01lI', salt
|
37
|
+
assert_equal 4, salt.size
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
require 'test_helper'
|
2
3
|
|
3
4
|
class ValidatableTest < ActiveSupport::TestCase
|
@@ -28,7 +29,7 @@ class ValidatableTest < ActiveSupport::TestCase
|
|
28
29
|
assert user.invalid?
|
29
30
|
assert_not_equal 'is invalid', user.errors[:email].join
|
30
31
|
|
31
|
-
%w
|
32
|
+
%w{invalid_email_format 123 $$$ () ☃ bla@bla.}.each do |email|
|
32
33
|
user.email = email
|
33
34
|
assert user.invalid?, 'should be invalid with email ' << email
|
34
35
|
assert_equal 'is invalid', user.errors[:email].join
|
@@ -39,7 +40,7 @@ class ValidatableTest < ActiveSupport::TestCase
|
|
39
40
|
end
|
40
41
|
|
41
42
|
test 'should accept valid emails' do
|
42
|
-
%w(a.b.c@example.com test_mail@gmail.com any@any.net email@test.br 123@mail.test).each do |email|
|
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|
|
43
44
|
user = new_user(:email => email)
|
44
45
|
assert user.valid?, 'should be valid with email ' << email
|
45
46
|
assert_blank user.errors[:email]
|
data/test/models_test.rb
CHANGED
@@ -42,18 +42,16 @@ class ActiveRecordTest < ActiveSupport::TestCase
|
|
42
42
|
assert_include_modules Admin, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :rememberable, :encryptable
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
45
|
+
test 'validations options are not applied too late' do
|
46
|
+
validators = WithValidation.validators_on :password
|
47
|
+
length = validators.find { |v| v.kind == :length }
|
48
|
+
assert_equal 2, length.options[:minimum]
|
49
|
+
assert_equal 6, length.options[:maximum]
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
52
|
+
test 'validations are applied just once' do
|
53
|
+
validators = Several.validators_on :password
|
54
|
+
assert_equal 1, validators.select{ |v| v.kind == :length }.length
|
57
55
|
end
|
58
56
|
|
59
57
|
test 'chosen modules are inheritable' do
|
data/test/orm/mongoid.rb
CHANGED
@@ -21,9 +21,4 @@ module Shim
|
|
21
21
|
def ==(other)
|
22
22
|
other.is_a?(self.class) && _id == other._id
|
23
23
|
end
|
24
|
-
|
25
|
-
# Mongoid does not have this method in the current beta version (2.0.0.beta.20)
|
26
|
-
def update_attribute(attribute, value)
|
27
|
-
update_attributes(attribute => value)
|
28
|
-
end
|
29
24
|
end
|