Commit 4b962efc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add extra data for RenderBlob json

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 2ae9c890
...@@ -14,7 +14,11 @@ module RendersBlob ...@@ -14,7 +14,11 @@ module RendersBlob
return render_404 unless viewer return render_404 unless viewer
render json: { render json: {
html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false) html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false),
plain: blob.data,
name: blob.name,
size: blob.size,
mime_type: blob.mime_type
} }
end end
......
...@@ -35,6 +35,26 @@ describe Projects::BlobController do ...@@ -35,6 +35,26 @@ describe Projects::BlobController do
end end
end end
context 'with file path and JSON format' do
context "valid branch, valid file" do
let(:id) { 'master/README.md' }
before do
get(:show,
namespace_id: project.namespace,
project_id: project,
id: id,
format: :json)
end
it do
expect(response).to be_ok
expect(json_response).to have_key 'html'
expect(json_response).to have_key 'plain'
end
end
end
context 'with tree path' do context 'with tree path' do
before do before do
get(:show, get(:show,
......
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