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
002a380f
Commit
002a380f
authored
3 years ago
by
Katrin Leinweber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include branch name(s) in "is invalid" alert
parent
9f5bdd47
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
app/controllers/projects/compare_controller.rb
app/controllers/projects/compare_controller.rb
+3
-3
spec/controllers/projects/compare_controller_spec.rb
spec/controllers/projects/compare_controller_spec.rb
+15
-2
No files found.
app/controllers/projects/compare_controller.rb
View file @
002a380f
...
...
@@ -79,11 +79,11 @@ class Projects::CompareController < Projects::ApplicationController
private
def
validate_refs!
valid
=
[
head_ref
,
start_ref
].
map
{
|
ref
|
valid_ref?
(
ref
)
}
invalid
=
[
head_ref
,
start_ref
].
filter
{
|
ref
|
!
valid_ref?
(
ref
)
}
return
if
valid
.
all
?
return
if
invalid
.
empty
?
flash
[
:alert
]
=
"Invalid branch name"
flash
[
:alert
]
=
"Invalid branch name
(s):
#{
invalid
.
join
(
', '
)
}
"
redirect_to
project_compare_index_path
(
source_project
)
end
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/projects/compare_controller_spec.rb
View file @
002a380f
...
...
@@ -156,7 +156,7 @@ RSpec.describe Projects::CompareController do
it
'shows a flash message and redirects'
do
show_request
expect
(
flash
[
:alert
]).
to
eq
(
'Invalid branch name'
)
expect
(
flash
[
:alert
]).
to
eq
(
"Invalid branch name(s): master%' AND 2554=4423 AND '%'='"
)
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
end
end
...
...
@@ -169,7 +169,20 @@ RSpec.describe Projects::CompareController do
it
'shows a flash message and redirects'
do
show_request
expect
(
flash
[
:alert
]).
to
eq
(
'Invalid branch name'
)
expect
(
flash
[
:alert
]).
to
eq
(
"Invalid branch name(s): master%' AND 2554=4423 AND '%'='"
)
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
end
end
context
'when the both refs are invalid'
do
let
(
:from_project_id
)
{
nil
}
let
(
:from_ref
)
{
"master%' AND 2554=4423 AND '%'='"
}
let
(
:to_ref
)
{
"improve%' =,awesome"
}
it
'shows a flash message and redirects'
do
show_request
expect
(
flash
[
:alert
]).
to
eq
(
"Invalid branch name(s): improve%' =,awesome, master%' AND 2554=4423 AND '%'='"
)
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
end
end
...
...
This diff is collapsed.
Click to expand it.
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