Commit 5ed898a5 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Peter Leitzen

Refactor let! with let_it_be in pipelines spec

parent b94dac6a
---
title: angelog Replace let! with let_it_be in pipelines spec
merge_request: 31916
author: Rajendra Kadam
type: fixed
...@@ -72,8 +72,8 @@ describe API::Pipelines do ...@@ -72,8 +72,8 @@ describe API::Pipelines do
end end
context 'when scope is branches or tags' do context 'when scope is branches or tags' do
let!(:pipeline_branch) { create(:ci_pipeline, project: project) } let_it_be(:pipeline_branch) { create(:ci_pipeline, project: project) }
let!(:pipeline_tag) { create(:ci_pipeline, project: project, ref: 'v1.0.0', tag: true) } let_it_be(:pipeline_tag) { create(:ci_pipeline, project: project, ref: 'v1.0.0', tag: true) }
context 'when scope is branches' do context 'when scope is branches' do
it 'returns matched pipelines' do it 'returns matched pipelines' do
...@@ -161,7 +161,7 @@ describe API::Pipelines do ...@@ -161,7 +161,7 @@ describe API::Pipelines do
end end
context 'when name is specified' do context 'when name is specified' do
let!(:pipeline) { create(:ci_pipeline, project: project, user: user) } let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
context 'when name exists' do context 'when name exists' do
it 'returns matched pipelines' do it 'returns matched pipelines' do
...@@ -185,7 +185,7 @@ describe API::Pipelines do ...@@ -185,7 +185,7 @@ describe API::Pipelines do
end end
context 'when username is specified' do context 'when username is specified' do
let!(:pipeline) { create(:ci_pipeline, project: project, user: user) } let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) }
context 'when username exists' do context 'when username exists' do
it 'returns matched pipelines' do it 'returns matched pipelines' do
...@@ -209,8 +209,8 @@ describe API::Pipelines do ...@@ -209,8 +209,8 @@ describe API::Pipelines do
end end
context 'when yaml_errors is specified' do context 'when yaml_errors is specified' do
let!(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: 'Syntax error') } let_it_be(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: 'Syntax error') }
let!(:pipeline2) { create(:ci_pipeline, project: project) } let_it_be(:pipeline2) { create(:ci_pipeline, project: project) }
context 'when yaml_errors is true' do context 'when yaml_errors is true' do
it 'returns matched pipelines' do it 'returns matched pipelines' do
...@@ -242,9 +242,9 @@ describe API::Pipelines do ...@@ -242,9 +242,9 @@ describe API::Pipelines do
end end
context 'when updated_at filters are specified' do context 'when updated_at filters are specified' do
let!(:pipeline1) { create(:ci_pipeline, project: project, updated_at: 2.days.ago) } let_it_be(:pipeline1) { create(:ci_pipeline, project: project, updated_at: 2.days.ago) }
let!(:pipeline2) { create(:ci_pipeline, project: project, updated_at: 4.days.ago) } let_it_be(:pipeline2) { create(:ci_pipeline, project: project, updated_at: 4.days.ago) }
let!(:pipeline3) { create(:ci_pipeline, project: project, updated_at: 1.hour.ago) } let_it_be(:pipeline3) { create(:ci_pipeline, project: project, updated_at: 1.hour.ago) }
it 'returns pipelines with last update date in specified datetime range' do it 'returns pipelines with last update date in specified datetime range' do
get api("/projects/#{project.id}/pipelines", user), params: { updated_before: 1.day.ago, updated_after: 3.days.ago } get api("/projects/#{project.id}/pipelines", user), params: { updated_before: 1.day.ago, updated_after: 3.days.ago }
...@@ -614,7 +614,7 @@ describe API::Pipelines do ...@@ -614,7 +614,7 @@ describe API::Pipelines do
end end
context 'when the pipeline has jobs' do context 'when the pipeline has jobs' do
let!(:build) { create(:ci_build, project: project, pipeline: pipeline) } let_it_be(:build) { create(:ci_build, project: project, pipeline: pipeline) }
it 'destroys associated jobs' do it 'destroys associated jobs' do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner)
...@@ -654,12 +654,12 @@ describe API::Pipelines do ...@@ -654,12 +654,12 @@ describe API::Pipelines do
describe 'POST /projects/:id/pipelines/:pipeline_id/retry' do describe 'POST /projects/:id/pipelines/:pipeline_id/retry' do
context 'authorized user' do context 'authorized user' do
let!(:pipeline) do let_it_be(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit.id, create(:ci_pipeline, project: project, sha: project.commit.id,
ref: project.default_branch) ref: project.default_branch)
end end
let!(:build) { create(:ci_build, :failed, pipeline: pipeline) } let_it_be(:build) { create(:ci_build, :failed, pipeline: pipeline) }
it 'retries failed builds' do it 'retries failed builds' do
expect do expect do
...@@ -683,12 +683,12 @@ describe API::Pipelines do ...@@ -683,12 +683,12 @@ describe API::Pipelines do
end end
describe 'POST /projects/:id/pipelines/:pipeline_id/cancel' do describe 'POST /projects/:id/pipelines/:pipeline_id/cancel' do
let!(:pipeline) do let_it_be(:pipeline) do
create(:ci_empty_pipeline, project: project, sha: project.commit.id, create(:ci_empty_pipeline, project: project, sha: project.commit.id,
ref: project.default_branch) ref: project.default_branch)
end end
let!(:build) { create(:ci_build, :running, pipeline: pipeline) } let_it_be(:build) { create(:ci_build, :running, pipeline: pipeline) }
context 'authorized user' do context 'authorized user' do
it 'retries failed builds', :sidekiq_might_not_need_inline do it 'retries failed builds', :sidekiq_might_not_need_inline do
...@@ -700,7 +700,7 @@ describe API::Pipelines do ...@@ -700,7 +700,7 @@ describe API::Pipelines do
end end
context 'user without proper access rights' do context 'user without proper access rights' do
let!(:reporter) { create(:user) } let_it_be(:reporter) { create(:user) }
before do before do
project.add_reporter(reporter) project.add_reporter(reporter)
......
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