diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-17 12:57:27 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-17 21:34:24 +0100 |
commit | 6737ada0c8d980ed1bd8f425e885fa1b89930616 (patch) | |
tree | b2efd37f2450e137c15f5ee433046a7725202cda /spec/lib/gitlab/chat_commands | |
parent | d4def9cbcd664b7067e7f9f4ea8be54463bd1d50 (diff) | |
download | gitlab-ce-6737ada0c8d980ed1bd8f425e885fa1b89930616.tar.gz |
Remove some commands for now
Diffstat (limited to 'spec/lib/gitlab/chat_commands')
4 files changed, 15 insertions, 121 deletions
diff --git a/spec/lib/gitlab/chat_commands/command_spec.rb b/spec/lib/gitlab/chat_commands/command_spec.rb index d28349ff1d8..bbd47f45761 100644 --- a/spec/lib/gitlab/chat_commands/command_spec.rb +++ b/spec/lib/gitlab/chat_commands/command_spec.rb @@ -7,12 +7,22 @@ describe Gitlab::ChatCommands::Command, service: true do subject { described_class.new(project, user, params).execute } - xdescribe '#execute' do - context 'when issue show is triggered' do - it 'calls IssueShowService' do - expect_any_instance_of(Mattermost::Commands::IssueShowService).to receive(:new).with(project, user, params) + describe '#execute' do + context 'when the command is not available' do + let(:project) { create(:project, has_external_issue_tracker: true) } - subject + it 'displays the help message' do + expect(subject[:response_type]).to be(:ephemeral) + expect(subject[:text]).to start_with('Available commands') + 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 end diff --git a/spec/lib/gitlab/chat_commands/issue_search_spec.rb b/spec/lib/gitlab/chat_commands/issue_search_spec.rb deleted file mode 100644 index 3e54333528a..00000000000 --- a/spec/lib/gitlab/chat_commands/issue_search_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' - -describe Gitlab::ChatCommands::IssueSearch, service: true do - describe '#execute' do - let!(:issue) { create(:issue, title: 'The bird is the word') } - let(:project) { issue.project } - let(:user) { issue.author } - let(:regex_match) { described_class.match("issue search bird is the") } - - before { project.team << [user, :master] } - - subject { described_class.new(project, user).execute(regex_match) } - - context 'without results' do - let(:regex_match) { described_class.match("issue search no results for this one") } - - it "returns nil" do - expect(subject[:response_type]).to be :ephemeral - expect(subject[:text]).to start_with '404 not found!' - end - end - - context 'with 1 result' do - it 'returns the issue' do - expect(subject[:response_type]).to be :in_channel - expect(subject[:text]).to match issue.title - end - end - - context 'with 2 or more results' do - let!(:issue2) { create(:issue, project: project, title: 'bird is the word!') } - - it 'returns multiple resources' do - expect(subject[:response_type]).to be :ephemeral - expect(subject[:text]).to start_with 'Multiple results were found' - end - end - end -end diff --git a/spec/lib/gitlab/chat_commands/merge_request_search_spec.rb b/spec/lib/gitlab/chat_commands/merge_request_search_spec.rb deleted file mode 100644 index 4033358ab2e..00000000000 --- a/spec/lib/gitlab/chat_commands/merge_request_search_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe Gitlab::ChatCommands::MergeRequestSearch, service: true do - describe '#execute' do - let!(:merge_request) { create(:merge_request, title: 'The bird is the word') } - let(:project) { merge_request.source_project } - let(:user) { merge_request.author } - let(:regex_match) { described_class.match("mergerequest search #{merge_request.title}") } - - before do - project.team << [user, :master] - end - - subject do - described_class.new(project, user).execute(regex_match) - end - - context 'the merge request exists' do - it 'returns the merge request' do - expect(subject[:response_type]).to be(:in_channel) - expect(subject[:text]).to match(merge_request.title) - end - end - - context 'no results can be found' do - let(:regex_match) { described_class.match("mergerequest search 12334") } - - it "returns a 404 message" do - expect(subject[:response_type]).to be(:ephemeral) - expect(subject[:text]).to start_with('404 not found!') - end - end - end - - describe 'self.match' do - it 'matches a valid query' do - expect(described_class.match("mergerequest search my title here")).to be_truthy - end - end -end diff --git a/spec/lib/gitlab/chat_commands/merge_request_show_spec.rb b/spec/lib/gitlab/chat_commands/merge_request_show_spec.rb deleted file mode 100644 index ed63ffa5f85..00000000000 --- a/spec/lib/gitlab/chat_commands/merge_request_show_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe Gitlab::ChatCommands::MergeRequestShow, service: true do - describe '#execute' do - let!(:merge_request) { create(:merge_request) } - let(:project) { merge_request.source_project } - let(:user) { merge_request.author } - let(:regex_match) { described_class.match("mergerequest show #{merge_request.iid}") } - - before { project.team << [user, :master] } - - subject { described_class.new(project, user).execute(regex_match) } - - context 'the merge request exists' do - it 'returns the merge request' do - expect(subject[:response_type]).to be :in_channel - expect(subject[:text]).to match merge_request.title - end - end - - context 'the merge request does not exist' do - let(:regex_match) { described_class.match("mergerequest show 12345") } - - it "returns nil" do - expect(subject[:response_type]).to be :ephemeral - expect(subject[:text]).to start_with '404 not found!' - end - end - end - - describe "self.match" do - it 'matches valid strings' do - expect(described_class.match("mergerequest show 123")).to be_truthy - expect(described_class.match("mergerequest show sdf23")).to be_falsy - end - end -end |