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:
authorAndreas Brandl <abrandl@gitlab.com>2019-04-05 14:29:19 +0300
committerAndreas Brandl <abrandl@gitlab.com>2019-04-05 14:29:19 +0300
commit30fa3cbdb74df2dfeebb2929a10dd301a0dde55e (patch)
tree72b5a7d8d615475ea2b8afabbfcebe1402c96d52 /spec/migrations
parent14cf8bf050896d617761e7947f81c8e23364a48b (diff)
parentebfe19e8e7690598f86facc0bb18df4052468fc0 (diff)
Merge branch '57493-add-limit-to-user-name' into 'master'
Add a length limit of 128 char to the user name field See merge request gitlab-org/gitlab-ce!26146
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/truncate_user_fullname_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/migrations/truncate_user_fullname_spec.rb b/spec/migrations/truncate_user_fullname_spec.rb
new file mode 100644
index 00000000000..17fd4d9f688
--- /dev/null
+++ b/spec/migrations/truncate_user_fullname_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper'
+require Rails.root.join('db', 'migrate', '20190325080727_truncate_user_fullname.rb')
+
+describe TruncateUserFullname, :migration do
+ let(:users) { table(:users) }
+
+ let(:user_short) { create_user(name: 'abc', email: 'test_short@example.com') }
+ let(:user_long) { create_user(name: 'a' * 200 + 'z', email: 'test_long@example.com') }
+
+ def create_user(params)
+ users.create!(params.merge(projects_limit: 0))
+ end
+
+ it 'truncates user full name to the first 128 characters' do
+ expect { migrate! }.to change { user_long.reload.name }.to('a' * 128)
+ end
+
+ it 'does not truncate short names' do
+ expect { migrate! }.not_to change { user_short.reload.name.length }
+ end
+end