BigW Consortium Gitlab

Commit 6597c213 by Lin Jen-Shin

Prefer empty relation rather than arrays

parent a1eac5e4
......@@ -431,7 +431,7 @@ class Project < ActiveRecord::Base
def builds_for(build_name, ref = 'HEAD')
ct = commit(ref)
return [] unless ct
return builds.none unless ct
sha = commit(ref).sha
......
......@@ -697,5 +697,11 @@ describe Ci::Build, models: true do
expect(build_ids).to eq([build.id])
end
it 'returns empty relation if the build cannot be found' do
builds = project.builds_for(build.name, 'TAIL').all
expect(builds).to be_empty
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