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
06e7bcf8
Commit
06e7bcf8
authored
Oct 22, 2019
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add size attribute to BlobEntity
parent
92490c32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
app/serializers/diff_file_base_entity.rb
app/serializers/diff_file_base_entity.rb
+8
-0
spec/serializers/blob_entity_spec.rb
spec/serializers/blob_entity_spec.rb
+10
-2
spec/serializers/diff_file_base_entity_spec.rb
spec/serializers/diff_file_base_entity_spec.rb
+13
-2
No files found.
app/serializers/diff_file_base_entity.rb
View file @
06e7bcf8
...
...
@@ -89,6 +89,14 @@ class DiffFileBaseEntity < Grape::Entity
expose
:viewer
,
using:
DiffViewerEntity
expose
:old_size
do
|
diff_file
|
diff_file
.
old_blob
&
.
raw_size
end
expose
:new_size
do
|
diff_file
|
diff_file
.
new_blob
&
.
raw_size
end
private
def
memoized_submodule_links
(
diff_file
,
options
)
...
...
spec/serializers/blob_entity_spec.rb
View file @
06e7bcf8
...
...
@@ -15,8 +15,16 @@ describe BlobEntity do
context
'as json'
do
subject
{
entity
.
as_json
}
it
'exposes needed attributes'
do
expect
(
subject
).
to
include
(
:readable_text
,
:url
)
it
'contains needed attributes'
do
expect
(
subject
).
to
include
({
id:
blob
.
id
,
path:
blob
.
path
,
name:
blob
.
name
,
mode:
"100644"
,
readable_text:
true
,
icon:
"file-text-o"
,
url:
"/
#{
project
.
full_path
}
/blob/master/bar/branch-test.txt"
})
end
end
end
spec/serializers/diff_file_base_entity_spec.rb
View file @
06e7bcf8
...
...
@@ -5,15 +5,15 @@ require 'spec_helper'
describe
DiffFileBaseEntity
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:entity
)
{
described_class
.
new
(
diff_file
,
options
).
as_json
}
context
'diff for a changed submodule'
do
let
(
:commit_sha_with_changed_submodule
)
do
"cfe32cf61b73a0d5e9f13e774abde7ff789b1660"
end
let
(
:commit
)
{
project
.
commit
(
commit_sha_with_changed_submodule
)
}
let
(
:diff_file
)
{
commit
.
diffs
.
diff_files
.
to_a
.
last
}
let
(
:options
)
{
{
request:
{},
submodule_links:
Gitlab
::
SubmoduleLinks
.
new
(
repository
)
}
}
let
(
:
entity
)
{
described_class
.
new
(
diff_file
,
options
).
as_json
}
let
(
:
diff_file
)
{
commit
.
diffs
.
diff_files
.
to_a
.
last
}
it
do
expect
(
entity
[
:submodule
]).
to
eq
(
true
)
...
...
@@ -23,4 +23,15 @@ describe DiffFileBaseEntity do
)
end
end
context
'contains raw sizes for the blob'
do
let
(
:commit
)
{
project
.
commit
(
'png-lfs'
)
}
let
(
:options
)
{
{
request:
{}
}
}
let
(
:diff_file
)
{
commit
.
diffs
.
diff_files
.
to_a
.
second
}
it
do
expect
(
entity
[
:old_size
]).
to
eq
(
1219696
)
expect
(
entity
[
:new_size
]).
to
eq
(
132
)
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