Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/user_detail_spec.rb')
-rw-r--r--spec/models/user_detail_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/user_detail_spec.rb b/spec/models/user_detail_spec.rb
index 04964d36dcd..ed55aca49b7 100644
--- a/spec/models/user_detail_spec.rb
+++ b/spec/models/user_detail_spec.rb
@@ -48,6 +48,23 @@ RSpec.describe UserDetail do
describe '#website_url' do
it { is_expected.to validate_length_of(:website_url).is_at_most(500) }
+
+ it 'only validates the website_url if it is changed' do
+ user_detail = create(:user_detail)
+ # `update_attribute` required to bypass current validations
+ # Validations on `User#website_url` were added after
+ # there was already data in the database and `UserDetail#website_url` is
+ # derived from `User#website_url` so this reproduces the state of some of
+ # our production data
+ user_detail.update_attribute(:website_url, 'NotAUrl')
+
+ expect(user_detail).to be_valid
+
+ user_detail.website_url = 'AlsoNotAUrl'
+
+ expect(user_detail).not_to be_valid
+ expect(user_detail.errors.full_messages).to match_array(["Website url is not a valid URL"])
+ end
end
end