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
1eb207f3
Commit
1eb207f3
authored
Dec 21, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for projects#reset_cache
parent
a8c016d5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+6
-0
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+47
-0
No files found.
app/controllers/projects_controller.rb
View file @
1eb207f3
...
...
@@ -176,6 +176,12 @@ 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
...
...
spec/controllers/projects_controller_spec.rb
View file @
1eb207f3
...
...
@@ -686,6 +686,53 @@ 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