Commit 153537a8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve integration/feature specs for pipeline security page

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent dc606b39
...@@ -3,7 +3,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -3,7 +3,7 @@ class Projects::PipelinesController < Projects::ApplicationController
before_action :whitelist_query_limiting, only: [:create, :retry] before_action :whitelist_query_limiting, only: [:create, :retry]
before_action :pipeline, except: [:index, :new, :create, :charts] before_action :pipeline, except: [:index, :new, :create, :charts]
before_action :commit, only: [:show, :builds, :failures, :security] before_action :commit, only: [:show, :builds, :failures]
before_action :authorize_read_pipeline! before_action :authorize_read_pipeline!
before_action :authorize_create_pipeline!, only: [:new, :create] before_action :authorize_create_pipeline!, only: [:new, :create]
before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action :authorize_update_pipeline!, only: [:retry, :cancel]
......
...@@ -4,6 +4,8 @@ module EE ...@@ -4,6 +4,8 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
def security def security
commit
if @pipeline.sast_artifact if @pipeline.sast_artifact
render_show render_show
else else
......
...@@ -13,7 +13,8 @@ describe Projects::PipelinesController do ...@@ -13,7 +13,8 @@ describe Projects::PipelinesController do
describe 'GET security' do describe 'GET security' do
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) }
let(:build) do context 'with a sast artifact' do
before do
create( create(
:ci_build, :ci_build,
:artifacts, :artifacts,
...@@ -25,10 +26,7 @@ describe Projects::PipelinesController do ...@@ -25,10 +26,7 @@ describe Projects::PipelinesController do
} }
} }
) )
end
before do
build
get :security, namespace_id: project.namespace, project_id: project, id: pipeline get :security, namespace_id: project.namespace, project_id: project, id: pipeline
end end
...@@ -37,4 +35,16 @@ describe Projects::PipelinesController do ...@@ -37,4 +35,16 @@ describe Projects::PipelinesController do
expect(response).to render_template :show expect(response).to render_template :show
end end
end end
context 'without sast artifact' do
before do
get :security, namespace_id: project.namespace, project_id: project, id: pipeline
end
it do
expect(response).to have_gitlab_http_status(:redirect)
expect(response).to redirect_to(pipeline_path(pipeline))
end
end
end
end end
...@@ -12,7 +12,8 @@ describe 'Pipeline', :js do ...@@ -12,7 +12,8 @@ describe 'Pipeline', :js do
describe 'GET /:project/pipelines/:id/security' do describe 'GET /:project/pipelines/:id/security' do
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) }
let(:build) do context 'with a sast artifact' do
before do
create( create(
:ci_build, :ci_build,
:artifacts, :artifacts,
...@@ -24,11 +25,6 @@ describe 'Pipeline', :js do ...@@ -24,11 +25,6 @@ describe 'Pipeline', :js do
} }
} }
) )
end
context 'when there is a sast artifact' do
before do
build
visit security_project_pipeline_path(project, pipeline) visit security_project_pipeline_path(project, pipeline)
end end
...@@ -51,6 +47,7 @@ describe 'Pipeline', :js do ...@@ -51,6 +47,7 @@ describe 'Pipeline', :js do
it 'displays the pipeline graph' do it 'displays the pipeline graph' do
expect(current_path).to eq(pipeline_path(pipeline)) expect(current_path).to eq(pipeline_path(pipeline))
expect(page).not_to have_content('Security report') expect(page).not_to have_content('Security report')
expect(page).to have_selector('.pipeline-visualization')
end end
end end
end end
......
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