Add extra data for RenderBlob json

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2017-06-15 21:10:49 +03:00
parent 2ae9c890e7
commit 4b962efc01
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
2 changed files with 25 additions and 1 deletions

View File

@ -14,7 +14,11 @@ module RendersBlob
return render_404 unless viewer
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

View File

@ -35,6 +35,26 @@ describe Projects::BlobController do
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
before do
get(:show,