Fix specs and improve code readability

This commit is contained in:
Kamil Trzcinski 2016-11-21 18:22:03 +01:00
parent a36d556137
commit d375e3f15b
2 changed files with 5 additions and 4 deletions

View file

@ -30,9 +30,9 @@ module Mattermost
if subject.is_a?(Gitlab::ChatCommands::Result)
show_result(subject)
elsif subject.respond_to?(:count)
if subject.try(:many?)
if subject.many?
multiple_resources(subject)
elsif subject.count == 0
elsif subject.none?
not_found
else
single_resource(subject)

View file

@ -52,12 +52,13 @@ describe Gitlab::ChatCommands::Deploy, service: true do
context 'when teardown action exists' do
let!(:teardown) do
create(:ci_build, :manual, :teardown_environment, project: project, pipeline: build.pipeline,
create(:ci_build, :manual, :teardown_environment,
project: project, pipeline: build.pipeline,
name: 'teardown', environment: 'production')
end
it 'returns error' do
expect(subject).to eq(action)
expect(subject).to eq(manual1)
end
end
end