Commit 011d0a4e authored by a_luna's avatar a_luna

Add more specs for WebIdeTerminalsController#retry

parent b6afb8b5
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
require 'spec_helper' require 'spec_helper'
describe Projects::WebIdeTerminalsController do describe Projects::WebIdeTerminalsController do
let(:owner) { create(:owner) } let_it_be(:owner) { create(:owner) }
let(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
let(:maintainer) { create(:user) } let_it_be(:maintainer) { create(:user) }
let(:developer) { create(:user) } let_it_be(:developer) { create(:user) }
let(:reporter) { create(:user) } let_it_be(:reporter) { create(:user) }
let(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
let(:project) { create(:project, :private, :repository, namespace: owner.namespace) } let_it_be(:project) { create(:project, :private, :repository, namespace: owner.namespace) }
let(:pipeline) { create(:ci_pipeline, project: project, source: :webide, config_source: :webide_source, user: user) } let(:pipeline) { create(:ci_pipeline, project: project, source: :webide, config_source: :webide_source, user: user) }
let(:job) { create(:ci_build, pipeline: pipeline, user: user, project: project) } let(:job) { create(:ci_build, pipeline: pipeline, user: user, project: project) }
let(:user) { maintainer } let(:user) { maintainer }
...@@ -206,7 +206,8 @@ describe Projects::WebIdeTerminalsController do ...@@ -206,7 +206,8 @@ describe Projects::WebIdeTerminalsController do
end end
describe 'POST retry' do describe 'POST retry' do
let(:job) { create(:ci_build, :failed, pipeline: pipeline, user: user, project: project) } let(:status) { :failed }
let(:job) { create(:ci_build, status, pipeline: pipeline, user: user, project: project) }
before do before do
post(:retry, params: { post(:retry, params: {
...@@ -220,11 +221,35 @@ describe Projects::WebIdeTerminalsController do ...@@ -220,11 +221,35 @@ describe Projects::WebIdeTerminalsController do
it_behaves_like 'when pipeline is not from a webide source' it_behaves_like 'when pipeline is not from a webide source'
context 'when job is not retryable' do context 'when job is not retryable' do
let!(:job) { create(:ci_build, :running, pipeline: pipeline, user: user) } let(:status) { :running }
it 'returns 422' do it 'returns 422' do
expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
context 'when job is cancelled' do
let(:status) { :canceled }
it 'returns 200' do
expect(response).to have_gitlab_http_status(:ok)
end
end
context 'when job fails' do
let(:status) { :failed }
it 'returns 200' do
expect(response).to have_gitlab_http_status(:ok)
end
end
context 'when job is successful' do
let(:status) { :success }
it 'returns 200' do
expect(response).to have_gitlab_http_status(:ok)
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