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
cdb10bf9
Commit
cdb10bf9
authored
May 20, 2021
by
David Fernandez
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '330737_fix_blob_preview' into 'master'
Fix blob preview error See merge request gitlab-org/gitlab!62128
parents
c15911af
2b72facc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
changelogs/unreleased/330737_fix_blob_preview.yml
changelogs/unreleased/330737_fix_blob_preview.yml
+5
-0
spec/controllers/projects/blob_controller_spec.rb
spec/controllers/projects/blob_controller_spec.rb
+34
-0
No files found.
app/controllers/projects/blob_controller.rb
View file @
cdb10bf9
...
...
@@ -92,7 +92,7 @@ class Projects::BlobController < Projects::ApplicationController
@blob
.
load_all_data!
diffy
=
Diffy
::
Diff
.
new
(
@blob
.
data
,
@content
,
diff:
'-U 3'
,
include_diff_info:
true
)
diff_lines
=
diffy
.
diff
.
scan
(
/.*\n/
)[
2
..-
1
]
diff_lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff_lines
)
diff_lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff_lines
)
.
to_a
@diff_lines
=
Gitlab
::
Diff
::
Highlight
.
new
(
diff_lines
,
repository:
@repository
).
highlight
render
layout:
false
...
...
changelogs/unreleased/330737_fix_blob_preview.yml
0 → 100644
View file @
cdb10bf9
---
title
:
Fix blob preview error
merge_request
:
62128
author
:
type
:
fixed
spec/controllers/projects/blob_controller_spec.rb
View file @
cdb10bf9
...
...
@@ -444,6 +444,40 @@ RSpec.describe Projects::BlobController do
end
end
describe
'POST preview'
do
subject
(
:request
)
{
post
:preview
,
params:
default_params
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:filename
)
{
'preview.md'
}
let
(
:default_params
)
do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
"
#{
project
.
default_branch
}
/
#{
filename
}
"
,
content:
"Bar
\n
"
}
end
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
project
.
repository
.
create_file
(
project
.
creator
,
filename
,
"Foo
\n
"
,
message:
'Test'
,
branch_name:
project
.
default_branch
)
end
it
'is successful'
do
request
expect
(
response
).
to
be_successful
end
end
describe
'POST create'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:default_params
)
do
...
...
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