mirror of
https://github.com/redmine/redmine.git
synced 2025-12-16 05:20:28 +01:00
Replace Hash#merge! with Hash#[]= (#34160).
git-svn-id: http://svn.redmine.org/redmine/trunk@20175 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -564,22 +564,6 @@ Performance/RedundantMatch:
|
|||||||
- 'lib/redmine/wiki_formatting/textile/formatter.rb'
|
- 'lib/redmine/wiki_formatting/textile/formatter.rb'
|
||||||
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
|
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
|
||||||
|
|
||||||
# Cop supports --auto-correct.
|
|
||||||
# Configuration parameters: MaxKeyValuePairs.
|
|
||||||
Performance/RedundantMerge:
|
|
||||||
Exclude:
|
|
||||||
- 'app/controllers/issues_controller.rb'
|
|
||||||
- 'app/helpers/application_helper.rb'
|
|
||||||
- 'app/helpers/avatars_helper.rb'
|
|
||||||
- 'app/helpers/custom_fields_helper.rb'
|
|
||||||
- 'app/helpers/workflows_helper.rb'
|
|
||||||
- 'app/models/auth_source_ldap.rb'
|
|
||||||
- 'app/models/principal.rb'
|
|
||||||
- 'lib/redmine/access_control.rb'
|
|
||||||
- 'test/functional/imports_controller_test.rb'
|
|
||||||
- 'test/unit/issue_import_test.rb'
|
|
||||||
- 'test/unit/time_entry_import_test.rb'
|
|
||||||
|
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Performance/Squeeze:
|
Performance/Squeeze:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
|||||||
@@ -666,7 +666,7 @@ class IssuesController < ApplicationController
|
|||||||
if params[:project_id]
|
if params[:project_id]
|
||||||
redirect_to new_project_issue_path(@issue.project, url_params)
|
redirect_to new_project_issue_path(@issue.project, url_params)
|
||||||
else
|
else
|
||||||
url_params[:issue].merge! :project_id => @issue.project_id
|
url_params[:issue][:project_id] = @issue.project_id
|
||||||
redirect_to new_issue_path(url_params)
|
redirect_to new_issue_path(url_params)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1401,16 +1401,16 @@ module ApplicationHelper
|
|||||||
args << {} unless args.last.is_a?(Hash)
|
args << {} unless args.last.is_a?(Hash)
|
||||||
options = args.last
|
options = args.last
|
||||||
if args.first.is_a?(Symbol)
|
if args.first.is_a?(Symbol)
|
||||||
options.merge!(:as => args.shift)
|
options[:as] = args.shift
|
||||||
end
|
end
|
||||||
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
|
options[:builder] = Redmine::Views::LabelledFormBuilder
|
||||||
form_for(*args, &proc)
|
form_for(*args, &proc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def labelled_fields_for(*args, &proc)
|
def labelled_fields_for(*args, &proc)
|
||||||
args << {} unless args.last.is_a?(Hash)
|
args << {} unless args.last.is_a?(Hash)
|
||||||
options = args.last
|
options = args.last
|
||||||
options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
|
options[:builder] = Redmine::Views::LabelledFormBuilder
|
||||||
fields_for(*args, &proc)
|
fields_for(*args, &proc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ module AvatarsHelper
|
|||||||
def assignee_avatar(user, options={})
|
def assignee_avatar(user, options={})
|
||||||
return '' unless user
|
return '' unless user
|
||||||
|
|
||||||
options.merge!(:title => l(:field_assigned_to) + ": " + user.name)
|
options[:title] = l(:field_assigned_to) + ": " + user.name
|
||||||
avatar(user, options).to_s.html_safe
|
avatar(user, options).to_s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def author_avatar(user, options={})
|
def author_avatar(user, options={})
|
||||||
return '' unless user
|
return '' unless user
|
||||||
|
|
||||||
options.merge!(:title => l(:field_author) + ": " + user.name)
|
options[:title] = l(:field_author) + ": " + user.name
|
||||||
avatar(user, options).to_s.html_safe
|
avatar(user, options).to_s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ module AvatarsHelper
|
|||||||
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
|
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
|
||||||
def avatar(user, options = { })
|
def avatar(user, options = { })
|
||||||
if Setting.gravatar_enabled?
|
if Setting.gravatar_enabled?
|
||||||
options.merge!(:default => Setting.gravatar_default)
|
options[:default] = Setting.gravatar_default
|
||||||
options[:class] = GravatarHelper::DEFAULT_OPTIONS[:class] + " " + options[:class] if options[:class]
|
options[:class] = GravatarHelper::DEFAULT_OPTIONS[:class] + " " + options[:class] if options[:class]
|
||||||
email = nil
|
email = nil
|
||||||
if user.respond_to?(:mail)
|
if user.respond_to?(:mail)
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ module CustomFieldsHelper
|
|||||||
api.array :custom_fields do
|
api.array :custom_fields do
|
||||||
custom_values.each do |custom_value|
|
custom_values.each do |custom_value|
|
||||||
attrs = {:id => custom_value.custom_field_id, :name => custom_value.custom_field.name}
|
attrs = {:id => custom_value.custom_field_id, :name => custom_value.custom_field.name}
|
||||||
attrs.merge!(:multiple => true) if custom_value.custom_field.multiple?
|
attrs[:multiple] = true if custom_value.custom_field.multiple?
|
||||||
api.custom_field attrs do
|
api.custom_field attrs do
|
||||||
if custom_value.value.is_a?(Array)
|
if custom_value.value.is_a?(Array)
|
||||||
api.array :value do
|
api.array :value do
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ module WorkflowsHelper
|
|||||||
end
|
end
|
||||||
all_tag_options = {:value => 'all', :selected => (selected == 'all')}
|
all_tag_options = {:value => 'all', :selected => (selected == 'all')}
|
||||||
if multiple
|
if multiple
|
||||||
all_tag_options.merge!(:style => "display:none;")
|
all_tag_options[:style] = "display:none;"
|
||||||
end
|
end
|
||||||
option_tags << content_tag('option', l(:label_all), all_tag_options)
|
option_tags << content_tag('option', l(:label_all), all_tag_options)
|
||||||
option_tags << options_from_collection_for_select(objects, "id", "name", selected)
|
option_tags << options_from_collection_for_select(objects, "id", "name", selected)
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ class AuthSourceLdap < AuthSource
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
unless ldap_user.blank? && ldap_password.blank?
|
unless ldap_user.blank? && ldap_password.blank?
|
||||||
options.merge!(:auth => {:method => :simple, :username => ldap_user, :password => ldap_password})
|
options[:auth] = {:method => :simple, :username => ldap_user, :password => ldap_password}
|
||||||
end
|
end
|
||||||
Net::LDAP.new options
|
Net::LDAP.new options
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class Principal < ActiveRecord::Base
|
|||||||
if tokens.present?
|
if tokens.present?
|
||||||
sql << ' OR ('
|
sql << ' OR ('
|
||||||
sql << tokens.map.with_index do |token, index|
|
sql << tokens.map.with_index do |token, index|
|
||||||
params.merge!(:"token_#{index}" => token)
|
params[:"token_#{index}"] = token
|
||||||
"(LOWER(#{table_name}.firstname) LIKE LOWER(:token_#{index}) OR LOWER(#{table_name}.lastname) LIKE LOWER(:token_#{index}))"
|
"(LOWER(#{table_name}.firstname) LIKE LOWER(:token_#{index}) OR LOWER(#{table_name}.lastname) LIKE LOWER(:token_#{index}))"
|
||||||
end.join(' AND ')
|
end.join(' AND ')
|
||||||
sql << ')'
|
sql << ')'
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ module Redmine
|
|||||||
|
|
||||||
def permission(name, hash, options={})
|
def permission(name, hash, options={})
|
||||||
@permissions ||= []
|
@permissions ||= []
|
||||||
options.merge!(:project_module => @project_module)
|
options[:project_module] = @project_module
|
||||||
@permissions << Permission.new(name, hash, options)
|
@permissions << Permission.new(name, hash, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ class ImportsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_show_with_errors_should_show_unsaved_items
|
def test_show_with_errors_should_show_unsaved_items
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge! 'subject' => 20
|
import.mapping['subject'] = 20
|
||||||
import.run
|
import.run
|
||||||
assert_not_equal 0, import.unsaved_items.count
|
assert_not_equal 0, import.unsaved_items.count
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_mapping_with_fixed_tracker
|
def test_mapping_with_fixed_tracker
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('tracker' => 'value:2')
|
import.mapping['tracker'] = 'value:2'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -84,7 +84,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_mapping_with_mapped_tracker
|
def test_mapping_with_mapped_tracker
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('tracker' => '13')
|
import.mapping['tracker'] = '13'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -95,7 +95,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
Tracker.find_by_name('Feature request').update!(:name => 'Feature')
|
Tracker.find_by_name('Feature request').update!(:name => 'Feature')
|
||||||
|
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('tracker' => '13')
|
import.mapping['tracker'] = '13'
|
||||||
import.save!
|
import.save!
|
||||||
import.run
|
import.run
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_status_should_be_set
|
def test_status_should_be_set
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('status' => '14')
|
import.mapping['status'] = '14'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -115,7 +115,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_parent_should_be_set
|
def test_parent_should_be_set
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('parent_issue_id' => '5')
|
import.mapping['parent_issue_id'] = '5'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -126,7 +126,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_import_utf8_with_bom
|
def test_import_utf8_with_bom
|
||||||
import = generate_import_with_mapping('import_issues_utf8_with_bom.csv')
|
import = generate_import_with_mapping('import_issues_utf8_with_bom.csv')
|
||||||
import.settings.merge!('encoding' => 'UTF-8')
|
import.settings['encoding'] = 'UTF-8'
|
||||||
import.save
|
import.save
|
||||||
|
|
||||||
issues = new_records(Issue,3) { import.run }
|
issues = new_records(Issue,3) { import.run }
|
||||||
@@ -275,7 +275,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_assignee_should_be_set
|
def test_assignee_should_be_set
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('assigned_to' => '11')
|
import.mapping['assigned_to'] = '11'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -285,7 +285,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
def test_user_custom_field_should_be_set
|
def test_user_custom_field_should_be_set
|
||||||
field = IssueCustomField.generate!(:field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
|
field = IssueCustomField.generate!(:field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!("cf_#{field.id}" => '11')
|
import.mapping["cf_#{field.id}"] = '11'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -297,7 +297,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
field.tracker_ids = Tracker.all.ids
|
field.tracker_ids = Tracker.all.ids
|
||||||
field.save!
|
field.save!
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!("cf_1" => '8')
|
import.mapping["cf_1"] = '8'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -312,7 +312,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
field.multiple = true
|
field.multiple = true
|
||||||
field.save!
|
field.save!
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!("cf_1" => '15')
|
import.mapping["cf_1"] = '15'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -323,7 +323,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_is_private_should_be_set_based_on_user_locale
|
def test_is_private_should_be_set_based_on_user_locale
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('is_private' => '6')
|
import.mapping['is_private'] = '6'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
@@ -333,7 +333,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
def test_dates_should_be_parsed_using_date_format_setting
|
def test_dates_should_be_parsed_using_date_format_setting
|
||||||
field = IssueCustomField.generate!(:field_format => 'date', :is_for_all => true, :trackers => Tracker.all)
|
field = IssueCustomField.generate!(:field_format => 'date', :is_for_all => true, :trackers => Tracker.all)
|
||||||
import = generate_import_with_mapping('import_dates.csv')
|
import = generate_import_with_mapping('import_dates.csv')
|
||||||
import.settings.merge!('date_format' => Import::DATE_FORMATS[1])
|
import.settings['date_format'] = Import::DATE_FORMATS[1]
|
||||||
import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1', 'due_date' => '2', "cf_#{field.id}" => '3')
|
import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1', 'due_date' => '2', "cf_#{field.id}" => '3')
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
# Tests using other date formats
|
# Tests using other date formats
|
||||||
import = generate_import_with_mapping('import_dates_ja.csv')
|
import = generate_import_with_mapping('import_dates_ja.csv')
|
||||||
import.settings.merge!('date_format' => Import::DATE_FORMATS[3])
|
import.settings['date_format'] = Import::DATE_FORMATS[3]
|
||||||
import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1')
|
import.mapping.merge!('tracker' => 'value:1', 'subject' => '0', 'start_date' => '1')
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||||||
system_version.save!
|
system_version.save!
|
||||||
|
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('fixed_version' => '9')
|
import.mapping['fixed_version'] = '9'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
issues = new_records(Issue, 3) { import.run }
|
issues = new_records(Issue, 3) { import.run }
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_maps_activity_to_column_value
|
def test_maps_activity_to_column_value
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('activity' => '5')
|
import.mapping['activity'] = '5'
|
||||||
import.save!
|
import.save!
|
||||||
|
|
||||||
# N.B. last row is not imported due to the usage of a disabled activity
|
# N.B. last row is not imported due to the usage of a disabled activity
|
||||||
@@ -116,7 +116,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase
|
|||||||
overtime_cf = CustomField.find(10)
|
overtime_cf = CustomField.find(10)
|
||||||
|
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('cf_10' => '6')
|
import.mapping['cf_10'] = '6'
|
||||||
import.save!
|
import.save!
|
||||||
first, second, third, fourth = new_records(TimeEntry, 4) { import.run }
|
first, second, third, fourth = new_records(TimeEntry, 4) { import.run }
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ class TimeEntryImportTest < ActiveSupport::TestCase
|
|||||||
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
||||||
|
|
||||||
import = generate_import_with_mapping
|
import = generate_import_with_mapping
|
||||||
import.mapping.merge!('user' => 'value:3')
|
import.mapping['user'] = 'value:3'
|
||||||
import.save!
|
import.save!
|
||||||
first, second, third, fourth = new_records(TimeEntry, 4) { import.run }
|
first, second, third, fourth = new_records(TimeEntry, 4) { import.run }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user