mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-29 08:16:58 +00:00
Simplify model validation specs for User
This commit is contained in:
parent
a1ac2a73ff
commit
f930788b6c
|
@ -33,26 +33,20 @@ RSpec.describe User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'Associations' do
|
||||||
it { is_expected.to belong_to(:account).required }
|
it { is_expected.to belong_to(:account).required }
|
||||||
|
|
||||||
it 'is invalid without a valid email' do
|
|
||||||
user = Fabricate.build(:user, email: 'john@')
|
|
||||||
user.valid?
|
|
||||||
expect(user).to model_have_error_on_field(:email)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'Validations' do
|
||||||
|
it { is_expected.to_not allow_value('john@').for(:email) }
|
||||||
|
|
||||||
it 'is valid with an invalid e-mail that has already been saved' do
|
it 'is valid with an invalid e-mail that has already been saved' do
|
||||||
user = Fabricate.build(:user, email: 'invalid-email')
|
user = Fabricate.build(:user, email: 'invalid-email')
|
||||||
user.save(validate: false)
|
user.save(validate: false)
|
||||||
expect(user.valid?).to be true
|
expect(user.valid?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is valid with a localhost e-mail address' do
|
it { is_expected.to allow_value('admin@localhost').for(:email) }
|
||||||
user = Fabricate.build(:user, email: 'admin@localhost')
|
|
||||||
user.valid?
|
|
||||||
expect(user.valid?).to be true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'Normalizations' do
|
describe 'Normalizations' do
|
||||||
|
|
Loading…
Reference in a new issue