-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b38fef5
commit d414a5e
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -366,6 +366,42 @@ def setup | |
User.validate_on_invite = validate_on_invite | ||
end | ||
|
||
test 'should not validate other attributes when validate_on_invite is disabled (for instance method)' do | ||
validate_on_invite = User.validate_on_invite | ||
User.validate_on_invite = false | ||
user = new_user(email: '[email protected]', username: 'a' * 50) | ||
user.invite!(nil, validate: false) | ||
assert_empty user.errors | ||
User.validate_on_invite = validate_on_invite | ||
end | ||
|
||
test 'should validate other attributes when validate_on_invite is disabled and validate option is enabled (for instance method)' do | ||
validate_on_invite = User.validate_on_invite | ||
User.validate_on_invite = false | ||
user = new_user(email: '[email protected]', username: 'a' * 50) | ||
user.invite!(nil, validate: true) | ||
refute_empty user.errors[:username] | ||
User.validate_on_invite = validate_on_invite | ||
end | ||
|
||
test 'should validate other attributes when validate_on_invite is enabled and validate option is disabled (for instance method)' do | ||
validate_on_invite = User.validate_on_invite | ||
User.validate_on_invite = true | ||
user = new_user(email: '[email protected]', username: 'a' * 50) | ||
user.invite! | ||
refute_empty user.errors[:username] | ||
User.validate_on_invite = validate_on_invite | ||
end | ||
|
||
test 'should validate other attributes when validate_on_invite is enabled and validate option is disabled explicitly (for instance method)' do | ||
validate_on_invite = User.validate_on_invite | ||
User.validate_on_invite = true | ||
user = new_user(email: '[email protected]', username: 'a' * 50) | ||
user.invite!(nil, validate: false) | ||
assert_empty user.errors | ||
User.validate_on_invite = validate_on_invite | ||
end | ||
|
||
test 'should return a record with errors if user was found by e-mail' do | ||
existing_user = User.new(email: '[email protected]') | ||
existing_user.save(validate: false) | ||
|