diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-01-04 19:13:30 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-01-04 22:17:01 +0100 |
commit | f834e2907d5111f3e2bcd8d0dd126f9e0dd0be7a (patch) | |
tree | 337796d2646a3483ceab82d8400793fdf0a3f1f3 /spec/controllers/projects/settings/ci_cd_controller_spec.rb | |
parent | 7b52a3482ec696320e4a101a80537e4e61118b5c (diff) | |
download | gitlab-ce-f834e2907d5111f3e2bcd8d0dd126f9e0dd0be7a.tar.gz |
Move cache reset to ci_cd_settings controller
Diffstat (limited to 'spec/controllers/projects/settings/ci_cd_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/settings/ci_cd_controller_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/controllers/projects/settings/ci_cd_controller_spec.rb b/spec/controllers/projects/settings/ci_cd_controller_spec.rb index b8fe0f46f57..acd40f4a305 100644 --- a/spec/controllers/projects/settings/ci_cd_controller_spec.rb +++ b/spec/controllers/projects/settings/ci_cd_controller_spec.rb @@ -17,4 +17,51 @@ describe Projects::Settings::CiCdController do expect(response).to render_template(:show) end end + + describe '#reset_cache' do + before do + sign_in(user) + + project.add_master(user) + + allow(ResetProjectCacheService).to receive_message_chain(:new, :execute).and_return(true) + end + + subject { get :reset_cache, namespace_id: project.namespace, project_id: project } + + it 'calls reset project cache service' do + expect(ResetProjectCacheService).to receive_message_chain(:new, :execute) + + subject + end + + it 'redirects to project pipelines path' do + subject + + expect(response).to have_gitlab_http_status(:redirect) + expect(response).to redirect_to(project_pipelines_path(project)) + end + + context 'when service returns successfully' do + it 'sets the flash notice variable' do + subject + + expect(controller).to set_flash[:notice] + expect(controller).not_to set_flash[:error] + end + end + + context 'when service does not return successfully' do + before do + allow(ResetProjectCacheService).to receive_message_chain(:new, :execute).and_return(false) + end + + it 'sets the flash error variable' do + subject + + expect(controller).not_to set_flash[:notice] + expect(controller).to set_flash[:error] + end + end + end end |