Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_comment_spec.rb « presenters « slash_commands « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3741563a744bba1b71807809fff5cc8cb257bb66 (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::SlashCommands::Presenters::IssueComment do
  let_it_be(:project) { create(:project) }
  let_it_be(:issue) { create(:issue, project: project) }
  let_it_be(:note) { create(:note, project: project, noteable: issue) }
  let(:author) { note.author }

  describe '#present' do
    let(:attachment) { subject[:attachments].first }

    subject { described_class.new(note).present }

    it { is_expected.to be_a(Hash) }

    it 'sets ephemeral response type' do
      expect(subject[:response_type]).to be(:ephemeral)
    end

    it 'sets the title' do
      expect(attachment[:title]).to eq("#{issue.title} · #{issue.to_reference}")
    end

    it 'sets the fallback text' do
      expect(attachment[:fallback]).to eq("New comment on #{issue.to_reference}: #{issue.title}")
    end

    it 'sets the fields' do
      expect(attachment[:fields]).to eq([{ title: 'Comment', value: note.note }])
    end

    it 'sets the color' do
      expect(attachment[:color]).to eq('#38ae67')
    end
  end
end