From 699607f2e50c7c71742205833d088e8cd5de1919 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Mon, 5 Feb 2018 16:25:31 +0100 Subject: initial refactor --- app/helpers/blob_helper.rb | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index a6e1de6ffdc..0bd1ee7c5f2 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -17,10 +17,7 @@ module BlobHelper end def edit_blob_link(project = @project, ref = @ref, path = @path, options = {}) - blob = options.delete(:blob) - blob ||= project.repository.blob_at(ref, path) rescue nil - - return unless blob && blob.readable_text? + return unless readable_blob?(options, path, project, ref) common_classes = "btn js-edit-blob #{options[:extra_class]}" @@ -30,16 +27,7 @@ module BlobHelper elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) link_to 'Edit', edit_blob_path(project, ref, path, options), class: "#{common_classes} btn-sm" elsif current_user && can?(current_user, :fork_project, project) - continue_params = { - to: edit_blob_path(project, ref, path, options), - notice: edit_in_new_fork_notice, - notice_now: edit_in_new_fork_notice_now - } - fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) - - button_tag 'Edit', - class: "#{common_classes} js-edit-blob-link-fork-toggler", - data: { action: 'edit', fork_path: fork_path } + edit_blob_fork(common_classes, options, path, project, ref) end end @@ -332,4 +320,24 @@ module BlobHelper options end + + def readable_blob?(options, path, project, ref) + blob = options.delete(:blob) + blob ||= project.repository.blob_at(ref, path) rescue nil + + blob && blob.readable_text? + end + + def edit_blob_fork(common_classes, options, path, project, ref) + continue_params = { + to: edit_blob_path(project, ref, path, options), + notice: edit_in_new_fork_notice, + notice_now: edit_in_new_fork_notice_now + } + fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) + + button_tag 'Edit', + class: "#{common_classes} js-edit-blob-link-fork-toggler", + data: { action: 'edit', fork_path: fork_path } + end end -- cgit v1.2.1 From cb31b369091e00ad3639bfde0fdd184d20619e7e Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 7 Feb 2018 11:43:30 +0100 Subject: a bit more refactoring --- app/helpers/blob_helper.rb | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 0bd1ee7c5f2..cba87176631 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -41,11 +41,7 @@ module BlobHelper def ide_blob_link(project = @project, ref = @ref, path = @path, options = {}) return unless show_new_ide? - - blob = options.delete(:blob) - blob ||= project.repository.blob_at(ref, path) rescue nil - - return unless blob && blob.readable_text? + return unless readable_blob?(options, path, project, ref) common_classes = "btn js-edit-ide #{options[:extra_class]}" @@ -55,16 +51,7 @@ module BlobHelper elsif current_user && can_modify_blob?(blob, project, ref) link_to ide_edit_text, ide_edit_path(project, ref, path, options), class: "#{common_classes} btn-sm" elsif current_user && can?(current_user, :fork_project, project) - continue_params = { - to: ide_edit_path(project, ref, path, options), - notice: edit_in_new_fork_notice, - notice_now: edit_in_new_fork_notice_now - } - fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) - - button_tag ide_edit_text, - class: common_classes, - data: { fork_path: fork_path } + edit_blob_fork(common_classes, options, path, project, ref) end end @@ -84,16 +71,7 @@ module BlobHelper elsif can_modify_blob?(blob, project, ref) button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' elsif can?(current_user, :fork_project, project) - continue_params = { - to: request.fullpath, - notice: edit_in_new_fork_notice + " Try to #{action} this file again.", - notice_now: edit_in_new_fork_notice_now - } - fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) - - button_tag label, - class: "#{common_classes} js-edit-blob-link-fork-toggler", - data: { action: action, fork_path: fork_path } + edit_blob_fork(common_classes, options, path, project, ref) end end -- cgit v1.2.1 From b8d7367ad0049dd3cb230d3439831037c4c25ed0 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 8 Feb 2018 11:58:47 +0100 Subject: refactor methods further (in helper) --- app/helpers/blob_helper.rb | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index cba87176631..16b9be9a916 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -22,10 +22,10 @@ module BlobHelper common_classes = "btn js-edit-blob #{options[:extra_class]}" if !on_top_of_branch?(project, ref) - button_tag 'Edit', class: "#{common_classes} disabled has-tooltip", title: "You can only edit files when you are on a branch", data: { container: 'body' } + edit_button_tag(edit_text, common_classes) # This condition applies to anonymous or users who can edit directly elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) - link_to 'Edit', edit_blob_path(project, ref, path, options), class: "#{common_classes} btn-sm" + edit_link_tag(edit_text, ide_edit_path(project, ref, path, options), common_classes) elsif current_user && can?(current_user, :fork_project, project) edit_blob_fork(common_classes, options, path, project, ref) end @@ -35,8 +35,12 @@ module BlobHelper "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}" end + def edit_text + _('Edit') + end + def ide_edit_text - "#{_('Web IDE')}" + _('Web IDE') end def ide_blob_link(project = @project, ref = @ref, path = @path, options = {}) @@ -46,10 +50,11 @@ module BlobHelper common_classes = "btn js-edit-ide #{options[:extra_class]}" if !on_top_of_branch?(project, ref) - button_tag ide_edit_text, class: "#{common_classes} disabled has-tooltip", title: _('You can only edit files when you are on a branch'), data: { container: 'body' } - # This condition applies to anonymous or users who can edit directly + edit_button_tag(ide_edit_text, common_classes) + # This condition only applies to users who are logged in + # Web IDE (Beta) requires the user to have this feature enabled elsif current_user && can_modify_blob?(blob, project, ref) - link_to ide_edit_text, ide_edit_path(project, ref, path, options), class: "#{common_classes} btn-sm" + edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) elsif current_user && can?(current_user, :fork_project, project) edit_blob_fork(common_classes, options, path, project, ref) end @@ -314,8 +319,16 @@ module BlobHelper } fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) - button_tag 'Edit', + button_tag edit_text, class: "#{common_classes} js-edit-blob-link-fork-toggler", data: { action: 'edit', fork_path: fork_path } end + + def edit_button_tag(button_text, common_classes) + button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _('You can only edit files when you are on a branch'), data: { container: 'body' }) + end + + def edit_link_tag(link_text, edit_path, common_classes) + link_to link_text, edit_path, class: "#{common_classes} btn-sm" + end end -- cgit v1.2.1 From 9053f8eb4b94669d18674552b8f588071d8c76c6 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 8 Feb 2018 14:12:44 +0100 Subject: fix specs --- app/helpers/blob_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 16b9be9a916..8546e72a8a9 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -17,7 +17,7 @@ module BlobHelper end def edit_blob_link(project = @project, ref = @ref, path = @path, options = {}) - return unless readable_blob?(options, path, project, ref) + return unless blob = readable_blob(options, path, project, ref) common_classes = "btn js-edit-blob #{options[:extra_class]}" @@ -45,7 +45,7 @@ module BlobHelper def ide_blob_link(project = @project, ref = @ref, path = @path, options = {}) return unless show_new_ide? - return unless readable_blob?(options, path, project, ref) + return unless blob = readable_blob(options, path, project, ref) common_classes = "btn js-edit-ide #{options[:extra_class]}" @@ -304,11 +304,11 @@ module BlobHelper options end - def readable_blob?(options, path, project, ref) + def readable_blob(options, path, project, ref) blob = options.delete(:blob) blob ||= project.repository.blob_at(ref, path) rescue nil - blob && blob.readable_text? + blob if blob&.readable_text? end def edit_blob_fork(common_classes, options, path, project, ref) -- cgit v1.2.1 From 6d885f9c92cdb6e2d8ad332af2490d25269b5f9f Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 8 Feb 2018 15:45:12 +0100 Subject: some more refactoring --- app/helpers/blob_helper.rb | 12 ++++++------ app/helpers/tree_helper.rb | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 8546e72a8a9..3f187a41735 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -27,7 +27,7 @@ module BlobHelper elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) edit_link_tag(edit_text, ide_edit_path(project, ref, path, options), common_classes) elsif current_user && can?(current_user, :fork_project, project) - edit_blob_fork(common_classes, options, path, project, ref) + edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project, edit_in_new_fork_notice) end end @@ -56,7 +56,7 @@ module BlobHelper elsif current_user && can_modify_blob?(blob, project, ref) edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) elsif current_user && can?(current_user, :fork_project, project) - edit_blob_fork(common_classes, options, path, project, ref) + edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project, edit_in_new_fork_notice) end end @@ -76,7 +76,7 @@ module BlobHelper elsif can_modify_blob?(blob, project, ref) button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' elsif can?(current_user, :fork_project, project) - edit_blob_fork(common_classes, options, path, project, ref) + edit_blob_fork(common_classes, request.fullpath, project, edit_in_new_fork_notice_action(action), action) end end @@ -311,10 +311,10 @@ module BlobHelper blob if blob&.readable_text? end - def edit_blob_fork(common_classes, options, path, project, ref) + def edit_blob_fork(common_classes, path, project, notice, action = 'edit') continue_params = { - to: edit_blob_path(project, ref, path, options), - notice: edit_in_new_fork_notice, + to: path, + notice: notice, notice_now: edit_in_new_fork_notice_now } fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index f5733b4b57c..f6a6d9bebde 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -83,6 +83,10 @@ module TreeHelper " A fork of this project has been created that you can make changes in, so you can submit a merge request." end + def edit_in_new_fork_notice_action(action) + edit_in_new_fork_notice + " Try to #{action} this file again." + end + def commit_in_fork_help "A new branch will be created in your fork and a new merge request will be started." end -- cgit v1.2.1 From 5fc3ff98930f74a694d40cc3533138fb06964bf1 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 8 Feb 2018 16:12:28 +0100 Subject: fix specs --- app/helpers/blob_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 3f187a41735..2822fa8144a 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -321,7 +321,7 @@ module BlobHelper button_tag edit_text, class: "#{common_classes} js-edit-blob-link-fork-toggler", - data: { action: 'edit', fork_path: fork_path } + data: { action: action, fork_path: fork_path } end def edit_button_tag(button_text, common_classes) -- cgit v1.2.1 From 4c8f8f4fe9248567e4b1a5ef5a6bc049513751a4 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 9 Feb 2018 08:59:03 +0100 Subject: fix spec --- app/helpers/blob_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 2822fa8144a..b54dd93cc08 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -12,8 +12,8 @@ module BlobHelper def edit_blob_path(project = @project, ref = @ref, path = @path, options = {}) project_edit_blob_path(project, - tree_join(ref, path), - options[:link_opts]) + tree_join(ref, path), + options[:link_opts]) end def edit_blob_link(project = @project, ref = @ref, path = @path, options = {}) @@ -25,7 +25,7 @@ module BlobHelper edit_button_tag(edit_text, common_classes) # This condition applies to anonymous or users who can edit directly elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) - edit_link_tag(edit_text, ide_edit_path(project, ref, path, options), common_classes) + edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) elsif current_user && can?(current_user, :fork_project, project) edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project, edit_in_new_fork_notice) end -- cgit v1.2.1 From f13609663912e940e860b8f7b5e8aa98c99800e9 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 9 Feb 2018 10:32:28 +0100 Subject: refactor modify_file_link --- app/helpers/blob_helper.rb | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index b54dd93cc08..848a59d3756 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -27,7 +27,7 @@ module BlobHelper elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) elsif current_user && can?(current_user, :fork_project, project) - edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project, edit_in_new_fork_notice) + edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project) end end @@ -56,7 +56,7 @@ module BlobHelper elsif current_user && can_modify_blob?(blob, project, ref) edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) elsif current_user && can?(current_user, :fork_project, project) - edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project, edit_in_new_fork_notice) + edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project) end end @@ -76,7 +76,7 @@ module BlobHelper elsif can_modify_blob?(blob, project, ref) button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' elsif can?(current_user, :fork_project, project) - edit_blob_fork(common_classes, request.fullpath, project, edit_in_new_fork_notice_action(action), action) + edit_modify_file_fork(action, common_classes, label, project) end end @@ -311,15 +311,28 @@ module BlobHelper blob if blob&.readable_text? end - def edit_blob_fork(common_classes, path, project, notice, action = 'edit') + def edit_blob_fork(common_classes, path, project) continue_params = { to: path, - notice: notice, + notice: edit_in_new_fork_notice, notice_now: edit_in_new_fork_notice_now } fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) button_tag edit_text, + class: "#{common_classes} js-edit-blob-link-fork-toggler", + data: { action: 'edit', fork_path: fork_path } + end + + def edit_modify_file_fork(action, common_classes, label, project) + continue_params = { + to: request.fullpath, + notice: edit_in_new_fork_notice + " Try to #{action} this file again.", + notice_now: edit_in_new_fork_notice_now + } + fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) + + button_tag label, class: "#{common_classes} js-edit-blob-link-fork-toggler", data: { action: action, fork_path: fork_path } end -- cgit v1.2.1 From bee837d7b5025a2e170dc0c857b188b4d89c014f Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 15 Feb 2018 08:53:09 +0100 Subject: some initial refactoring --- app/helpers/blob_helper.rb | 26 +++++++++++++++++--------- app/views/projects/blob/_header.html.haml | 4 ++-- app/views/projects/diffs/_file.html.haml | 2 +- spec/helpers/blob_helper_spec.rb | 10 +++++----- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 848a59d3756..a5fba39630a 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -16,7 +16,7 @@ module BlobHelper options[:link_opts]) end - def edit_blob_link(project = @project, ref = @ref, path = @path, options = {}) + def edit_blob_element(project = @project, ref = @ref, path = @path, options = {}) return unless blob = readable_blob(options, path, project, ref) common_classes = "btn js-edit-blob #{options[:extra_class]}" @@ -24,13 +24,17 @@ module BlobHelper if !on_top_of_branch?(project, ref) edit_button_tag(edit_text, common_classes) # This condition applies to anonymous or users who can edit directly - elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) + elsif !current_user || user_can_modify_blob(blob, project, ref) edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) - elsif current_user && can?(current_user, :fork_project, project) + elsif user_can_fork_project(project) edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project) end end + def user_can_fork_project(project) + current_user && can?(current_user, :fork_project, project) + end + def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}" end @@ -43,7 +47,7 @@ module BlobHelper _('Web IDE') end - def ide_blob_link(project = @project, ref = @ref, path = @path, options = {}) + def ide_edit_element(project = @project, ref = @ref, path = @path, options = {}) return unless show_new_ide? return unless blob = readable_blob(options, path, project, ref) @@ -53,14 +57,18 @@ module BlobHelper edit_button_tag(ide_edit_text, common_classes) # This condition only applies to users who are logged in # Web IDE (Beta) requires the user to have this feature enabled - elsif current_user && can_modify_blob?(blob, project, ref) + elsif user_can_modify_blob(blob, project, ref) edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) - elsif current_user && can?(current_user, :fork_project, project) + elsif user_can_fork_project(project) edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project) end end - def modify_file_link(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) + def user_can_modify_blob(blob, project, ref) + current_user && can_modify_blob?(blob, project, ref) + end + + def modify_file_element(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) return unless current_user blob = project.repository.blob_at(ref, path) rescue nil @@ -81,7 +89,7 @@ module BlobHelper end def replace_blob_link(project = @project, ref = @ref, path = @path) - modify_file_link( + modify_file_element( project, ref, path, @@ -93,7 +101,7 @@ module BlobHelper end def delete_blob_link(project = @project, ref = @ref, path = @path) - modify_file_link( + modify_file_element( project, ref, path, diff --git a/app/views/projects/blob/_header.html.haml b/app/views/projects/blob/_header.html.haml index 2a77dedd9a2..da0c0ed6cb4 100644 --- a/app/views/projects/blob/_header.html.haml +++ b/app/views/projects/blob/_header.html.haml @@ -11,8 +11,8 @@ = view_on_environment_button(@commit.sha, @path, @environment) if @environment .btn-group{ role: "group" }< - = edit_blob_link - = ide_blob_link + = edit_blob_element + = ide_edit_element - if current_user = replace_blob_link = delete_blob_link diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml index 0b01e38d23d..3e6001e6f30 100644 --- a/app/views/projects/diffs/_file.html.haml +++ b/app/views/projects/diffs/_file.html.haml @@ -17,7 +17,7 @@ \ - if editable_diff?(diff_file) - link_opts = @merge_request.persisted? ? { from_merge_request_iid: @merge_request.iid } : {} - = edit_blob_link(@merge_request.source_project, @merge_request.source_branch, diff_file.new_path, + = edit_blob_element(@merge_request.source_project, @merge_request.source_branch, diff_file.new_path, blob: blob, link_opts: link_opts) - if image_diff && image_replaced diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index a030796c54e..d1968eac3e3 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -74,7 +74,7 @@ describe BlobHelper do end end - describe "#edit_blob_link" do + describe "#edit_blob_element" do let(:namespace) { create(:namespace, name: 'gitlab' )} let(:project) { create(:project, :repository, namespace: namespace) } @@ -86,7 +86,7 @@ describe BlobHelper do it 'verifies blob is text' do expect(helper).not_to receive(:blob_text_viewable?) - button = edit_blob_link(project, 'refs/heads/master', 'README.md') + button = edit_blob_element(project, 'refs/heads/master', 'README.md') expect(button).to start_with(' Date: Thu, 15 Feb 2018 09:44:08 +0100 Subject: more refactoring --- app/helpers/blob_helper.rb | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index a5fba39630a..7e40e554c60 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -27,7 +27,7 @@ module BlobHelper elsif !current_user || user_can_modify_blob(blob, project, ref) edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) elsif user_can_fork_project(project) - edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project) + edit_fork_button_tag(common_classes, project, edit_text, edit_blob_fork_params(path)) end end @@ -60,7 +60,7 @@ module BlobHelper elsif user_can_modify_blob(blob, project, ref) edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) elsif user_can_fork_project(project) - edit_blob_fork(common_classes, edit_blob_path(project, ref, path, options), project) + edit_fork_button_tag(common_classes, project, ide_edit_text, edit_blob_fork_params(path)) end end @@ -84,7 +84,7 @@ module BlobHelper elsif can_modify_blob?(blob, project, ref) button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' elsif can?(current_user, :fork_project, project) - edit_modify_file_fork(action, common_classes, label, project) + edit_fork_button_tag(common_classes, project, label, edit_modify_file_fork_params(action)) end end @@ -319,30 +319,28 @@ module BlobHelper blob if blob&.readable_text? end - def edit_blob_fork(common_classes, path, project) - continue_params = { + def edit_blob_fork_params(path) + { to: path, notice: edit_in_new_fork_notice, notice_now: edit_in_new_fork_notice_now } - fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) - - button_tag edit_text, - class: "#{common_classes} js-edit-blob-link-fork-toggler", - data: { action: 'edit', fork_path: fork_path } end - def edit_modify_file_fork(action, common_classes, label, project) - continue_params = { - to: request.fullpath, - notice: edit_in_new_fork_notice + " Try to #{action} this file again.", + def edit_modify_file_fork_params(action) + { + to: request.full_path, + notice: edit_in_new_fork_notice_action(action), notice_now: edit_in_new_fork_notice_now } - fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: continue_params) + end + + def edit_fork_button_tag(common_classes, project, label, params) + fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: params) - button_tag label, + button_tag edit_text, class: "#{common_classes} js-edit-blob-link-fork-toggler", - data: { action: action, fork_path: fork_path } + data: { action: 'edit', fork_path: fork_path } end def edit_button_tag(button_text, common_classes) -- cgit v1.2.1 From 50ccc6dcc79d5864f5fb9e18e2c586fd3e5f9218 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 15 Feb 2018 10:24:42 +0100 Subject: fix specs --- app/helpers/blob_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 7e40e554c60..d520f2ed068 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -329,7 +329,7 @@ module BlobHelper def edit_modify_file_fork_params(action) { - to: request.full_path, + to: request.fullpath, notice: edit_in_new_fork_notice_action(action), notice_now: edit_in_new_fork_notice_now } -- cgit v1.2.1 From 6ade6e2bb6a937c08da9a1bc62f62e92ad2ab06e Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 15 Feb 2018 12:03:37 +0100 Subject: fix specs --- app/helpers/blob_helper.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index d520f2ed068..1c076321cb7 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -84,7 +84,7 @@ module BlobHelper elsif can_modify_blob?(blob, project, ref) button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' elsif can?(current_user, :fork_project, project) - edit_fork_button_tag(common_classes, project, label, edit_modify_file_fork_params(action)) + edit_fork_button_tag(common_classes, project, label, edit_modify_file_fork_params(action), action) end end @@ -331,16 +331,17 @@ module BlobHelper { to: request.fullpath, notice: edit_in_new_fork_notice_action(action), - notice_now: edit_in_new_fork_notice_now + notice_now: edit_in_new_fork_notice_now, + action: action } end - def edit_fork_button_tag(common_classes, project, label, params) + def edit_fork_button_tag(common_classes, project, label, params, action = 'edit') fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: params) - button_tag edit_text, + button_tag label, class: "#{common_classes} js-edit-blob-link-fork-toggler", - data: { action: 'edit', fork_path: fork_path } + data: { action: action, fork_path: fork_path } end def edit_button_tag(button_text, common_classes) -- cgit v1.2.1 From 31abc74ff427f0b350b7121d5e6a7394daf7bf2f Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 15 Feb 2018 13:42:33 +0100 Subject: fix specs --- app/helpers/blob_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 1c076321cb7..9c682a856dd 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -27,7 +27,9 @@ module BlobHelper elsif !current_user || user_can_modify_blob(blob, project, ref) edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) elsif user_can_fork_project(project) - edit_fork_button_tag(common_classes, project, edit_text, edit_blob_fork_params(path)) + edit_fork_button_tag(common_classes, + project, edit_text, + edit_blob_fork_params(edit_blob_path(project, ref, path, options))) end end @@ -60,7 +62,10 @@ module BlobHelper elsif user_can_modify_blob(blob, project, ref) edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) elsif user_can_fork_project(project) - edit_fork_button_tag(common_classes, project, ide_edit_text, edit_blob_fork_params(path)) + edit_fork_button_tag(common_classes, + project, + ide_edit_text, + edit_blob_fork_params(ide_edit_path(project, ref, path, options))) end end @@ -332,7 +337,6 @@ module BlobHelper to: request.fullpath, notice: edit_in_new_fork_notice_action(action), notice_now: edit_in_new_fork_notice_now, - action: action } end -- cgit v1.2.1 From 9753396fe2da21fdb1cc7656e4bf33e28f374363 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 15 Feb 2018 14:50:00 +0100 Subject: fix static analysis --- app/helpers/blob_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 9c682a856dd..3c45f670015 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -336,7 +336,7 @@ module BlobHelper { to: request.fullpath, notice: edit_in_new_fork_notice_action(action), - notice_now: edit_in_new_fork_notice_now, + notice_now: edit_in_new_fork_notice_now } end -- cgit v1.2.1 From 228b757d29a141c4fda0e7c4be75784a6cefe427 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Mon, 19 Feb 2018 11:38:31 +0100 Subject: refactor blob link methods --- app/helpers/blob_helper.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 3c45f670015..6322eb1b671 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -24,19 +24,24 @@ module BlobHelper if !on_top_of_branch?(project, ref) edit_button_tag(edit_text, common_classes) # This condition applies to anonymous or users who can edit directly - elsif !current_user || user_can_modify_blob(blob, project, ref) + elsif !current_user || user_can_modify_blob?(blob, project, ref) edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) - elsif user_can_fork_project(project) + elsif user_can_fork_project?(project) edit_fork_button_tag(common_classes, - project, edit_text, + project, + edit_text, edit_blob_fork_params(edit_blob_path(project, ref, path, options))) end end - def user_can_fork_project(project) + def user_can_fork_project?(project) current_user && can?(current_user, :fork_project, project) end + def user_can_modify_blob?(blob, project, ref) + current_user && can_modify_blob?(blob, project, ref) + end + def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}" end @@ -59,9 +64,9 @@ module BlobHelper edit_button_tag(ide_edit_text, common_classes) # This condition only applies to users who are logged in # Web IDE (Beta) requires the user to have this feature enabled - elsif user_can_modify_blob(blob, project, ref) + elsif user_can_modify_blob?(blob, project, ref) edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) - elsif user_can_fork_project(project) + elsif user_can_fork_project?(project) edit_fork_button_tag(common_classes, project, ide_edit_text, @@ -69,10 +74,6 @@ module BlobHelper end end - def user_can_modify_blob(blob, project, ref) - current_user && can_modify_blob?(blob, project, ref) - end - def modify_file_element(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) return unless current_user -- cgit v1.2.1 From 0767861bcdc62cedf374c6a4b53d8526efb4ff58 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 22 Feb 2018 13:54:19 +0100 Subject: refactor code based on feedback --- app/helpers/blob_helper.rb | 22 +++++++++++----------- app/views/projects/blob/_header.html.haml | 4 ++-- app/views/projects/diffs/_file.html.haml | 2 +- spec/helpers/blob_helper_spec.rb | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 6322eb1b671..93e2a752547 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -16,13 +16,13 @@ module BlobHelper options[:link_opts]) end - def edit_blob_element(project = @project, ref = @ref, path = @path, options = {}) + def edit_blob_button(project = @project, ref = @ref, path = @path, options = {}) return unless blob = readable_blob(options, path, project, ref) common_classes = "btn js-edit-blob #{options[:extra_class]}" if !on_top_of_branch?(project, ref) - edit_button_tag(edit_text, common_classes) + edit_disabled_button_tag(edit_text, common_classes) # This condition applies to anonymous or users who can edit directly elsif !current_user || user_can_modify_blob?(blob, project, ref) edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) @@ -54,14 +54,14 @@ module BlobHelper _('Web IDE') end - def ide_edit_element(project = @project, ref = @ref, path = @path, options = {}) + def ide_edit_button(project = @project, ref = @ref, path = @path, options = {}) return unless show_new_ide? return unless blob = readable_blob(options, path, project, ref) common_classes = "btn js-edit-ide #{options[:extra_class]}" if !on_top_of_branch?(project, ref) - edit_button_tag(ide_edit_text, common_classes) + edit_disabled_button_tag(ide_edit_text, common_classes) # This condition only applies to users who are logged in # Web IDE (Beta) requires the user to have this feature enabled elsif user_can_modify_blob?(blob, project, ref) @@ -327,17 +327,17 @@ module BlobHelper def edit_blob_fork_params(path) { - to: path, - notice: edit_in_new_fork_notice, - notice_now: edit_in_new_fork_notice_now + to: path, + notice: edit_in_new_fork_notice, + notice_now: edit_in_new_fork_notice_now } end def edit_modify_file_fork_params(action) { - to: request.fullpath, - notice: edit_in_new_fork_notice_action(action), - notice_now: edit_in_new_fork_notice_now + to: request.fullpath, + notice: edit_in_new_fork_notice_action(action), + notice_now: edit_in_new_fork_notice_now } end @@ -349,7 +349,7 @@ module BlobHelper data: { action: action, fork_path: fork_path } end - def edit_button_tag(button_text, common_classes) + def edit_disabled_button_tag(button_text, common_classes) button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _('You can only edit files when you are on a branch'), data: { container: 'body' }) end diff --git a/app/views/projects/blob/_header.html.haml b/app/views/projects/blob/_header.html.haml index da0c0ed6cb4..1b150ec3e5c 100644 --- a/app/views/projects/blob/_header.html.haml +++ b/app/views/projects/blob/_header.html.haml @@ -11,8 +11,8 @@ = view_on_environment_button(@commit.sha, @path, @environment) if @environment .btn-group{ role: "group" }< - = edit_blob_element - = ide_edit_element + = edit_blob_button + = ide_edit_button - if current_user = replace_blob_link = delete_blob_link diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml index 3e6001e6f30..47bfcb21cf4 100644 --- a/app/views/projects/diffs/_file.html.haml +++ b/app/views/projects/diffs/_file.html.haml @@ -17,7 +17,7 @@ \ - if editable_diff?(diff_file) - link_opts = @merge_request.persisted? ? { from_merge_request_iid: @merge_request.iid } : {} - = edit_blob_element(@merge_request.source_project, @merge_request.source_branch, diff_file.new_path, + = edit_blob_button(@merge_request.source_project, @merge_request.source_branch, diff_file.new_path, blob: blob, link_opts: link_opts) - if image_diff && image_replaced diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index d1968eac3e3..0548e71c89d 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -86,7 +86,7 @@ describe BlobHelper do it 'verifies blob is text' do expect(helper).not_to receive(:blob_text_viewable?) - button = edit_blob_element(project, 'refs/heads/master', 'README.md') + button = edit_blob_button(project, 'refs/heads/master', 'README.md') expect(button).to start_with(' Date: Fri, 23 Feb 2018 09:09:32 +0100 Subject: refactor code based on feedback --- app/helpers/blob_helper.rb | 51 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 93e2a752547..67196d09b48 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -21,25 +21,20 @@ module BlobHelper common_classes = "btn js-edit-blob #{options[:extra_class]}" - if !on_top_of_branch?(project, ref) - edit_disabled_button_tag(edit_text, common_classes) - # This condition applies to anonymous or users who can edit directly - elsif !current_user || user_can_modify_blob?(blob, project, ref) - edit_link_tag(edit_text, edit_blob_path(project, ref, path, options), common_classes) - elsif user_can_fork_project?(project) - edit_fork_button_tag(common_classes, - project, - edit_text, - edit_blob_fork_params(edit_blob_path(project, ref, path, options))) - end + edit_button_tag(blob, + common_classes, + edit_text, + edit_blob_path(project, ref, path, options), + project, + ref) end def user_can_fork_project?(project) current_user && can?(current_user, :fork_project, project) end - def user_can_modify_blob?(blob, project, ref) - current_user && can_modify_blob?(blob, project, ref) + def display_modify_blob?(blob, project, ref) + !current_user || (current_user && can_modify_blob?(blob, project, ref)) end def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) @@ -60,18 +55,12 @@ module BlobHelper common_classes = "btn js-edit-ide #{options[:extra_class]}" - if !on_top_of_branch?(project, ref) - edit_disabled_button_tag(ide_edit_text, common_classes) - # This condition only applies to users who are logged in - # Web IDE (Beta) requires the user to have this feature enabled - elsif user_can_modify_blob?(blob, project, ref) - edit_link_tag(ide_edit_text, ide_edit_path(project, ref, path, options), common_classes) - elsif user_can_fork_project?(project) - edit_fork_button_tag(common_classes, - project, - ide_edit_text, - edit_blob_fork_params(ide_edit_path(project, ref, path, options))) - end + edit_button_tag(blob, + common_classes, + ide_edit_text, + ide_edit_path(project, ref, path, options), + project, + ref) end def modify_file_element(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) @@ -356,4 +345,16 @@ module BlobHelper def edit_link_tag(link_text, edit_path, common_classes) link_to link_text, edit_path, class: "#{common_classes} btn-sm" end + + def edit_button_tag(blob, common_classes, text, edit_path, project, ref) + if !on_top_of_branch?(project, ref) + edit_disabled_button_tag(text, common_classes) + # This condition only applies to users who are logged in + # Web IDE (Beta) requires the user to have this feature enabled + elsif display_modify_blob?(blob, project, ref) + edit_link_tag(text, edit_path, common_classes) + elsif user_can_fork_project?(project) + edit_fork_button_tag(common_classes, project, text, edit_path) + end + end end -- cgit v1.2.1 From b8028c6ccc0de02d7a6d97471a555d0e58e59b29 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 23 Feb 2018 13:58:27 +0100 Subject: fix fork button issue --- app/helpers/blob_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 67196d09b48..40a6a7ca574 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -354,7 +354,7 @@ module BlobHelper elsif display_modify_blob?(blob, project, ref) edit_link_tag(text, edit_path, common_classes) elsif user_can_fork_project?(project) - edit_fork_button_tag(common_classes, project, text, edit_path) + edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path)) end end end -- cgit v1.2.1 From 73c4c995f90ab84ff1a3cff24d2cb189003f54a0 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 23 Feb 2018 16:04:31 +0100 Subject: inline methods --- app/helpers/blob_helper.rb | 30 ++++++-------------------- app/views/projects/tree/_tree_header.html.haml | 4 ++-- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 40a6a7ca574..551af3301db 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -23,32 +23,16 @@ module BlobHelper edit_button_tag(blob, common_classes, - edit_text, + _('Edit'), edit_blob_path(project, ref, path, options), project, ref) end - def user_can_fork_project?(project) - current_user && can?(current_user, :fork_project, project) - end - def display_modify_blob?(blob, project, ref) !current_user || (current_user && can_modify_blob?(blob, project, ref)) end - def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) - "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}" - end - - def edit_text - _('Edit') - end - - def ide_edit_text - _('Web IDE') - end - def ide_edit_button(project = @project, ref = @ref, path = @path, options = {}) return unless show_new_ide? return unless blob = readable_blob(options, path, project, ref) @@ -57,13 +41,13 @@ module BlobHelper edit_button_tag(blob, common_classes, - ide_edit_text, - ide_edit_path(project, ref, path, options), + _('Web IDE'), + "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}", project, ref) end - def modify_file_element(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) + def modify_file_button(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:) return unless current_user blob = project.repository.blob_at(ref, path) rescue nil @@ -84,7 +68,7 @@ module BlobHelper end def replace_blob_link(project = @project, ref = @ref, path = @path) - modify_file_element( + modify_file_button( project, ref, path, @@ -96,7 +80,7 @@ module BlobHelper end def delete_blob_link(project = @project, ref = @ref, path = @path) - modify_file_element( + modify_file_button( project, ref, path, @@ -353,7 +337,7 @@ module BlobHelper # Web IDE (Beta) requires the user to have this feature enabled elsif display_modify_blob?(blob, project, ref) edit_link_tag(text, edit_path, common_classes) - elsif user_can_fork_project?(project) + elsif current_user && can?(current_user, :fork_project, project) edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path)) end end diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml index 05539dfed7c..ff3928552af 100644 --- a/app/views/projects/tree/_tree_header.html.haml +++ b/app/views/projects/tree/_tree_header.html.haml @@ -74,8 +74,8 @@ .tree-controls - if show_new_ide? = succeed " " do - = link_to ide_edit_path(@project, @id), class: 'btn btn-default' do - = ide_edit_text + = link_to "#{ide_path}/project#{edit_blob_path(@project, @id, @path, {})}", class: 'btn btn-default' do + = _('Web IDE') = link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn' -- cgit v1.2.1 From c888e73bc6bf7c89c551a45e579a3b319d435d21 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 23 Feb 2018 16:52:18 +0100 Subject: refactor methods inline --- app/helpers/blob_helper.rb | 12 ++++++------ app/views/projects/tree/_tree_header.html.haml | 2 +- spec/helpers/blob_helper_spec.rb | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 551af3301db..0e806d16bc5 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -16,6 +16,10 @@ module BlobHelper options[:link_opts]) end + def ide_edit_path(project = @project, ref = @ref, path = @path, options = {}) + "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}" + end + def edit_blob_button(project = @project, ref = @ref, path = @path, options = {}) return unless blob = readable_blob(options, path, project, ref) @@ -29,10 +33,6 @@ module BlobHelper ref) end - def display_modify_blob?(blob, project, ref) - !current_user || (current_user && can_modify_blob?(blob, project, ref)) - end - def ide_edit_button(project = @project, ref = @ref, path = @path, options = {}) return unless show_new_ide? return unless blob = readable_blob(options, path, project, ref) @@ -42,7 +42,7 @@ module BlobHelper edit_button_tag(blob, common_classes, _('Web IDE'), - "#{ide_path}/project#{edit_blob_path(project, ref, path, options)}", + ide_edit_path(project, ref, path, options), project, ref) end @@ -335,7 +335,7 @@ module BlobHelper edit_disabled_button_tag(text, common_classes) # This condition only applies to users who are logged in # Web IDE (Beta) requires the user to have this feature enabled - elsif display_modify_blob?(blob, project, ref) + elsif !current_user || (current_user && can_modify_blob?(blob, project, ref)) edit_link_tag(text, edit_path, common_classes) elsif current_user && can?(current_user, :fork_project, project) edit_fork_button_tag(common_classes, project, text, edit_blob_fork_params(edit_path)) diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml index ff3928552af..39511435508 100644 --- a/app/views/projects/tree/_tree_header.html.haml +++ b/app/views/projects/tree/_tree_header.html.haml @@ -74,7 +74,7 @@ .tree-controls - if show_new_ide? = succeed " " do - = link_to "#{ide_path}/project#{edit_blob_path(@project, @id, @path, {})}", class: 'btn btn-default' do + = link_to ide_edit_path(@project, @id), class: 'btn btn-default' do = _('Web IDE') = link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn' diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 0548e71c89d..1fa194fe1b8 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -74,7 +74,7 @@ describe BlobHelper do end end - describe "#edit_blob_element" do + describe "#edit_blob_link" do let(:namespace) { create(:namespace, name: 'gitlab' )} let(:project) { create(:project, :repository, namespace: namespace) } -- cgit v1.2.1