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
27b9eca4
Commit
27b9eca4
authored
Nov 18, 2020
by
fjsanpedro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Snippet#blobs method
parent
05ce22b8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
11 deletions
+4
-11
app/models/snippet.rb
app/models/snippet.rb
+2
-1
spec/models/snippet_spec.rb
spec/models/snippet_spec.rb
+2
-10
No files found.
app/models/snippet.rb
View file @
27b9eca4
...
@@ -213,7 +213,8 @@ class Snippet < ApplicationRecord
...
@@ -213,7 +213,8 @@ class Snippet < ApplicationRecord
def
blobs
def
blobs
return
[]
unless
repository_exists?
return
[]
unless
repository_exists?
repository
.
ls_files
(
default_branch
).
map
{
|
file
|
Blob
.
lazy
(
repository
,
default_branch
,
file
)
}
branch
=
default_branch
list_files
(
branch
).
map
{
|
file
|
Blob
.
lazy
(
repository
,
branch
,
file
)
}
end
end
def
hook_attrs
def
hook_attrs
...
...
spec/models/snippet_spec.rb
View file @
27b9eca4
...
@@ -481,17 +481,9 @@ RSpec.describe Snippet do
...
@@ -481,17 +481,9 @@ RSpec.describe Snippet do
end
end
describe
'#blobs'
do
describe
'#blobs'
do
context
'when repository does not exist'
do
let
(
:snippet
)
{
create
(
:snippet
)
}
let
(
:snippet
)
{
create
(
:snippet
)
}
it
'returns a blob representing the snippet data'
do
blob
=
snippet
.
blob
expect
(
blob
).
to
be_a
(
Blob
)
expect
(
blob
.
path
).
to
eq
(
snippet
.
file_name
)
expect
(
blob
.
data
).
to
eq
(
snippet
.
content
)
end
context
'when repository does not exist'
do
it
'returns empty array'
do
it
'returns empty array'
do
expect
(
snippet
.
blobs
).
to
be_empty
expect
(
snippet
.
blobs
).
to
be_empty
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