summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-20 22:31:40 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-20 22:31:40 +0800
commit88aacaa7e5ec57b85749028f4463a498fc1e35f1 (patch)
tree6e0798679ca5fe41a0f1ddf0ca47d75fe01f7467 /spec
parenta7713232ea723a7215ab0aff4c6fed87343df1fd (diff)
downloadgitlab-ce-88aacaa7e5ec57b85749028f4463a498fc1e35f1.tar.gz
Reuse those two methods
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_spec.rb29
1 files changed, 10 insertions, 19 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index cbd1f5f9e32..9d122fd0083 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1115,19 +1115,23 @@ describe Project, models: true do
end
describe '#latest_successful_builds_for' do
- let(:project) { create(:project) }
-
- let(:pipeline) do
+ def create_pipeline
create(:ci_pipeline, project: project,
- sha: project.commit.id,
+ sha: project.commit.sha,
ref: project.default_branch,
status: 'success')
end
- let(:build) do
- create(:ci_build, :artifacts, :success, pipeline: pipeline)
+ def create_build(new_pipeline = pipeline, name = 'test')
+ create(:ci_build, :success, :artifacts,
+ pipeline: new_pipeline,
+ name: name)
end
+ let(:project) { create(:project) }
+ let(:pipeline) { create_pipeline }
+ let(:build) { create_build }
+
context 'with succeeded pipeline' do
context 'standalone pipeline' do
before do
@@ -1163,19 +1167,6 @@ describe Project, models: true do
expect(latest_builds).to contain_exactly(@build2_p2, @build1_p2)
end
-
- def create_pipeline
- create(:ci_pipeline, project: project,
- sha: project.commit.sha,
- ref: project.default_branch,
- status: 'success')
- end
-
- def create_build(pipe, name = 'test')
- create(:ci_build, :success, :artifacts,
- pipeline: pipe,
- name: name)
- end
end
context 'with multiple pipelines and builds' do