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
before_action :whitelist_query_limiting, only: [:create, :retry]
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_create_pipeline!, only: [:new, :create]
before_action :authorize_update_pipeline!, only: [:retry, :cancel]
......
......@@ -4,6 +4,8 @@ module EE
extend ActiveSupport::Concern
def security
commit
if @pipeline.sast_artifact
render_show
else
......
......@@ -13,28 +13,38 @@ describe Projects::PipelinesController do
describe 'GET security' do
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
let(:build) do
create(
:ci_build,
:artifacts,
name: 'sast',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::Build::SAST_FILE]
context 'with a sast artifact' do
before do
create(
:ci_build,
:artifacts,
name: 'sast',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::Build::SAST_FILE]
}
}
}
)
end
)
get :security, namespace_id: project.namespace, project_id: project, id: pipeline
end
before do
build
get :security, namespace_id: project.namespace, project_id: project, id: pipeline
it do
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template :show
end
end
it do
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template :show
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
......@@ -12,23 +12,19 @@ describe 'Pipeline', :js do
describe 'GET /:project/pipelines/:id/security' do
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
let(:build) 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
context 'with a sast artifact' 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)
end
......@@ -51,6 +47,7 @@ describe 'Pipeline', :js do
it 'displays the pipeline graph' do
expect(current_path).to eq(pipeline_path(pipeline))
expect(page).not_to have_content('Security report')
expect(page).to have_selector('.pipeline-visualization')
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