summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2018-01-31 11:39:03 -0600
committerDouwe Maan <douwe@selenight.nl>2018-02-06 12:09:03 -0600
commita03d29da1dbbef3c202899cef3cd89b453a8b76f (patch)
tree83f08b67027f9169eac9dfbc6a4c19f1752ad9ff /spec/models/user_spec.rb
parent75144b1e03db342730535f1f49b0e7cd2987d755 (diff)
downloadgitlab-ce-a03d29da1dbbef3c202899cef3cd89b453a8b76f.tar.gz
Validate User username only on Namespace, and bubble up appropriately
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a52dc93befe..cb02d526a98 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -140,7 +140,19 @@ describe User do
user = build(:user, username: username)
expect(user).not_to be_valid
- expect(user.errors.messages[:"namespace.route.path"].first).to eq('foo has been taken before. Please use another one')
+ expect(user.errors.full_messages).to eq(['Username has been taken before'])
+ end
+ end
+
+ context 'when the username is in use by another user' do
+ let(:username) { 'foo' }
+ let!(:other_user) { create(:user, username: username) }
+
+ it 'is invalid' do
+ user = build(:user, username: username)
+
+ expect(user).not_to be_valid
+ expect(user.errors.full_messages).to eq(['Username has already been taken'])
end
end
end
@@ -2634,7 +2646,7 @@ describe User do
it 'should raise an ActiveRecord::RecordInvalid exception' do
user2 = build(:user, username: 'foo')
- expect { user2.save! }.to raise_error(ActiveRecord::RecordInvalid, /Namespace route path foo has been taken before/)
+ expect { user2.save! }.to raise_error(ActiveRecord::RecordInvalid, /Username has been taken before/)
end
end