2016-11-15 20:50:27 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-11-16 17:28:38 +00:00
|
|
|
describe Gitlab::ChatCommands::IssueShow, service: true do
|
2016-11-15 20:50:27 +00:00
|
|
|
describe '#execute' do
|
|
|
|
let(:issue) { create(:issue) }
|
|
|
|
let(:project) { issue.project }
|
|
|
|
let(:user) { issue.author }
|
2016-11-16 17:28:38 +00:00
|
|
|
let(:regex_match) { described_class.match("issue show #{issue.iid}") }
|
2016-11-15 20:50:27 +00:00
|
|
|
|
|
|
|
before { project.team << [user, :master] }
|
|
|
|
|
2016-11-16 17:28:38 +00:00
|
|
|
subject { described_class.new(project, user).execute(regex_match) }
|
2016-11-15 20:50:27 +00:00
|
|
|
|
|
|
|
context 'the issue exists' do
|
|
|
|
it 'returns the issue' do
|
|
|
|
expect(subject[:response_type]).to be :in_channel
|
|
|
|
expect(subject[:text]).to match issue.title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'the issue does not exist' do
|
2016-11-16 17:28:38 +00:00
|
|
|
let(:regex_match) { described_class.match("issue show 1234") }
|
2016-11-15 20:50:27 +00:00
|
|
|
|
|
|
|
it "returns nil" do
|
|
|
|
expect(subject[:response_type]).to be :ephemeral
|
|
|
|
expect(subject[:text]).to start_with '404 not found!'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|