summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-02-29 17:17:14 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-02-29 17:19:53 -0500
commit58a8d6e9ba783d26ebdc6d79b2c457e2721988e8 (patch)
tree986f0dbeaa8708b8325ea0503f6e1e299df30505 /spec/models
parent128757a7f97b3dc0bf2efd4fac49dc0eaa0af04c (diff)
downloadgitlab-ce-58a8d6e9ba783d26ebdc6d79b2c457e2721988e8.tar.gz
Only validate avatar cropping values when avatar is present AND changedrs-avatar-validation
Closes #13905
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/user_spec.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 88821dd0dad..b2a398348b8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -176,7 +176,7 @@ describe User, models: true do
end
describe 'avatar' do
- it 'only validates when avatar is present' do
+ it 'only validates when avatar is present and changed' do
user = build(:user, :with_avatar)
user.avatar_crop_x = nil
@@ -184,6 +184,20 @@ describe User, models: true do
user.avatar_crop_size = nil
expect(user).not_to be_valid
+ expect(user.errors.keys).
+ to match_array %i(avatar_crop_x avatar_crop_y avatar_crop_size)
+ end
+
+ it 'does not validate when avatar has not changed' do
+ user = create(:user, :with_avatar)
+
+ expect { user.avatar_crop_x = nil }.not_to change(user, :valid?)
+ end
+
+ it 'does not validate when avatar is not present' do
+ user = create(:user)
+
+ expect { user.avatar_crop_y = nil }.not_to change(user, :valid?)
end
end
end