diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-06-08 15:22:01 +0200 |
---|---|---|
committer | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-06-08 09:22:01 -0400 |
commit | c207b4bb330463c39c202d1c66e2447b55332093 (patch) | |
tree | 932150591bd43dc2c4b3490f9be29132911b1bf6 /spec | |
parent | b87eb8ea146a54fcfd2533f47622070d0f30a9fa (diff) |
Fix db:seed - only run some validations when the field was changed (#3592)
* Fix db:seed - only run some validations when the field was changed * Add tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/account_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index ab4de9aa1..73ae34f8e 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -387,6 +387,12 @@ RSpec.describe Account, type: :model do expect(account).to model_have_error_on_field(:username) end + it 'is valid when username is reserved but record has already been created' do + account = Fabricate.build(:account, username: 'support') + account.save(validate: false) + expect(account.valid?).to be true + end + context 'when is local' do it 'is invalid if the username doesn\'t only contains letters, numbers and underscores' do account = Fabricate.build(:account, username: 'the-doctor') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 13a60f668..a6df3fb26 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -34,6 +34,12 @@ RSpec.describe User, type: :model do expect(user).to model_have_error_on_field(:email) end + it 'is valid with an invalid e-mail that has already been saved' do + user = Fabricate.build(:user, email: 'invalid-email') + user.save(validate: false) + expect(user.valid?).to be true + end + it 'cleans out empty string from languages' do user = Fabricate.build(:user, filtered_languages: ['']) user.valid? |