Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
635c3741992f
Commit
635c3741
authored
Oct 01, 2017
by
Guilherme Vieira
Browse files
Renders 404 in commits controller if no commits are found
parent
b7f8915d44a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/controllers/projects/commits_controller.rb
View file @
635c3741
...
...
@@ -48,6 +48,8 @@
private
def
set_commits
render_404
unless
request
.
format
==
:atom
||
@repository
.
blob_at
(
@commit
.
id
,
@path
)
||
@repository
.
tree
(
@commit
.
id
,
@path
).
entries
.
present?
@limit
,
@offset
=
(
params
[
:limit
]
||
40
).
to_i
,
(
params
[
:offset
]
||
0
).
to_i
search
=
params
[
:search
]
...
...
changelogs/unreleased/not-found-in-commits.yml
0 → 100644
View file @
635c3741
---
title
:
Renders 404 in commits controller if no commits are found for a given path
merge_request
:
14610
author
:
Guilherme Vieira
type
:
fixed
features/steps/shared/paths.rb
View file @
635c3741
...
...
@@ -222,7 +222,7 @@
end
step
"I visit my project's commits page for a specific path"
do
visit
project_commits_path
(
@project
,
root_ref
+
"/
app/models/project
.rb"
,
{
limit:
5
})
visit
project_commits_path
(
@project
,
root_ref
+
"/
files/ruby/regex
.rb"
,
{
limit:
5
})
end
step
'I visit my project\'s commits stats page'
do
...
...
spec/controllers/projects/commits_controller_spec.rb
View file @
635c3741
...
...
@@ -10,4 +10,33 @@
end
describe
"GET show"
do
render_views
context
'with file path'
do
before
do
get
(
:show
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
id
)
end
context
"valid branch, valid file"
do
let
(
:id
)
{
'master/README.md'
}
it
{
is_expected
.
to
respond_with
(
:success
)
}
end
context
"valid branch, invalid file"
do
let
(
:id
)
{
'master/invalid-path.rb'
}
it
{
is_expected
.
to
respond_with
(
:not_found
)
}
end
context
"invalid branch, valid file"
do
let
(
:id
)
{
'invalid-branch/README.md'
}
it
{
is_expected
.
to
respond_with
(
:not_found
)
}
end
end
context
"when the ref name ends in .atom"
do
...
...
@@ -13,6 +42,4 @@
context
"when the ref name ends in .atom"
do
render_views
context
"when the ref does not exist with the suffix"
do
it
"renders as atom"
do
get
(
:show
,
...
...
Write
Preview
Supports
Markdown
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