diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-17 00:11:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-17 00:11:02 +0300 |
commit | 587b778d3eaa04e18b3b8e2ecc290156e3e1f93e (patch) | |
tree | e879a35a8bbab4cb89395c885460a731a4a1645a /spec/migrations/orphaned_invite_tokens_cleanup_spec.rb | |
parent | e684f438e60b801b4eb8b19dd9489dce84503c03 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations/orphaned_invite_tokens_cleanup_spec.rb')
-rw-r--r-- | spec/migrations/orphaned_invite_tokens_cleanup_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/migrations/orphaned_invite_tokens_cleanup_spec.rb b/spec/migrations/orphaned_invite_tokens_cleanup_spec.rb new file mode 100644 index 00000000000..889c04700c7 --- /dev/null +++ b/spec/migrations/orphaned_invite_tokens_cleanup_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! 'orphaned_invite_tokens_cleanup' + +RSpec.describe OrphanedInviteTokensCleanup, :migration do + def create_member(**extra_attributes) + defaults = { + access_level: 10, + source_id: 1, + source_type: "Project", + notification_level: 0, + type: 'ProjectMember' + } + + table(:members).create!(defaults.merge(extra_attributes)) + end + + describe '#up', :aggregate_failures do + it 'removes invite tokens for accepted records with invite_accepted_at < created_at' do + record1 = create_member(invite_token: 'foo', invite_accepted_at: 1.day.ago, created_at: 1.hour.ago) + record2 = create_member(invite_token: 'foo2', invite_accepted_at: nil, created_at: 1.hour.ago) + record3 = create_member(invite_token: 'foo3', invite_accepted_at: 1.day.ago, created_at: 1.year.ago) + + migrate! + + expect(table(:members).find(record1.id).invite_token).to eq nil + expect(table(:members).find(record2.id).invite_token).to eq 'foo2' + expect(table(:members).find(record3.id).invite_token).to eq 'foo3' + end + end +end |