diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/lib/gitlab/background_migration/replace_blocked_by_links_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/lib/gitlab/background_migration/replace_blocked_by_links_spec.rb')
-rw-r--r-- | spec/lib/gitlab/background_migration/replace_blocked_by_links_spec.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/spec/lib/gitlab/background_migration/replace_blocked_by_links_spec.rb b/spec/lib/gitlab/background_migration/replace_blocked_by_links_spec.rb index fa4f2d1fd88..561a602fab9 100644 --- a/spec/lib/gitlab/background_migration/replace_blocked_by_links_spec.rb +++ b/spec/lib/gitlab/background_migration/replace_blocked_by_links_spec.rb @@ -9,28 +9,34 @@ RSpec.describe Gitlab::BackgroundMigration::ReplaceBlockedByLinks, schema: 20201 let(:issue2) { table(:issues).create!(project_id: project.id, title: 'b') } let(:issue3) { table(:issues).create!(project_id: project.id, title: 'c') } let(:issue_links) { table(:issue_links) } - let!(:blocks_link) { issue_links.create!(source_id: issue1.id, target_id: issue2.id, link_type: 1) } - let!(:bidirectional_link) { issue_links.create!(source_id: issue2.id, target_id: issue1.id, link_type: 2) } - let!(:blocked_link) { issue_links.create!(source_id: issue1.id, target_id: issue3.id, link_type: 2) } + let!(:blocked_link1) { issue_links.create!(source_id: issue2.id, target_id: issue1.id, link_type: 2) } + let!(:opposite_link1) { issue_links.create!(source_id: issue1.id, target_id: issue2.id, link_type: 1) } + let!(:blocked_link2) { issue_links.create!(source_id: issue1.id, target_id: issue3.id, link_type: 2) } + let!(:opposite_link2) { issue_links.create!(source_id: issue3.id, target_id: issue1.id, link_type: 0) } + let!(:nochange_link) { issue_links.create!(source_id: issue2.id, target_id: issue3.id, link_type: 1) } subject { described_class.new.perform(issue_links.minimum(:id), issue_links.maximum(:id)) } - it 'deletes issue links where opposite relation already exists' do - expect { subject }.to change { issue_links.count }.by(-1) + it 'deletes any opposite relations' do + subject + + expect(issue_links.ids).to match_array([nochange_link.id, blocked_link1.id, blocked_link2.id]) end it 'ignores issue links other than blocked_by' do subject - expect(blocks_link.reload.link_type).to eq(1) + expect(nochange_link.reload.link_type).to eq(1) end it 'updates blocked_by issue links' do subject - link = blocked_link.reload - expect(link.link_type).to eq(1) - expect(link.source_id).to eq(issue3.id) - expect(link.target_id).to eq(issue1.id) + expect(blocked_link1.reload.link_type).to eq(1) + expect(blocked_link1.source_id).to eq(issue1.id) + expect(blocked_link1.target_id).to eq(issue2.id) + expect(blocked_link2.reload.link_type).to eq(1) + expect(blocked_link2.source_id).to eq(issue3.id) + expect(blocked_link2.target_id).to eq(issue1.id) end end |