Commit fd333b8d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve tests for security report page

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 3a6ef0ed
...@@ -17,6 +17,7 @@ describe Projects::PipelinesController do ...@@ -17,6 +17,7 @@ describe Projects::PipelinesController do
before do before do
create( create(
:ci_build, :ci_build,
:success,
:artifacts, :artifacts,
name: 'sast', name: 'sast',
pipeline: pipeline, pipeline: pipeline,
...@@ -26,24 +27,56 @@ describe Projects::PipelinesController do ...@@ -26,24 +27,56 @@ describe Projects::PipelinesController do
} }
} }
) )
end
context 'with feature enabled' do
before do
allow(License).to receive(:feature_available?).and_return(true)
get :security, namespace_id: project.namespace, project_id: project, id: pipeline get :security, namespace_id: project.namespace, project_id: project, id: pipeline
end
it do
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template :show
end
end end
it do context 'with feature disabled' 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
context 'without sast artifact' do context 'without sast artifact' do
before do context 'with feature enabled' do
get :security, namespace_id: project.namespace, project_id: project, id: pipeline before do
allow(License).to receive(:feature_available?).and_return(true)
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
it do context 'with feature disabled' do
expect(response).to have_gitlab_http_status(:redirect) before do
expect(response).to redirect_to(pipeline_path(pipeline)) 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
......
...@@ -7,6 +7,8 @@ describe 'Pipeline', :js do ...@@ -7,6 +7,8 @@ describe 'Pipeline', :js do
before do before do
sign_in(user) sign_in(user)
project.add_developer(user) project.add_developer(user)
allow(License).to receive(:feature_available?).and_return(true)
end end
describe 'GET /:project/pipelines/:id/security' do describe 'GET /:project/pipelines/:id/security' do
...@@ -16,6 +18,7 @@ describe 'Pipeline', :js do ...@@ -16,6 +18,7 @@ describe 'Pipeline', :js do
before do before do
create( create(
:ci_build, :ci_build,
:success,
:artifacts, :artifacts,
name: 'sast', name: 'sast',
pipeline: pipeline, pipeline: pipeline,
......
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