Commit 8b0f7fb5 authored by Allison Browne's avatar Allison Browne

Use let_it_be to speed up pipeline specs

Speed up the pipeline feature specs by creating fewer
projects using let_it_be.

Total projects created 103 -> 30
Total time creating projects 21.9884s -> 7.8286s
parent c1e16db6
...@@ -7,7 +7,8 @@ RSpec.describe 'Pipeline', :js do ...@@ -7,7 +7,8 @@ RSpec.describe 'Pipeline', :js do
include ProjectForksHelper include ProjectForksHelper
include ::ExclusiveLeaseHelpers include ::ExclusiveLeaseHelpers
let(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:role) { :developer } let(:role) { :developer }
...@@ -59,8 +60,9 @@ RSpec.describe 'Pipeline', :js do ...@@ -59,8 +60,9 @@ RSpec.describe 'Pipeline', :js do
describe 'GET /:project/-/pipelines/:id' do describe 'GET /:project/-/pipelines/:id' do
include_context 'pipeline builds' include_context 'pipeline builds'
let(:group) { create(:group) } let_it_be(:group) { create(:group) }
let(:project) { create(:project, :repository, group: group) } let_it_be(:project, reload: true) { create(:project, :repository, group: group) }
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) }
subject(:visit_pipeline) { visit project_pipeline_path(project, pipeline) } subject(:visit_pipeline) { visit project_pipeline_path(project, pipeline) }
...@@ -246,6 +248,8 @@ RSpec.describe 'Pipeline', :js do ...@@ -246,6 +248,8 @@ RSpec.describe 'Pipeline', :js do
end end
context 'when pipeline has a delayed job' do context 'when pipeline has a delayed job' do
let(:project) { create(:project, :repository, group: group) }
it 'shows the scheduled icon and an unschedule action for the delayed job' do it 'shows the scheduled icon and an unschedule action for the delayed job' do
page.within('#ci-badge-delayed-job') do page.within('#ci-badge-delayed-job') do
expect(page).to have_selector('.js-ci-status-icon-scheduled') expect(page).to have_selector('.js-ci-status-icon-scheduled')
...@@ -550,6 +554,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -550,6 +554,7 @@ RSpec.describe 'Pipeline', :js do
end end
context 'when pipeline is merge request pipeline' do context 'when pipeline is merge request pipeline' do
let(:project) { create(:project, :repository, group: group) }
let(:source_project) { project } let(:source_project) { project }
let(:target_project) { project } let(:target_project) { project }
...@@ -634,7 +639,8 @@ RSpec.describe 'Pipeline', :js do ...@@ -634,7 +639,8 @@ RSpec.describe 'Pipeline', :js do
describe 'GET /:project/-/pipelines/:id' do describe 'GET /:project/-/pipelines/:id' do
include_context 'pipeline builds' include_context 'pipeline builds'
let(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) }
before do before do
...@@ -997,7 +1003,8 @@ RSpec.describe 'Pipeline', :js do ...@@ -997,7 +1003,8 @@ RSpec.describe 'Pipeline', :js do
describe 'GET /:project/-/pipelines/:id/builds' do describe 'GET /:project/-/pipelines/:id/builds' do
include_context 'pipeline builds' include_context 'pipeline builds'
let(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
before do before do
...@@ -1234,7 +1241,8 @@ RSpec.describe 'Pipeline', :js do ...@@ -1234,7 +1241,8 @@ RSpec.describe 'Pipeline', :js do
describe 'GET /:project/-/pipelines/:id/dag' do describe 'GET /:project/-/pipelines/:id/dag' do
include_context 'pipeline builds' include_context 'pipeline builds'
let(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
before do before do
...@@ -1263,7 +1271,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -1263,7 +1271,7 @@ RSpec.describe 'Pipeline', :js do
end end
context 'when user sees pipeline flags in a pipeline detail page' do context 'when user sees pipeline flags in a pipeline detail page' do
let(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
context 'when pipeline is latest' do context 'when pipeline is latest' do
include_context 'pipeline builds' include_context 'pipeline builds'
......
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