diff options
| author | Matija Čupić <matteeyah@gmail.com> | 2018-03-11 23:51:10 +0100 |
|---|---|---|
| committer | Matija Čupić <matteeyah@gmail.com> | 2018-03-11 23:53:02 +0100 |
| commit | 92d361c8d34d3ef29ff546ed1f7b74ce9a8f81f4 (patch) | |
| tree | 30ffe667f77dce921ed15feca7bf805b3043165b /spec | |
| parent | afd2d381119c3778140c3dd63c7ef24ecdb4c62e (diff) | |
| download | gitlab-ce-92d361c8d34d3ef29ff546ed1f7b74ce9a8f81f4.tar.gz | |
Add empty repo check before running AutoDevOps pipeline
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/projects/pipelines_settings_controller_spec.rb | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/controllers/projects/pipelines_settings_controller_spec.rb b/spec/controllers/projects/pipelines_settings_controller_spec.rb index 1cc488bef32..0dd8575e2b7 100644 --- a/spec/controllers/projects/pipelines_settings_controller_spec.rb +++ b/spec/controllers/projects/pipelines_settings_controller_spec.rb @@ -47,10 +47,38 @@ describe Projects::PipelinesSettingsController do expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(true) end - it 'queues a CreatePipelineWorker' do - expect(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) + context 'when the project repository is empty' do + before do + allow_any_instance_of(Project).to receive(:empty_repo?).and_return(true) + end - subject + it 'sets a warning flash' do + expect(subject).to set_flash[:warning] + end + + it 'does not queue a CreatePipelineWorker' do + expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) + + subject + end + end + + context 'when the project repository is not empty' do + before do + allow_any_instance_of(Project).to receive(:empty_repo?).and_return(false) + end + + it 'sets a success flash' do + allow(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) + + expect(subject).to set_flash[:success] + end + + 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 end |
