Commit cdb10bf9 authored by David Fernandez's avatar David Fernandez

Merge branch '330737_fix_blob_preview' into 'master'

Fix blob preview error

See merge request gitlab-org/gitlab!62128
parents c15911af 2b72facc
......@@ -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
......
---
title: Fix blob preview error
merge_request: 62128
author:
type: fixed
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment