2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
RSpec.describe GraphqlTriggers, feature_category: :shared do
|
2023-01-13 00:05:48 +05:30
|
|
|
let_it_be(:issuable, refind: true) { create(:work_item) }
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
describe '.issuable_assignees_updated' do
|
2023-01-13 00:05:48 +05:30
|
|
|
let(:assignees) { create_list(:user, 2) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
before do
|
|
|
|
issuable.update!(assignees: assignees)
|
|
|
|
end
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the issuable_assignees_updated subscription' do
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:issuable_assignees_updated,
|
2023-01-13 00:05:48 +05:30
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2021-06-08 01:23:25 +05:30
|
|
|
)
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
GraphqlTriggers.issuable_assignees_updated(issuable)
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
|
|
|
|
describe '.issuable_title_updated' do
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the issuable_title_updated subscription' do
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:issuable_title_updated,
|
2023-01-13 00:05:48 +05:30
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-04-04 11:22:00 +05:30
|
|
|
).and_call_original
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
GraphqlTriggers.issuable_title_updated(issuable)
|
2022-04-04 11:22:00 +05:30
|
|
|
end
|
|
|
|
end
|
2022-06-21 17:19:12 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
describe '.issuable_description_updated' do
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the issuable_description_updated subscription' do
|
2022-11-25 23:54:43 +05:30
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:issuable_description_updated,
|
2023-01-13 00:05:48 +05:30
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-11-25 23:54:43 +05:30
|
|
|
).and_call_original
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
GraphqlTriggers.issuable_description_updated(issuable)
|
2022-11-25 23:54:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
describe '.issuable_labels_updated' do
|
2023-01-13 00:05:48 +05:30
|
|
|
let(:labels) { create_list(:label, 3, project: create(:project)) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
issuable.update!(labels: labels)
|
|
|
|
end
|
2022-06-21 17:19:12 +05:30
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the issuable_labels_updated subscription' do
|
2022-06-21 17:19:12 +05:30
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:issuable_labels_updated,
|
2023-01-13 00:05:48 +05:30
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-06-21 17:19:12 +05:30
|
|
|
)
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
GraphqlTriggers.issuable_labels_updated(issuable)
|
2022-06-21 17:19:12 +05:30
|
|
|
end
|
|
|
|
end
|
2022-08-27 11:52:29 +05:30
|
|
|
|
|
|
|
describe '.issuable_dates_updated' do
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the issuable_dates_updated subscription' do
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:issuable_dates_updated,
|
2023-01-13 00:05:48 +05:30
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
|
|
|
).and_call_original
|
|
|
|
|
|
|
|
GraphqlTriggers.issuable_dates_updated(issuable)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.issuable_milestone_updated' do
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the issuable_milestone_updated subscription' do
|
2023-01-13 00:05:48 +05:30
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:issuable_milestone_updated,
|
2023-01-13 00:05:48 +05:30
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-08-27 11:52:29 +05:30
|
|
|
).and_call_original
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
GraphqlTriggers.issuable_milestone_updated(issuable)
|
2022-08-27 11:52:29 +05:30
|
|
|
end
|
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
describe '.merge_request_reviewers_updated' do
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the merge_request_reviewers_updated subscription' do
|
2022-11-25 23:54:43 +05:30
|
|
|
merge_request = build_stubbed(:merge_request)
|
|
|
|
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:merge_request_reviewers_updated,
|
2022-11-25 23:54:43 +05:30
|
|
|
{ issuable_id: merge_request.to_gid },
|
|
|
|
merge_request
|
|
|
|
).and_call_original
|
|
|
|
|
|
|
|
GraphqlTriggers.merge_request_reviewers_updated(merge_request)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.merge_request_merge_status_updated' do
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the merge_request_merge_status_updated subscription' do
|
2022-11-25 23:54:43 +05:30
|
|
|
merge_request = build_stubbed(:merge_request)
|
|
|
|
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:merge_request_merge_status_updated,
|
2022-11-25 23:54:43 +05:30
|
|
|
{ issuable_id: merge_request.to_gid },
|
|
|
|
merge_request
|
|
|
|
).and_call_original
|
|
|
|
|
|
|
|
GraphqlTriggers.merge_request_merge_status_updated(merge_request)
|
|
|
|
end
|
2023-06-20 00:43:36 +05:30
|
|
|
|
|
|
|
context 'when realtime_mr_status_change feature flag is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(realtime_mr_status_change: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not trigger realtime_mr_status_change subscription' do
|
|
|
|
merge_request = build_stubbed(:merge_request)
|
|
|
|
|
|
|
|
expect(GitlabSchema.subscriptions).not_to receive(:trigger)
|
|
|
|
|
|
|
|
GraphqlTriggers.merge_request_merge_status_updated(merge_request)
|
|
|
|
end
|
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
end
|
2023-03-04 22:38:38 +05:30
|
|
|
|
|
|
|
describe '.merge_request_approval_state_updated' do
|
2023-06-20 00:43:36 +05:30
|
|
|
it 'triggers the merge_request_approval_state_updated subscription' do
|
2023-03-04 22:38:38 +05:30
|
|
|
merge_request = build_stubbed(:merge_request)
|
|
|
|
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
2023-06-20 00:43:36 +05:30
|
|
|
:merge_request_approval_state_updated,
|
2023-03-04 22:38:38 +05:30
|
|
|
{ issuable_id: merge_request.to_gid },
|
|
|
|
merge_request
|
|
|
|
).and_call_original
|
|
|
|
|
|
|
|
GraphqlTriggers.merge_request_approval_state_updated(merge_request)
|
|
|
|
end
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|