Add extra data for RenderBlob json
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
2ae9c890e7
commit
4b962efc01
2 changed files with 25 additions and 1 deletions
|
@ -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
|
||||||
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,
|
||||||
|
|
Loading…
Reference in a new issue