summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/chat_commands/presenters/show_issue_spec.rb
blob: 13a318fe68082938d1bf8327f5fbdba30ff04d77 (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
require 'spec_helper'

describe Gitlab::ChatCommands::Presenters::ShowIssue do
  let(:project) { create(:empty_project) }
  let(:issue) { create(:issue, project: project) }
  let(:attachment) { subject[:attachments].first }

  subject { described_class.new(issue).present }

  it { is_expected.to be_a(Hash) }

  it 'shows the issue' do
    expect(subject[:response_type]).to be(:in_channel)
    expect(subject).to have_key(:attachments)
    expect(attachment[:title]).to eq(issue.title)
  end

  context 'with upvotes' do
    before do
      create(:award_emoji, :upvote, awardable: issue)
    end

    it 'shows the upvote count' do
      expect(attachment[:text]).to start_with(":+1: 1")
    end
  end
end