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
e702e4c9
Commit
e702e4c9
authored
Jul 14, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix snippet url helper when repository is not present
Changelog: fixed
parent
a551f185
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
app/helpers/routing/snippets_helper.rb
app/helpers/routing/snippets_helper.rb
+1
-1
spec/helpers/gitlab_routing_helper_spec.rb
spec/helpers/gitlab_routing_helper_spec.rb
+14
-3
No files found.
app/helpers/routing/snippets_helper.rb
View file @
e702e4c9
...
...
@@ -49,7 +49,7 @@ module Routing
def
gitlab_raw_snippet_blob_url
(
snippet
,
path
,
ref
=
nil
,
**
options
)
params
=
{
snippet_id:
snippet
,
ref:
ref
||
snippet
.
repository
.
root_ref
,
ref:
ref
||
snippet
.
default_branch
,
path:
path
}
...
...
spec/helpers/gitlab_routing_helper_spec.rb
View file @
e702e4c9
...
...
@@ -239,8 +239,9 @@ RSpec.describe GitlabRoutingHelper do
let
(
:blob
)
{
snippet
.
blobs
.
first
}
let
(
:ref
)
{
'snippet-test-ref'
}
let
(
:args
)
{
{}
}
let
(
:path
)
{
blob
.
path
}
subject
{
gitlab_raw_snippet_blob_url
(
snippet
,
blob
.
path
,
ref
,
**
args
)
}
subject
{
gitlab_raw_snippet_blob_url
(
snippet
,
path
,
ref
,
**
args
)
}
it_behaves_like
'snippet blob raw url'
...
...
@@ -248,7 +249,7 @@ RSpec.describe GitlabRoutingHelper do
let
(
:args
)
{
{
inline:
true
}
}
let
(
:snippet
)
{
personal_snippet
}
it
{
expect
(
subject
).
to
eq
(
"http://test.host/-/snippets/
#{
snippet
.
id
}
/raw/
#{
ref
}
/
#{
blob
.
path
}
?inline=true"
)
}
it
{
expect
(
subject
).
to
eq
(
"http://test.host/-/snippets/
#{
snippet
.
id
}
/raw/
#{
ref
}
/
#{
path
}
?inline=true"
)
}
end
context
'without a ref'
do
...
...
@@ -257,7 +258,17 @@ RSpec.describe GitlabRoutingHelper do
let
(
:expected_ref
)
{
snippet
.
repository
.
root_ref
}
it
'uses the root ref'
do
expect
(
subject
).
to
eq
(
"http://test.host/-/snippets/
#{
snippet
.
id
}
/raw/
#{
expected_ref
}
/
#{
blob
.
path
}
"
)
expect
(
subject
).
to
eq
(
"http://test.host/-/snippets/
#{
snippet
.
id
}
/raw/
#{
expected_ref
}
/
#{
path
}
"
)
end
context
'when snippet does not have a repository'
do
let
(
:snippet
)
{
create
(
:personal_snippet
)
}
let
(
:path
)
{
'example'
}
let
(
:expected_ref
)
{
Gitlab
::
DefaultBranch
.
value
}
it
'uses the instance deafult branch'
do
expect
(
subject
).
to
eq
(
"http://test.host/-/snippets/
#{
snippet
.
id
}
/raw/
#{
expected_ref
}
/
#{
path
}
"
)
end
end
end
end
...
...
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