diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-06-15 12:42:56 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-06-15 12:42:56 +0300 |
commit | fbc749a96e07dd1b1b5760cfe376b5b7838181f0 (patch) | |
tree | ab7f1576bcb409f614db6a40ca77de032553a7a7 | |
parent | 4ac381a565eb1b3e7ebaec443889c6a7138fdfd0 (diff) |
Reuse viewer param and move logic to blob controller
-rw-r--r-- | app/assets/javascripts/ide/services/index.js | 2 | ||||
-rw-r--r-- | app/controllers/concerns/renders_blob.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 11 | ||||
-rw-r--r-- | spec/controllers/projects/blob_controller_spec.rb | 5 |
4 files changed, 10 insertions, 10 deletions
diff --git a/app/assets/javascripts/ide/services/index.js b/app/assets/javascripts/ide/services/index.js index a8b9afa35d9..da9de25302a 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', html_render: 'false' } }); + return Vue.http.get(endpoint, { params: { format: 'json', viewer: 'none' } }); }, getRawFileData(file) { if (file.tempFile) { diff --git a/app/controllers/concerns/renders_blob.rb b/app/controllers/concerns/renders_blob.rb index 10fb004a60c..ba7adcfea86 100644 --- a/app/controllers/concerns/renders_blob.rb +++ b/app/controllers/concerns/renders_blob.rb @@ -14,8 +14,6 @@ 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/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 0c1c286a0a4..64bc6bd5536 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -197,14 +197,11 @@ class Projects::BlobController < Projects::ApplicationController end def show_json - json = blob_json(@blob) - return render_404 unless json - path_segments = @path.split('/') path_segments.pop tree_path = path_segments.join('/') - render json: json.merge( + json = { id: @blob.id, path: blob.path, name: blob.name, @@ -221,6 +218,10 @@ class Projects::BlobController < Projects::ApplicationController commits_path: project_commits_path(project, @id), tree_path: project_tree_path(project, File.join(@ref, tree_path)), permalink: project_blob_path(project, File.join(@commit.id, @path)) - ) + } + + json.merge!(blob_json(@blob) || {}) unless params[:viewer] == 'none' + + render json: json end end diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index f47593aad72..9e696e9cb29 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -56,7 +56,7 @@ describe Projects::BlobController do end end - context "html_render=false" do + context "with viewer=none" do let(:id) { 'master/README.md' } before do @@ -65,12 +65,13 @@ describe Projects::BlobController do project_id: project, id: id, format: :json, - html_render: 'false') + viewer: 'none') end it do expect(response).to be_ok expect(json_response).not_to have_key 'html' + expect(json_response).to have_key 'raw_path' end end end |