diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-03-01 16:03:38 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-03-01 16:03:38 +0000 |
commit | ad9137a785910e825067182409db040f67f5a63c (patch) | |
tree | 9df87ec60213c70ed466e56b2c05896e3c678e0f /spec | |
parent | acd9881061a3196d1ed869448ea6c321301f9ac7 (diff) | |
parent | 58a8d6e9ba783d26ebdc6d79b2c457e2721988e8 (diff) | |
download | gitlab-ce-ad9137a785910e825067182409db040f67f5a63c.tar.gz |
Merge branch 'rs-avatar-validation' into 'master'
Only validate avatar cropping values when avatar is present AND changed
Closes #13905
See merge request !3018
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/user_spec.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7ad7aab2eec..412101ac9f9 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 |