summaryrefslogtreecommitdiff
path: root/spec/models/project_services/chat_message/merge_message_spec.rb
blob: 07c414c6ca468dd6b242729f5115283d724c307b (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
51
require 'spec_helper'

describe ChatMessage::MergeMessage, models: true do
  subject { described_class.new(args) }

  let(:args) do
    {
      user: {
          name: 'Test User',
          username: 'test.user'
      },
      project_name: 'project_name',
      project_url: 'somewhere.com',

      object_attributes: {
        title: "Issue title\nSecond line",
        id: 10,
        iid: 100,
        assignee_id: 1,
        url: 'url',
        state: 'opened',
        description: 'issue description',
        source_branch: 'source_branch',
        target_branch: 'target_branch',
      }
    }
  end

  let(:color) { '#345' }

  context 'open' do
    it 'returns a message regarding opening of merge requests' do
      expect(subject.pretext).to eq(
        'test.user opened <somewhere.com/merge_requests/100|merge request !100> '\
        'in <somewhere.com|project_name>: *Issue title*')
      expect(subject.attachments).to be_empty
    end
  end

  context 'close' do
    before do
      args[:object_attributes][:state] = 'closed'
    end
    it 'returns a message regarding closing of merge requests' do
      expect(subject.pretext).to eq(
        'test.user closed <somewhere.com/merge_requests/100|merge request !100> '\
        'in <somewhere.com|project_name>: *Issue title*')
      expect(subject.attachments).to be_empty
    end
  end
end