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
ef78f67f
Commit
ef78f67f
authored
Dec 09, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a spec for rate limiting pipeline schedules
parent
54f13b1e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
app/controllers/projects/pipeline_schedules_controller.rb
app/controllers/projects/pipeline_schedules_controller.rb
+2
-2
spec/controllers/projects/pipeline_schedules_controller_spec.rb
...ontrollers/projects/pipeline_schedules_controller_spec.rb
+10
-0
No files found.
app/controllers/projects/pipeline_schedules_controller.rb
View file @
ef78f67f
...
...
@@ -45,7 +45,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
limiter
=
::
Gitlab
::
ActionRateLimiter
.
new
(
action:
'play_pipeline_schedule'
)
if
limiter
.
throttled?
(
throttle_key
,
1
)
flash
[
:
notice
]
=
'You cannot play this scheduled pipeline at the moment. Please wait a minute.'
flash
[
:
alert
]
=
'You cannot play this scheduled pipeline at the moment. Please wait a minute.'
return
redirect_to
pipeline_schedules_path
(
@project
)
end
...
...
@@ -53,7 +53,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
flash
[
:notice
]
=
if
job_id
"Successfully scheduled a pipeline to run. Go to the <a href=
\"
#{
project_pipelines_path
(
@project
)
}
\"
>Pipelines page</a> for details"
.
html_safe
"Successfully scheduled a pipeline to run. Go to the <a href=
\"
#{
project_pipelines_path
(
@project
)
}
\"
>Pipelines page</a> for details
.
"
.
html_safe
else
'Unable to schedule a pipeline to run immediately'
end
...
...
spec/controllers/projects/pipeline_schedules_controller_spec.rb
View file @
ef78f67f
...
...
@@ -385,6 +385,16 @@ describe Projects::PipelineSchedulesController do
expect
(
flash
[
:notice
]).
to
start_with
'Successfully scheduled a pipeline to run'
expect
(
response
).
to
have_gitlab_http_status
(
302
)
end
it
'prevents users from scheduling the same pipeline repeatedly'
do
2
.
times
do
post
:play
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
pipeline_schedule
.
id
end
expect
(
flash
.
to_a
.
size
).
to
eq
(
2
)
expect
(
flash
[
:alert
]).
to
eq
'You cannot play this scheduled pipeline at the moment. Please wait a minute.'
expect
(
response
).
to
have_gitlab_http_status
(
302
)
end
end
context
'when a developer attempts to schedule a protected ref'
do
...
...
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