diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-19 12:06:00 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-19 12:06:00 +0000 |
commit | b570d73ecd31e2ca9cf8c2f1adb056edf2869477 (patch) | |
tree | 0b8aa67eab6da552d8499f1fdcf9a7495dcf1379 /spec/migrations | |
parent | 34b3567c97ecc0f317adae04e10e4d7d8c8830db (diff) | |
download | gitlab-ce-b570d73ecd31e2ca9cf8c2f1adb056edf2869477.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/nullify_users_role_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/migrations/nullify_users_role_spec.rb b/spec/migrations/nullify_users_role_spec.rb new file mode 100644 index 00000000000..ad25e4885ef --- /dev/null +++ b/spec/migrations/nullify_users_role_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20191104142124_nullify_users_role.rb') + +describe NullifyUsersRole, :migration do + let(:users) { table(:users) } + + before do + allow(Gitlab).to receive(:com?).and_return(true) + + users.create!(role: 0, updated_at: '2019-11-04 12:08:00', projects_limit: 0, email: '1') + users.create!(role: 1, updated_at: '2019-11-04 12:08:00', projects_limit: 0, email: '2') + users.create!(role: 0, updated_at: '2019-11-06 12:08:00', projects_limit: 0, email: '3') + + migrate! + end + + it 'nullifies the role of the user with updated_at < 2019-11-05 12:08:00 and a role of 0' do + expect(users.where(role: nil).count).to eq(1) + expect(users.where(role: nil).first.email).to eq('1') + end + + it 'leaves the user with role of 1' do + expect(users.where(role: 1).count).to eq(1) + expect(users.where(role: 1).first.email).to eq('2') + end + + it 'leaves the user with updated_at > 2019-11-05 12:08:00' do + expect(users.where(role: 0).count).to eq(1) + expect(users.where(role: 0).first.email).to eq('3') + end +end |