2017-09-15 03:53:28 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::PipelinesSettingsController do
|
|
|
|
set(:user) { create(:user) }
|
|
|
|
set(:project_auto_devops) { create(:project_auto_devops) }
|
|
|
|
let(:project) { project_auto_devops.project }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_master(user)
|
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'PATCH update' do
|
2017-11-17 11:24:40 -05:00
|
|
|
subject do
|
2017-09-15 03:53:28 -04:00
|
|
|
patch :update,
|
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
2017-12-04 06:27:21 -05:00
|
|
|
project: {
|
|
|
|
auto_devops_attributes: params
|
|
|
|
}
|
2017-09-15 03:53:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when updating the auto_devops settings' do
|
2017-09-18 05:54:48 -04:00
|
|
|
let(:params) { { enabled: '', domain: 'mepmep.md' } }
|
|
|
|
|
2017-09-15 03:53:28 -04:00
|
|
|
it 'redirects to the settings page' do
|
2017-11-17 11:24:40 -05:00
|
|
|
subject
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
2017-09-15 03:53:28 -04:00
|
|
|
expect(flash[:notice]).to eq("Pipelines settings for '#{project.name}' were successfully updated.")
|
|
|
|
end
|
2017-09-18 05:54:48 -04:00
|
|
|
|
|
|
|
context 'following the instance default' do
|
|
|
|
let(:params) { { enabled: '' } }
|
|
|
|
|
|
|
|
it 'allows enabled to be set to nil' do
|
2017-11-17 11:24:40 -05:00
|
|
|
subject
|
2017-09-18 05:54:48 -04:00
|
|
|
project_auto_devops.reload
|
|
|
|
|
|
|
|
expect(project_auto_devops.enabled).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2017-11-17 11:24:40 -05:00
|
|
|
|
|
|
|
context 'when run_auto_devops_pipeline is true' do
|
2017-12-04 06:27:21 -05:00
|
|
|
before do
|
|
|
|
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(true)
|
|
|
|
end
|
2017-11-17 11:24:40 -05:00
|
|
|
|
|
|
|
it 'queues a CreatePipelineWorker' do
|
|
|
|
expect(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when run_auto_devops_pipeline is not true' do
|
2017-12-04 06:27:21 -05:00
|
|
|
before do
|
|
|
|
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(false)
|
|
|
|
end
|
2017-11-17 11:24:40 -05:00
|
|
|
|
|
|
|
it 'does not queue a CreatePipelineWorker' do
|
|
|
|
expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, :web, any_args)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
2017-09-15 03:53:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|