summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2018-06-14 19:37:16 +0200
committerTim Zallmann <tzallmann@gitlab.com>2018-06-14 19:37:16 +0200
commit3b2a909ac22b7ac559062973dbd1c951fae3ed43 (patch)
treef48da067230b94279cb1231c17a6198defd1603c
parent20ca5e3041949c09820fc9e467f7e1b9dd980d6c (diff)
downloadgitlab-ce-3b2a909ac22b7ac559062973dbd1c951fae3ed43.tar.gz
Makes the html attribute in the json output optional with the option html_render=false
-rw-r--r--app/assets/javascripts/ide/services/index.js2
-rw-r--r--app/controllers/concerns/renders_blob.rb2
-rw-r--r--spec/controllers/projects/blob_controller_spec.rb18
3 files changed, 21 insertions, 1 deletions
diff --git a/app/assets/javascripts/ide/services/index.js b/app/assets/javascripts/ide/services/index.js
index e8b51f2b516..a8b9afa35d9 100644
--- a/app/assets/javascripts/ide/services/index.js
+++ b/app/assets/javascripts/ide/services/index.js
@@ -9,7 +9,7 @@ export default {
return Vue.http.get(endpoint, { params: { format: 'json' } });
},
getFileData(endpoint) {
- return Vue.http.get(endpoint, { params: { format: 'json' } });
+ return Vue.http.get(endpoint, { params: { format: 'json', html_render: 'false' } });
},
getRawFileData(file) {
if (file.tempFile) {
diff --git a/app/controllers/concerns/renders_blob.rb b/app/controllers/concerns/renders_blob.rb
index ba7adcfea86..f80c908f926 100644
--- a/app/controllers/concerns/renders_blob.rb
+++ b/app/controllers/concerns/renders_blob.rb
@@ -14,6 +14,8 @@ module RendersBlob
return unless viewer
+ return {} if params[:html_render] == 'false'
+
{
html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false)
}
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb
index 00a7df6ccc8..fff363bca7a 100644
--- a/spec/controllers/projects/blob_controller_spec.rb
+++ b/spec/controllers/projects/blob_controller_spec.rb
@@ -55,6 +55,24 @@ describe Projects::BlobController do
expect(json_response).to have_key 'raw_path'
end
end
+
+ context "html_render=false" do
+ let(:id) { 'master/README.md' }
+
+ before do
+ get(:show,
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ format: :json,
+ html_render: false)
+ end
+
+ it do
+ expect(response).to be_ok
+ expect(json_response).note_to have_key 'html'
+ end
+ end
end
context 'with tree path' do