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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
caf10464
Commit
caf10464
authored
Oct 05, 2018
by
Oswaldo Ferreira
Committed by
Douglas Barbosa Alexandre
Oct 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix LFS uploaded images not being rendered
parent
1bd08177
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
56 additions
and
7 deletions
+56
-7
app/assets/javascripts/diffs/components/diff_content.vue
app/assets/javascripts/diffs/components/diff_content.vue
+1
-1
app/serializers/diff_file_entity.rb
app/serializers/diff_file_entity.rb
+4
-0
app/serializers/diff_viewer_entity.rb
app/serializers/diff_viewer_entity.rb
+7
-0
changelogs/unreleased/osw-fix-lfs-images-not-rendering.yml
changelogs/unreleased/osw-fix-lfs-images-not-rendering.yml
+5
-0
spec/fixtures/api/schemas/entities/diff_viewer.json
spec/fixtures/api/schemas/entities/diff_viewer.json
+8
-0
spec/javascripts/diffs/components/diff_content_spec.js
spec/javascripts/diffs/components/diff_content_spec.js
+2
-3
spec/javascripts/diffs/components/diff_file_spec.js
spec/javascripts/diffs/components/diff_file_spec.js
+2
-3
spec/javascripts/diffs/mock_data/diff_file.js
spec/javascripts/diffs/mock_data/diff_file.js
+3
-0
spec/serializers/diff_file_entity_spec.rb
spec/serializers/diff_file_entity_spec.rb
+5
-0
spec/serializers/diff_viewer_entity_spec.rb
spec/serializers/diff_viewer_entity_spec.rb
+19
-0
No files found.
app/assets/javascripts/diffs/components/diff_content.vue
View file @
caf10464
...
@@ -28,7 +28,7 @@ export default {
...
@@ -28,7 +28,7 @@ export default {
return
diffModes
[
diffModeKey
]
||
diffModes
.
replaced
;
return
diffModes
[
diffModeKey
]
||
diffModes
.
replaced
;
},
},
isTextFile
()
{
isTextFile
()
{
return
this
.
diffFile
.
text
;
return
this
.
diffFile
.
viewer
.
name
===
'
text
'
;
},
},
},
},
};
};
...
...
app/serializers/diff_file_entity.rb
View file @
caf10464
...
@@ -116,6 +116,10 @@ class DiffFileEntity < Grape::Entity
...
@@ -116,6 +116,10 @@ class DiffFileEntity < Grape::Entity
project_blob_path
(
project
,
tree_join
(
diff_file
.
content_sha
,
diff_file
.
new_path
))
project_blob_path
(
project
,
tree_join
(
diff_file
.
content_sha
,
diff_file
.
new_path
))
end
end
expose
:viewer
,
using:
DiffViewerEntity
do
|
diff_file
|
diff_file
.
rich_viewer
||
diff_file
.
simple_viewer
end
expose
:replaced_view_path
,
if:
->
(
_
,
options
)
{
options
[
:merge_request
]
}
do
|
diff_file
|
expose
:replaced_view_path
,
if:
->
(
_
,
options
)
{
options
[
:merge_request
]
}
do
|
diff_file
|
image_diff
=
diff_file
.
rich_viewer
&&
diff_file
.
rich_viewer
.
partial_name
==
'image'
image_diff
=
diff_file
.
rich_viewer
&&
diff_file
.
rich_viewer
.
partial_name
==
'image'
image_replaced
=
diff_file
.
old_content_sha
&&
diff_file
.
old_content_sha
!=
diff_file
.
content_sha
image_replaced
=
diff_file
.
old_content_sha
&&
diff_file
.
old_content_sha
!=
diff_file
.
content_sha
...
...
app/serializers/diff_viewer_entity.rb
0 → 100644
View file @
caf10464
# frozen_string_literal: true
class
DiffViewerEntity
<
Grape
::
Entity
# Partial name refers directly to a Rails feature, let's avoid
# using this on the frontend.
expose
:partial_name
,
as: :name
end
changelogs/unreleased/osw-fix-lfs-images-not-rendering.yml
0 → 100644
View file @
caf10464
---
title
:
Fix LFS uploaded images not being rendered
merge_request
:
22092
author
:
type
:
fixed
spec/fixtures/api/schemas/entities/diff_viewer.json
0 → 100644
View file @
caf10464
{
"type"
:
"object"
,
"required"
:
[
"name"
],
"properties"
:
{
"name"
:
{
"type"
:
[
"string"
]
}
},
"additionalProperties"
:
false
}
spec/javascripts/diffs/components/diff_content_spec.js
View file @
caf10464
...
@@ -8,13 +8,12 @@ import diffFileMockData from '../mock_data/diff_file';
...
@@ -8,13 +8,12 @@ import diffFileMockData from '../mock_data/diff_file';
describe
(
'
DiffContent
'
,
()
=>
{
describe
(
'
DiffContent
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
DiffContentComponent
);
const
Component
=
Vue
.
extend
(
DiffContentComponent
);
let
vm
;
let
vm
;
const
getDiffFileMock
=
()
=>
Object
.
assign
({},
diffFileMockData
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponentWithStore
(
Component
,
{
vm
=
mountComponentWithStore
(
Component
,
{
store
,
store
,
props
:
{
props
:
{
diffFile
:
getDiffFileMock
(
),
diffFile
:
JSON
.
parse
(
JSON
.
stringify
(
diffFileMockData
)
),
},
},
});
});
});
});
...
@@ -43,7 +42,7 @@ describe('DiffContent', () => {
...
@@ -43,7 +42,7 @@ describe('DiffContent', () => {
describe
(
'
Non-Text diffs
'
,
()
=>
{
describe
(
'
Non-Text diffs
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
.
diffFile
.
text
=
false
;
vm
.
diffFile
.
viewer
.
name
=
'
image
'
;
});
});
describe
(
'
image diff
'
,
()
=>
{
describe
(
'
image diff
'
,
()
=>
{
...
...
spec/javascripts/diffs/components/diff_file_spec.js
View file @
caf10464
...
@@ -6,11 +6,10 @@ import diffFileMockData from '../mock_data/diff_file';
...
@@ -6,11 +6,10 @@ import diffFileMockData from '../mock_data/diff_file';
describe
(
'
DiffFile
'
,
()
=>
{
describe
(
'
DiffFile
'
,
()
=>
{
let
vm
;
let
vm
;
const
getDiffFileMock
=
()
=>
Object
.
assign
({},
diffFileMockData
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
DiffFileComponent
),
store
,
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
DiffFileComponent
),
store
,
{
file
:
getDiffFileMock
(
),
file
:
JSON
.
parse
(
JSON
.
stringify
(
diffFileMockData
)
),
canCurrentUserFork
:
false
,
canCurrentUserFork
:
false
,
}).
$mount
();
}).
$mount
();
});
});
...
@@ -18,7 +17,7 @@ describe('DiffFile', () => {
...
@@ -18,7 +17,7 @@ describe('DiffFile', () => {
describe
(
'
template
'
,
()
=>
{
describe
(
'
template
'
,
()
=>
{
it
(
'
should render component with file header, file content components
'
,
()
=>
{
it
(
'
should render component with file header, file content components
'
,
()
=>
{
const
el
=
vm
.
$el
;
const
el
=
vm
.
$el
;
const
{
fileHash
,
filePath
}
=
diffFileMockData
;
const
{
fileHash
,
filePath
}
=
vm
.
file
;
expect
(
el
.
id
).
toEqual
(
fileHash
);
expect
(
el
.
id
).
toEqual
(
fileHash
);
expect
(
el
.
classList
.
contains
(
'
diff-file
'
)).
toEqual
(
true
);
expect
(
el
.
classList
.
contains
(
'
diff-file
'
)).
toEqual
(
true
);
...
...
spec/javascripts/diffs/mock_data/diff_file.js
View file @
caf10464
...
@@ -23,6 +23,9 @@ export default {
...
@@ -23,6 +23,9 @@ export default {
aMode
:
'
100644
'
,
aMode
:
'
100644
'
,
bMode
:
'
100644
'
,
bMode
:
'
100644
'
,
text
:
true
,
text
:
true
,
viewer
:
{
name
:
'
text
'
,
},
addedLines
:
2
,
addedLines
:
2
,
removedLines
:
0
,
removedLines
:
0
,
diffRefs
:
{
diffRefs
:
{
...
...
spec/serializers/diff_file_entity_spec.rb
View file @
caf10464
...
@@ -26,6 +26,11 @@ describe DiffFileEntity do
...
@@ -26,6 +26,11 @@ describe DiffFileEntity do
)
)
end
end
it
'includes viewer'
do
expect
(
subject
[
:viewer
].
with_indifferent_access
)
.
to
match_schema
(
'entities/diff_viewer'
)
end
# Converted diff files from GitHub import does not contain blob file
# Converted diff files from GitHub import does not contain blob file
# and content sha.
# and content sha.
context
'when diff file does not have a blob and content sha'
do
context
'when diff file does not have a blob and content sha'
do
...
...
spec/serializers/diff_viewer_entity_spec.rb
0 → 100644
View file @
caf10464
require
'spec_helper'
describe
DiffViewerEntity
do
include
RepoHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff_refs
)
{
commit
.
diff_refs
}
let
(
:diff
)
{
commit
.
raw_diffs
.
first
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs:
diff_refs
,
repository:
repository
)
}
let
(
:viewer
)
{
diff_file
.
simple_viewer
}
subject
{
described_class
.
new
(
viewer
).
as_json
}
it
'serializes diff file viewer'
do
expect
(
subject
.
with_indifferent_access
).
to
match_schema
(
'entities/diff_viewer'
)
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