2021-04-23 05:10:03 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe GraphqlTriggers do
|
2022-10-28 08:11:31 -04:00
|
|
|
let_it_be(:issuable, refind: true) { create(:work_item) }
|
|
|
|
|
2021-04-23 05:10:03 -04:00
|
|
|
describe '.issuable_assignees_updated' do
|
2022-10-28 08:11:31 -04:00
|
|
|
let(:assignees) { create_list(:user, 2) }
|
2021-04-23 05:10:03 -04:00
|
|
|
|
2022-10-28 08:11:31 -04:00
|
|
|
before do
|
|
|
|
issuable.update!(assignees: assignees)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'triggers the issuableAssigneesUpdated subscription' do
|
2021-04-23 05:10:03 -04:00
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'issuableAssigneesUpdated',
|
2022-10-28 08:11:31 -04:00
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2021-04-23 05:10:03 -04:00
|
|
|
)
|
|
|
|
|
2022-10-28 08:11:31 -04:00
|
|
|
GraphqlTriggers.issuable_assignees_updated(issuable)
|
2021-04-23 05:10:03 -04:00
|
|
|
end
|
|
|
|
end
|
2022-02-11 16:12:17 -05:00
|
|
|
|
|
|
|
describe '.issuable_title_updated' do
|
|
|
|
it 'triggers the issuableTitleUpdated subscription' do
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'issuableTitleUpdated',
|
2022-10-28 08:11:31 -04:00
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-02-11 16:12:17 -05:00
|
|
|
).and_call_original
|
|
|
|
|
2022-10-28 08:11:31 -04:00
|
|
|
GraphqlTriggers.issuable_title_updated(issuable)
|
2022-02-11 16:12:17 -05:00
|
|
|
end
|
|
|
|
end
|
2022-04-01 14:08:46 -04:00
|
|
|
|
2022-09-23 20:14:11 -04:00
|
|
|
describe '.issuable_description_updated' do
|
|
|
|
it 'triggers the issuableDescriptionUpdated subscription' do
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'issuableDescriptionUpdated',
|
2022-10-28 08:11:31 -04:00
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-09-23 20:14:11 -04:00
|
|
|
).and_call_original
|
|
|
|
|
2022-10-28 08:11:31 -04:00
|
|
|
GraphqlTriggers.issuable_description_updated(issuable)
|
2022-09-23 20:14:11 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-01 14:08:46 -04:00
|
|
|
describe '.issuable_labels_updated' do
|
2022-10-28 08:11:31 -04:00
|
|
|
let(:labels) { create_list(:label, 3, project: create(:project)) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
issuable.update!(labels: labels)
|
|
|
|
end
|
2022-04-01 14:08:46 -04:00
|
|
|
|
2022-10-28 08:11:31 -04:00
|
|
|
it 'triggers the issuableLabelsUpdated subscription' do
|
2022-04-01 14:08:46 -04:00
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'issuableLabelsUpdated',
|
2022-10-28 08:11:31 -04:00
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-04-01 14:08:46 -04:00
|
|
|
)
|
|
|
|
|
2022-10-28 08:11:31 -04:00
|
|
|
GraphqlTriggers.issuable_labels_updated(issuable)
|
2022-04-01 14:08:46 -04:00
|
|
|
end
|
|
|
|
end
|
2022-08-05 14:08:56 -04:00
|
|
|
|
|
|
|
describe '.issuable_dates_updated' do
|
|
|
|
it 'triggers the issuableDatesUpdated subscription' do
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'issuableDatesUpdated',
|
2022-10-28 08:11:31 -04:00
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
|
|
|
).and_call_original
|
|
|
|
|
|
|
|
GraphqlTriggers.issuable_dates_updated(issuable)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.issuable_milestone_updated' do
|
|
|
|
it 'triggers the issuableMilestoneUpdated subscription' do
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'issuableMilestoneUpdated',
|
|
|
|
{ issuable_id: issuable.to_gid },
|
|
|
|
issuable
|
2022-08-05 14:08:56 -04:00
|
|
|
).and_call_original
|
|
|
|
|
2022-10-28 08:11:31 -04:00
|
|
|
GraphqlTriggers.issuable_milestone_updated(issuable)
|
2022-08-05 14:08:56 -04:00
|
|
|
end
|
|
|
|
end
|
2022-09-30 05:09:43 -04:00
|
|
|
|
|
|
|
describe '.merge_request_reviewers_updated' do
|
|
|
|
it 'triggers the mergeRequestReviewersUpdated subscription' do
|
|
|
|
merge_request = build_stubbed(:merge_request)
|
|
|
|
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'mergeRequestReviewersUpdated',
|
|
|
|
{ issuable_id: merge_request.to_gid },
|
|
|
|
merge_request
|
|
|
|
).and_call_original
|
|
|
|
|
|
|
|
GraphqlTriggers.merge_request_reviewers_updated(merge_request)
|
|
|
|
end
|
|
|
|
end
|
2022-10-04 23:09:43 -04:00
|
|
|
|
|
|
|
describe '.merge_request_merge_status_updated' do
|
|
|
|
it 'triggers the mergeRequestMergeStatusUpdated subscription' do
|
|
|
|
merge_request = build_stubbed(:merge_request)
|
|
|
|
|
|
|
|
expect(GitlabSchema.subscriptions).to receive(:trigger).with(
|
|
|
|
'mergeRequestMergeStatusUpdated',
|
|
|
|
{ issuable_id: merge_request.to_gid },
|
|
|
|
merge_request
|
|
|
|
).and_call_original
|
|
|
|
|
|
|
|
GraphqlTriggers.merge_request_merge_status_updated(merge_request)
|
|
|
|
end
|
|
|
|
end
|
2021-04-23 05:10:03 -04:00
|
|
|
end
|