Skip to content
Snippets Groups Projects
Commit b7894a74 authored by Z.J. van de Weg's avatar Z.J. van de Weg
Browse files

Fix errorcode 500 on slash commands

Coverage was failing, so this could slip through the cracks
parent 358a2d8b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -49,8 +49,9 @@ module Gitlab
end
 
def url(subject)
polymorphic_url(
[ subject.project.namespace.becomes(Namespace), subject.project, subject ])
project = subject.project
namespace_project_build_url(project.namespace.becomes(Namespace), project, subject)
end
end
end
Loading
Loading
Loading
Loading
@@ -30,12 +30,12 @@ module Gitlab
if subject.is_a?(Gitlab::ChatCommands::Result)
show_result(subject)
elsif subject.respond_to?(:count)
if subject.many?
multiple_resources(subject)
elsif subject.none?
if subject.none?
not_found
elsif subject.one?
single_resource(subject.first)
else
single_resource(subject)
multiple_resources(subject)
end
else
single_resource(subject)
Loading
Loading
@@ -71,9 +71,9 @@ module Gitlab
end
 
def multiple_resources(resources)
resources.map! { |resource| title(resource) }
titles = resources.map { |resource| title(resource) }
 
message = header_with_list("Multiple results were found:", resources)
message = header_with_list("Multiple results were found:", titles)
 
ephemeral_response(message)
end
Loading
Loading
Loading
Loading
@@ -54,6 +54,30 @@ describe Gitlab::ChatCommands::Command, service: true do
end
end
 
context 'searching for an issue' do
let(:params) { { text: 'issue search find me' } }
let!(:issue) { create(:issue, project: project, title: 'find me') }
before do
project.team << [user, :master]
end
context 'a single issue is found' do
it 'presents the issue' do
expect(subject[:text]).to match(issue.title)
end
end
context 'multiple issues found' do
let!(:issue2) { create(:issue, project: project, title: "someone find me") }
it 'shows a link to the new issue' do
expect(subject[:text]).to match(issue.title)
expect(subject[:text]).to match(issue2.title)
end
end
end
context 'when trying to do deployment' do
let(:params) { { text: 'deploy staging to production' } }
let!(:build) { create(:ci_build, project: project) }
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ describe MattermostSlashCommandsService, :models do
context 'Mattermost API' do
let(:project) { create(:empty_project) }
let(:service) { project.build_mattermost_slash_commands_service }
let(:user) { create(:user)}
let(:user) { create(:user) }
 
before do
Mattermost::Session.base_uri("http://mattermost.example.com")
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment