Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
f834e290
Commit
f834e290
authored
Jan 04, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move cache reset to ci_cd_settings controller
parent
7b52a348
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
59 deletions
+60
-59
app/controllers/projects/settings/ci_cd_controller.rb
app/controllers/projects/settings/ci_cd_controller.rb
+9
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+0
-9
app/views/projects/pipelines/index.html.haml
app/views/projects/pipelines/index.html.haml
+1
-1
config/routes/project.rb
config/routes/project.rb
+3
-2
spec/controllers/projects/settings/ci_cd_controller_spec.rb
spec/controllers/projects/settings/ci_cd_controller_spec.rb
+47
-0
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+0
-47
No files found.
app/controllers/projects/settings/ci_cd_controller.rb
View file @
f834e290
...
...
@@ -11,6 +11,15 @@ module Projects
define_auto_devops_variables
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
def
define_runners_variables
...
...
app/controllers/projects_controller.rb
View file @
f834e290
...
...
@@ -175,15 +175,6 @@ class ProjectsController < Projects::ApplicationController
)
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
@project
.
add_export_job
(
current_user:
current_user
)
...
...
app/views/projects/pipelines/index.html.haml
View file @
f834e290
...
...
@@ -11,7 +11,7 @@
"can-create-pipeline"
=>
can?
(
current_user
,
:create_pipeline
,
@project
).
to_s
,
"has-ci"
=>
@repository
.
gitlab_ci_yml
,
"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
(
'pipelines'
)
config/routes/project.rb
View file @
f834e290
...
...
@@ -407,7 +407,9 @@ constraints(ProjectUrlConstrainer.new) do
end
namespace
:settings
do
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
:repository
,
only:
[
:show
],
controller: :repository
end
...
...
@@ -436,7 +438,6 @@ constraints(ProjectUrlConstrainer.new) do
get
:download_export
get
:activity
get
:refs
get
:reset_cache
put
:new_issuable_address
end
end
...
...
spec/controllers/projects/settings/ci_cd_controller_spec.rb
View file @
f834e290
...
...
@@ -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
spec/controllers/projects_controller_spec.rb
View file @
f834e290
...
...
@@ -686,53 +686,6 @@ describe ProjectsController do
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
before
do
sign_in
(
user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment