Move cache reset to ci_cd_settings controller
This commit is contained in:
parent
7b52a3482e
commit
f834e2907d
|
@ -11,6 +11,15 @@ module Projects
|
||||||
define_auto_devops_variables
|
define_auto_devops_variables
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_cache
|
||||||
|
if ResetProjectCacheService.new(@project, current_user).execute
|
||||||
|
flash[:notice] = _("Project cache successfully reset.")
|
||||||
|
else
|
||||||
|
flash[:error] = _("Unable to reset project cache.")
|
||||||
|
end
|
||||||
|
redirect_to project_pipelines_path(@project)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def define_runners_variables
|
def define_runners_variables
|
||||||
|
|
|
@ -175,15 +175,6 @@ class ProjectsController < Projects::ApplicationController
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_cache
|
|
||||||
if ResetProjectCacheService.new(@project, current_user).execute
|
|
||||||
flash[:notice] = _("Project cache successfully reset.")
|
|
||||||
else
|
|
||||||
flash[:error] = _("Unable to reset project cache.")
|
|
||||||
end
|
|
||||||
redirect_to project_pipelines_path(@project)
|
|
||||||
end
|
|
||||||
|
|
||||||
def export
|
def export
|
||||||
@project.add_export_job(current_user: current_user)
|
@project.add_export_job(current_user: current_user)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"can-create-pipeline" => can?(current_user, :create_pipeline, @project).to_s,
|
"can-create-pipeline" => can?(current_user, :create_pipeline, @project).to_s,
|
||||||
"has-ci" => @repository.gitlab_ci_yml,
|
"has-ci" => @repository.gitlab_ci_yml,
|
||||||
"ci-lint-path" => ci_lint_path,
|
"ci-lint-path" => ci_lint_path,
|
||||||
"reset-cache-path" => reset_cache_project_path(@project) } }
|
"reset-cache-path" => reset_cache_project_settings_ci_cd_path(@project) } }
|
||||||
|
|
||||||
= page_specific_javascript_bundle_tag('common_vue')
|
= page_specific_javascript_bundle_tag('common_vue')
|
||||||
= page_specific_javascript_bundle_tag('pipelines')
|
= page_specific_javascript_bundle_tag('pipelines')
|
||||||
|
|
|
@ -407,7 +407,9 @@ constraints(ProjectUrlConstrainer.new) do
|
||||||
end
|
end
|
||||||
namespace :settings do
|
namespace :settings do
|
||||||
get :members, to: redirect("%{namespace_id}/%{project_id}/project_members")
|
get :members, to: redirect("%{namespace_id}/%{project_id}/project_members")
|
||||||
resource :ci_cd, only: [:show], controller: 'ci_cd'
|
resource :ci_cd, only: [:show], controller: 'ci_cd' do
|
||||||
|
get :reset_cache
|
||||||
|
end
|
||||||
resource :integrations, only: [:show]
|
resource :integrations, only: [:show]
|
||||||
resource :repository, only: [:show], controller: :repository
|
resource :repository, only: [:show], controller: :repository
|
||||||
end
|
end
|
||||||
|
@ -436,7 +438,6 @@ constraints(ProjectUrlConstrainer.new) do
|
||||||
get :download_export
|
get :download_export
|
||||||
get :activity
|
get :activity
|
||||||
get :refs
|
get :refs
|
||||||
get :reset_cache
|
|
||||||
put :new_issuable_address
|
put :new_issuable_address
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,4 +17,51 @@ describe Projects::Settings::CiCdController do
|
||||||
expect(response).to render_template(:show)
|
expect(response).to render_template(:show)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -686,53 +686,6 @@ describe ProjectsController do
|
||||||
end
|
end
|
||||||
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, 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
|
|
||||||
|
|
||||||
describe '#export' do
|
describe '#export' do
|
||||||
before do
|
before do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
|
Loading…
Reference in New Issue