2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe IssueLinks::CreateService, feature_category: :team_planning do
|
2020-11-24 15:15:51 +05:30
|
|
|
describe '#execute' do
|
2022-05-07 20:08:51 +05:30
|
|
|
let_it_be(:user) { create :user }
|
|
|
|
let_it_be(:namespace) { create :namespace }
|
|
|
|
let_it_be(:project) { create :project, namespace: namespace }
|
|
|
|
let_it_be(:issuable) { create :issue, project: project }
|
|
|
|
let_it_be(:issuable2) { create :issue, project: project }
|
2023-03-17 16:20:25 +05:30
|
|
|
let_it_be(:restricted_issuable) { create :issue }
|
2022-05-07 20:08:51 +05:30
|
|
|
let_it_be(:another_project) { create :project, namespace: project.namespace }
|
|
|
|
let_it_be(:issuable3) { create :issue, project: another_project }
|
|
|
|
let_it_be(:issuable_a) { create :issue, project: project }
|
|
|
|
let_it_be(:issuable_b) { create :issue, project: project }
|
|
|
|
let_it_be(:issuable_link) { create :issue_link, source: issuable, target: issuable_b, link_type: IssueLink::TYPE_RELATES_TO }
|
|
|
|
|
|
|
|
let(:issuable_parent) { issuable.project }
|
|
|
|
let(:issuable_type) { :issue }
|
|
|
|
let(:issuable_link_class) { IssueLink }
|
|
|
|
let(:params) { {} }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
2023-03-17 16:20:25 +05:30
|
|
|
restricted_issuable.project.add_guest(user)
|
2022-05-07 20:08:51 +05:30
|
|
|
another_project.add_developer(user)
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it_behaves_like 'issuable link creation'
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
context 'when target is an incident' do
|
|
|
|
let_it_be(:issue) { create(:incident, project: project) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
let(:params) do
|
2022-05-07 20:08:51 +05:30
|
|
|
{ issuable_references: [issuable2.to_reference, issuable3.to_reference(another_project)] }
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
subject { described_class.new(issue, user, params).execute }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it_behaves_like 'an incident management tracked event', :incident_management_incident_relate do
|
|
|
|
let(:current_user) { user }
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
2023-03-04 22:38:38 +05:30
|
|
|
|
|
|
|
it_behaves_like 'Snowplow event tracking with RedisHLL context' do
|
|
|
|
let(:namespace) { issue.namespace }
|
|
|
|
let(:category) { described_class.to_s }
|
|
|
|
let(:action) { 'incident_management_incident_relate' }
|
|
|
|
let(:label) { 'redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly' }
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|