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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
89a9b3a9
Commit
89a9b3a9
authored
Jun 30, 2020
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirects if scope is not valid
parent
16c547a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+7
-1
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+8
-8
No files found.
app/controllers/projects/pipelines_controller.rb
View file @
89a9b3a9
...
...
@@ -19,6 +19,8 @@ class Projects::PipelinesController < Projects::ApplicationController
end
before_action
:ensure_pipeline
,
only:
[
:show
]
before_action
:ensure_valid_scope
,
only:
[
:index
]
around_action
:allow_gitaly_ref_name_caching
,
only:
[
:index
,
:show
]
track_unique_visits
:charts
,
target_id:
'p_analytics_pipelines'
...
...
@@ -44,7 +46,7 @@ class Projects::PipelinesController < Projects::ApplicationController
render
json:
{
pipelines:
serialize_pipelines
,
count:
{
all:
@pipelines_count
,
all:
@pipelines_count
}
}
end
...
...
@@ -223,6 +225,10 @@ class Projects::PipelinesController < Projects::ApplicationController
render_404
unless
pipeline
end
def
ensure_valid_scope
redirect_to
project_pipelines_path
(
project
,
status:
params
[
:scope
])
if
%w[running pending]
.
include?
(
params
[
:scope
])
end
# rubocop: disable CodeReuse/ActiveRecord
def
pipeline
@pipeline
||=
if
params
[
:id
].
blank?
&&
params
[
:latest
]
...
...
spec/controllers/projects/pipelines_controller_spec.rb
View file @
89a9b3a9
...
...
@@ -119,6 +119,14 @@ RSpec.describe Projects::PipelinesController do
end
end
context
'when scope is pending or running'
do
it
'redirects to all pipelines with that status instead'
do
get_pipelines_index_json
(
scope:
'running'
)
expect
(
response
).
to
redirect_to
(
project_pipelines_path
(
project
,
status:
'running'
))
end
end
context
'filter by scope'
do
context
'scope is branches or tags'
do
before
do
...
...
@@ -192,14 +200,6 @@ RSpec.describe Projects::PipelinesController do
check_pipeline_response
(
returned:
1
,
all:
1
)
end
context
'when filter by unrelated scope'
do
it
'returns empty list'
do
get_pipelines_index_json
(
status:
'success'
,
scope:
'running'
)
check_pipeline_response
(
returned:
0
,
all:
1
)
end
end
end
context
'when no pipeline with the status exists'
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