2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe IssueLink do
|
2022-05-07 20:08:51 +05:30
|
|
|
it_behaves_like 'issuable link' do
|
|
|
|
let_it_be_with_reload(:issuable_link) { create(:issue_link) }
|
|
|
|
let_it_be(:issuable) { create(:issue) }
|
|
|
|
let(:issuable_class) { 'Issue' }
|
|
|
|
let(:issuable_link_factory) { :issue_link }
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
describe '.issuable_type' do
|
|
|
|
it { expect(described_class.issuable_type).to eq(:issue) }
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
describe 'Scopes' do
|
|
|
|
let_it_be(:issue1) { create(:issue) }
|
|
|
|
let_it_be(:issue2) { create(:issue) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
describe '.for_source_issue' do
|
|
|
|
it 'includes linked issues for source issue' do
|
|
|
|
source_issue = create(:issue)
|
|
|
|
issue_link_1 = create(:issue_link, source: source_issue, target: issue1)
|
|
|
|
issue_link_2 = create(:issue_link, source: source_issue, target: issue2)
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
result = described_class.for_source_issue(source_issue)
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(result).to contain_exactly(issue_link_1, issue_link_2)
|
|
|
|
end
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
describe '.for_target_issue' do
|
|
|
|
it 'includes linked issues for target issue' do
|
|
|
|
target_issue = create(:issue)
|
|
|
|
issue_link_1 = create(:issue_link, source: issue1, target: target_issue)
|
|
|
|
issue_link_2 = create(:issue_link, source: issue2, target: target_issue)
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
result = described_class.for_target_issue(target_issue)
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(result).to contain_exactly(issue_link_1, issue_link_2)
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|