Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for 2.0.6 #892

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test/models/invitable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: 'valid@email.com', 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: 'valid@email.com', 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: 'valid@email.com', 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: 'valid@email.com', 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: 'valid@email.com')
existing_user.save(validate: false)
Expand Down