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,28 +13,38 @@ describe Projects::PipelinesController do ...@@ -13,28 +13,38 @@ 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
create( before do
:ci_build, create(
:artifacts, :ci_build,
name: 'sast', :artifacts,
pipeline: pipeline, name: 'sast',
options: { pipeline: pipeline,
artifacts: { options: {
paths: [Ci::Build::SAST_FILE] artifacts: {
paths: [Ci::Build::SAST_FILE]
}
} }
} )
)
end get :security, namespace_id: project.namespace, project_id: project, id: pipeline
end
before do it do
build expect(response).to have_gitlab_http_status(200)
get :security, namespace_id: project.namespace, project_id: project, id: pipeline expect(response).to render_template :show
end
end end
it do context 'without sast artifact' do
expect(response).to have_gitlab_http_status(200) before do
expect(response).to render_template :show 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
end end
...@@ -12,23 +12,19 @@ describe 'Pipeline', :js do ...@@ -12,23 +12,19 @@ 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
create(
:ci_build,
:artifacts,
name: 'sast',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::Build::SAST_FILE]
}
}
)
end
context 'when there is a sast artifact' do
before do before do
build create(
:ci_build,
:artifacts,
name: 'sast',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::Build::SAST_FILE]
}
}
)
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