summaryrefslogtreecommitdiff
path: root/spec/graphql/graphql_triggers_spec.rb
blob: 84af33a5cb3f0f29a982969b89216a958c349cb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe GraphqlTriggers do
  describe '.issuable_assignees_updated' do
    it 'triggers the issuableAssigneesUpdated subscription' do
      assignees = create_list(:user, 2)
      issue = create(:issue, assignees: assignees)

      expect(GitlabSchema.subscriptions).to receive(:trigger).with(
        'issuableAssigneesUpdated',
        { issuable_id: issue.to_gid },
        issue
      )

      GraphqlTriggers.issuable_assignees_updated(issue)
    end
  end

  describe '.issuable_title_updated' do
    it 'triggers the issuableTitleUpdated subscription' do
      work_item = create(:work_item)

      expect(GitlabSchema.subscriptions).to receive(:trigger).with(
        'issuableTitleUpdated',
        { issuable_id: work_item.to_gid },
        work_item
      ).and_call_original

      GraphqlTriggers.issuable_title_updated(work_item)
    end
  end

  describe '.issuable_labels_updated' do
    it 'triggers the issuableLabelsUpdated subscription' do
      project = create(:project)
      labels = create_list(:label, 3, project: project)
      issue = create(:issue, labels: labels)

      expect(GitlabSchema.subscriptions).to receive(:trigger).with(
        'issuableLabelsUpdated',
        { issuable_id: issue.to_gid },
        issue
      )

      GraphqlTriggers.issuable_labels_updated(issue)
    end
  end
end