summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorBrandon Labuschagne <blabuschagne@gitlab.com>2019-03-14 12:32:07 +0200
committerBrandon Labuschagne <blabuschagne@gitlab.com>2019-04-05 09:35:34 +0200
commitebfe19e8e7690598f86facc0bb18df4052468fc0 (patch)
tree895c9eff8dec2e7d2a93672d15a148503a6b5d4e /spec/migrations
parentb54228ad3d79dc0bd7060128e0b75f68cd1c51d9 (diff)
downloadgitlab-ce-ebfe19e8e7690598f86facc0bb18df4052468fc0.tar.gz
Add limit of 128 characters to users name57493-add-limit-to-user-name
Truncate existing users names which exceed 128 characters Include test for truncating users names
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