2016-11-15 03:55:56 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-11-16 12:28:38 -05:00
|
|
|
describe Gitlab::ChatCommands::Command, service: true do
|
2016-11-17 09:30:04 -05:00
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
2016-11-15 03:55:56 -05:00
|
|
|
|
|
|
|
subject { described_class.new(project, user, params).execute }
|
|
|
|
|
2016-11-17 06:57:27 -05:00
|
|
|
describe '#execute' do
|
2016-11-17 09:30:04 -05:00
|
|
|
context 'when no command is not available' do
|
|
|
|
let(:params) { { text: 'issue show 1' } }
|
2016-11-17 06:57:27 -05:00
|
|
|
let(:project) { create(:project, has_external_issue_tracker: true) }
|
2016-11-15 03:55:56 -05:00
|
|
|
|
2016-11-17 06:57:27 -05:00
|
|
|
it 'displays the help message' do
|
|
|
|
expect(subject[:response_type]).to be(:ephemeral)
|
2016-11-17 09:30:04 -05:00
|
|
|
expect(subject[:text]).to start_with('404 not found')
|
2016-11-17 06:57:27 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when an unknown command is triggered' do
|
|
|
|
let(:params) { { text: "unknown command 123" } }
|
|
|
|
|
|
|
|
it 'displays the help message' do
|
|
|
|
expect(subject[:response_type]).to be(:ephemeral)
|
|
|
|
expect(subject[:text]).to start_with('Available commands')
|
2016-11-15 03:55:56 -05:00
|
|
|
end
|
|
|
|
end
|
2016-11-17 09:30:04 -05:00
|
|
|
|
|
|
|
context 'issue is succesfully created' do
|
|
|
|
let(:params) { { text: "issue create my new issue" } }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'presents the issue' do
|
|
|
|
expect(subject[:text]).to match("my new issue")
|
|
|
|
end
|
|
|
|
end
|
2016-11-15 03:55:56 -05:00
|
|
|
end
|
|
|
|
end
|