debian-mirror-gitlab/spec/lib/gitlab/slash_commands/presenters/issue_show_spec.rb

57 lines
1.6 KiB
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::SlashCommands::Presenters::IssueShow do
2020-04-22 19:07:51 +05:30
let(:user) { create(:user, :with_avatar) }
let(:project) { create(:project, creator: user) }
2017-08-17 22:00:37 +05:30
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 start_with(issue.title)
2020-04-22 19:07:51 +05:30
expect(attachment[:author_icon]).to eq(user.avatar_url(only_path: false))
2017-08-17 22:00:37 +05:30
end
context 'with upvotes' do
before do
create(:award_emoji, :upvote, awardable: issue)
end
it 'shows the upvote count' do
expect(subject[:response_type]).to be(:in_channel)
expect(attachment[:text]).to start_with("**Open** · :+1: 1")
end
end
context 'with labels' do
let(:label) { create(:label, project: project, title: 'mep') }
let(:label1) { create(:label, project: project, title: 'mop') }
before do
issue.labels << [label, label1]
end
it 'shows the labels' do
labels = attachment[:fields].find { |f| f[:title] == 'Labels' }
expect(labels[:value]).to eq("mep, mop")
end
end
context 'confidential issue' do
let(:issue) { create(:issue, project: project) }
it 'shows an ephemeral response' do
expect(subject[:response_type]).to be(:in_channel)
expect(attachment[:text]).to start_with("**Open**")
end
end
end