Commit 4a52f44f authored by Pedro Pombeiro's avatar Pedro Pombeiro

Fix behavior when user is nil

parent dd6983a5
...@@ -12,7 +12,7 @@ module Ci ...@@ -12,7 +12,7 @@ module Ci
end end
def execute def execute
return false unless @user.nil? || @user.can?(:assign_runner, @runner) return false unless @user.present? && @user.can?(:assign_runner, @runner)
@runner.assign_to(@project, @user) @runner.assign_to(@project, @user)
end end
......
...@@ -11,10 +11,10 @@ RSpec.describe ::Ci::AssignRunnerService, '#execute' do ...@@ -11,10 +11,10 @@ RSpec.describe ::Ci::AssignRunnerService, '#execute' do
context 'without user' do context 'without user' do
let(:user) { nil } let(:user) { nil }
it 'calls assign_to on runner and returns value unchanged' do it 'does not call assign_to on runner and returns false' do
expect(runner).to receive(:assign_to).with(project, nil).once.and_return('assign_to return value') expect(runner).not_to receive(:assign_to)
is_expected.to eq('assign_to return value') is_expected.to eq(false)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment