From 52a55f407b74815c13675f4176570b8a952d7b75 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 8 Jan 2024 01:04:37 +0000 Subject: Replace String#sub with delete_prefix / delete_suffix (#40008). Patch by Go MAEDA (@maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22596 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/repositories_controller.rb | 2 +- app/controllers/settings_controller.rb | 2 +- app/controllers/workflows_controller.rb | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 07829c58d..5b18f14a6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -230,7 +230,7 @@ class RepositoriesController < ApplicationController # Adds a related issue to a changeset # POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues def add_related_issue - issue_id = params[:issue_id].to_s.sub(/^#/, '') + issue_id = params[:issue_id].to_s.delete_prefix('#') @issue = @changeset.find_referenced_issue_by_id(issue_id) if @issue && (!@issue.visible? || @changeset.issues.include?(@issue)) @issue = nil diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 9fb08d651..4662950c1 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -53,7 +53,7 @@ class SettingsController < ApplicationController @deliveries = ActionMailer::Base.perform_deliveries @guessed_host_and_path = request.host_with_port.dup - @guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank? + @guessed_host_and_path << ("/#{Redmine::Utils.relative_url_root.delete_prefix('/')}") unless Redmine::Utils.relative_url_root.blank? @commit_update_keywords = Setting.commit_update_keywords.dup @commit_update_keywords = [{}] unless @commit_update_keywords.is_a?(Array) && @commit_update_keywords.any? diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index 3bb46ad14..abad0f710 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -58,7 +58,9 @@ class WorkflowsController < ApplicationController def permissions if @roles && @trackers - @fields = (Tracker::CORE_FIELDS_ALL - @trackers.map(&:disabled_core_fields).reduce(:&)).map {|field| [field, l("field_"+field.sub(/_id$/, ''))]} + @fields = (Tracker::CORE_FIELDS_ALL - @trackers.map(&:disabled_core_fields).reduce(:&)).map do |field| + [field, l("field_#{field.delete_suffix('_id')}")] + end @custom_fields = @trackers.map(&:custom_fields).flatten.uniq.sort @permissions = WorkflowPermission.rules_by_status_id(@trackers, @roles) @statuses.each {|status| @permissions[status.id] ||= {}} -- cgit v1.2.3