Commit cfd7c445 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Move Project#latest_successful_builds_for to project_spec.rb

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5347#note_13173313
parent dc6afd57
...@@ -674,40 +674,6 @@ describe Ci::Build, models: true do ...@@ -674,40 +674,6 @@ describe Ci::Build, models: true do
end end
end end
describe 'Project#latest_successful_builds_for' do
let!(:build) do
create(:ci_build, :artifacts, :success, pipeline: pipeline)
end
context 'with succeed pipeline' do
it 'returns builds for ref for default_branch' do
builds = project.latest_successful_builds_for
expect(builds).to contain_exactly(build)
end
it 'returns empty relation if the build cannot be found' do
builds = project.latest_successful_builds_for('TAIL')
expect(builds).to be_kind_of(ActiveRecord::Relation)
expect(builds).to be_empty
end
end
context 'with pending pipeline' do
before do
pipeline.update(status: 'pending')
end
it 'returns empty relation' do
builds = project.latest_successful_builds_for
expect(builds).to be_kind_of(ActiveRecord::Relation)
expect(builds).to be_empty
end
end
end
describe '#manual?' do describe '#manual?' do
before do before do
build.update(when: value) build.update(when: value)
......
...@@ -1114,6 +1114,49 @@ describe Project, models: true do ...@@ -1114,6 +1114,49 @@ describe Project, models: true do
end end
end end
describe '#latest_successful_builds_for' do
let(:project) { create(:project) }
let(:pipeline) do
create(:ci_pipeline, project: project,
sha: project.commit.id,
ref: project.default_branch,
status: 'success')
end
let!(:build) do
create(:ci_build, :artifacts, :success, pipeline: pipeline)
end
context 'with succeed pipeline' do
it 'returns builds for ref for default_branch' do
builds = project.latest_successful_builds_for
expect(builds).to contain_exactly(build)
end
it 'returns empty relation if the build cannot be found' do
builds = project.latest_successful_builds_for('TAIL')
expect(builds).to be_kind_of(ActiveRecord::Relation)
expect(builds).to be_empty
end
end
context 'with pending pipeline' do
before do
pipeline.update(status: 'pending')
end
it 'returns empty relation' do
builds = project.latest_successful_builds_for
expect(builds).to be_kind_of(ActiveRecord::Relation)
expect(builds).to be_empty
end
end
end
describe '.where_paths_in' do describe '.where_paths_in' do
context 'without any paths' do context 'without any paths' do
it 'returns an empty relation' do it 'returns an empty relation' do
......
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