gitlab-org--gitlab-foss/spec/lib/gitlab/chat_commands/command_spec.rb

42 lines
1.2 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe Gitlab::ChatCommands::Command, service: true do
2016-11-17 09:30:04 -05:00
let(:project) { create(:project) }
let(:user) { create(:user) }
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-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')
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
end
end