Skip to content
Snippets Groups Projects
Commit d0451a05 authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Test for Project#builds_for and return empty array for nothing

parent 2c646bb2
No related branches found
No related tags found
1 merge request!5142Add a download buttons for Build Artifacts
Pipeline #
Loading
Loading
@@ -430,6 +430,9 @@ class Project < ActiveRecord::Base
end
 
def builds_for(build_name, ref = 'HEAD')
ct = commit(ref)
return [] unless ct
sha = commit(ref).sha
 
builds.joins(:pipeline).
Loading
Loading
Loading
Loading
@@ -359,11 +359,25 @@ describe Project, models: true do
describe :repository do
let(:project) { create(:project) }
 
it 'should return valid repo' do
it 'returns valid repo' do
expect(project.repository).to be_kind_of(Repository)
end
end
 
describe '#builds_for' do
let(:project) { create(:project) }
let(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit.sha)
end
let(:build) { create(:ci_build, pipeline: pipeline) }
it 'returns builds for a particular ref' do
build_ids = project.builds_for(build.name, build.sha).map(&:id)
expect(build_ids).to eq([build.id])
end
end
describe :default_issues_tracker? do
let(:project) { create(:project) }
let(:ext_project) { create(:redmine_project) }
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