From 93645a279e68b5f23d13c340d96ede3f65aff635 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 21 Aug 2024 00:46:15 +0000 Subject: [PATCH] Use anonymous block forwarding introduced in Ruby 3.1 (#38585). git-svn-id: https://svn.redmine.org/redmine/trunk@22973 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 24 +++++++++---------- app/helpers/custom_fields_helper.rb | 2 +- app/helpers/issues_helper.rb | 4 ++-- app/helpers/projects_helper.rb | 2 +- app/helpers/queries_helper.rb | 2 +- app/models/attachment.rb | 4 ++-- app/models/auth_source_ldap.rb | 2 +- app/models/mailer.rb | 4 ++-- app/models/query.rb | 6 ++--- app/models/user.rb | 4 ++-- config/initializers/10-patches.rb | 4 ++-- lib/redmine/activity.rb | 2 +- lib/redmine/activity/fetcher.rb | 2 +- lib/redmine/export/csv.rb | 4 ++-- lib/redmine/field_format.rb | 2 +- lib/redmine/pagination.rb | 6 ++--- lib/redmine/plugin.rb | 8 +++---- lib/redmine/scm/adapters/abstract_adapter.rb | 4 ++-- lib/redmine/scm/adapters/bazaar_adapter.rb | 8 +++---- lib/redmine/scm/adapters/cvs_adapter.rb | 6 ++--- lib/redmine/scm/adapters/git_adapter.rb | 4 ++-- lib/redmine/scm/adapters/mercurial_adapter.rb | 4 ++-- lib/redmine/search.rb | 2 +- lib/redmine/syntax_highlighting.rb | 2 +- lib/redmine/views/builders/structure.rb | 2 +- lib/redmine/views/builders/xml.rb | 8 +++---- .../repositories_git_controller_test.rb | 2 +- test/object_helpers.rb | 12 +++++----- test/test_helper.rb | 12 +++++----- .../unit/issue_nested_set_concurrency_test.rb | 2 +- .../lib/redmine/views/builders/json_test.rb | 2 +- .../lib/redmine/views/builders/xml_test.rb | 2 +- test/unit/mailer_localisation_test.rb | 2 +- 33 files changed, 78 insertions(+), 78 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 58189c3e5..369291a3c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -638,8 +638,8 @@ module ApplicationHelper # Yields the given block for each project with its level in the tree # # Wrapper for Project#project_tree - def project_tree(projects, options={}, &block) - Project.project_tree(projects, options, &block) + def project_tree(projects, options={}, &) + Project.project_tree(projects, options, &) end def principals_check_box_tags(name, principals) @@ -755,7 +755,7 @@ module ApplicationHelper elements.any? ? content_tag('p', (args.join(" \xc2\xbb ") + " \xc2\xbb ").html_safe, :class => 'breadcrumb') : nil end - def other_formats_links(&block) + def other_formats_links(&) concat('

'.html_safe + l(:label_export_to)) yield Redmine::Views::OtherFormatsBuilder.new(self) concat('

'.html_safe) @@ -820,8 +820,8 @@ module ApplicationHelper end end - def actions_dropdown(&block) - content = capture(&block) + def actions_dropdown(&) + content = capture(&) if content.present? trigger = content_tag('span', l(:button_actions), :class => 'icon-only icon-actions', @@ -1508,21 +1508,21 @@ module ApplicationHelper (blank ? [["(#{l('label_option_auto_lang')})", ""]] : []) + languages_options end - def labelled_form_for(*args, &proc) + def labelled_form_for(*args, &) args << {} unless args.last.is_a?(Hash) options = args.last if args.first.is_a?(Symbol) options[:as] = args.shift end options[:builder] = Redmine::Views::LabelledFormBuilder - form_for(*args, &proc) + form_for(*args, &) end - def labelled_fields_for(*args, &proc) + def labelled_fields_for(*args, &) args << {} unless args.last.is_a?(Hash) options = args.last options[:builder] = Redmine::Views::LabelledFormBuilder - fields_for(*args, &proc) + fields_for(*args, &) end def form_tag_html(html_options) @@ -1866,17 +1866,17 @@ module ApplicationHelper end end - def render_if_exist(options = {}, locals = {}, &block) + def render_if_exist(options = {}, locals = {}, &) # Remove test_render_if_exist_should_be_render_partial and test_render_if_exist_should_be_render_nil # along with this method in Redmine 7.0 Rails.application.deprecators[:redmine].warn 'ApplicationHelper#render_if_exist is deprecated and will be removed in Redmine 7.0.' if options[:partial] if lookup_context.exists?(options[:partial], lookup_context.prefixes, true) - render(options, locals, &block) + render(options, locals, &) end else - render(options, locals, &block) + render(options, locals, &) end end diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index f59a8f4cd..82b78cdcb 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -178,7 +178,7 @@ module CustomFieldsHelper # Yields the given block for each custom field value of object that should be # displayed, with the custom field and the formatted value as arguments - def render_custom_field_values(object, &block) + def render_custom_field_values(object, &) object.visible_custom_field_values.each do |custom_value| formatted = show_value(custom_value) if formatted.present? diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 5661cf377..1455fa1c5 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -22,7 +22,7 @@ module IssuesHelper include Redmine::Export::PDF::IssuesPdfHelper include IssueStatusesHelper - def issue_list(issues, &block) + def issue_list(issues, &) ancestors = [] issues.each do |issue| while ancestors.any? && @@ -34,7 +34,7 @@ module IssuesHelper end end - def grouped_issue_list(issues, query, &block) + def grouped_issue_list(issues, query, &) ancestors = [] grouped_query_results(issues, query) do |issue, group_name, group_count, group_totals| while ancestors.any? && diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 43c89a350..5a8649dc3 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -194,7 +194,7 @@ module ProjectsHelper link_to text, url, remote: true, method: method, class: css end - def grouped_project_list(projects, query, &block) + def grouped_project_list(projects, query, &) ancestors = [] grouped_query_results(projects, query) do |project, group_name, group_count, group_totals| ancestors.pop while ancestors.any? && !project.is_descendant_of?(ancestors.last) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index b5ce6addd..516088f8d 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -151,7 +151,7 @@ module QueriesHelper tags end - def grouped_query_results(items, query, &block) + def grouped_query_results(items, query, &) result_count_by_group = query.result_count_by_group previous_group, first = false, true totals_by_group = query.totalable_columns.inject({}) do |h, column| diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 7fc8a8ab0..dea287c97 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -553,7 +553,7 @@ class Attachment < ApplicationRecord # Singleton class method is public class << self # Claims a unique ASCII or hashed filename, yields the open file handle - def create_diskfile(filename, directory=nil, &block) + def create_diskfile(filename, directory=nil, &) timestamp = DateTime.now.strftime("%y%m%d%H%M%S") ascii = '' if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50 @@ -572,7 +572,7 @@ class Attachment < ApplicationRecord File.join(path, name), flags: File::CREAT | File::EXCL | File::WRONLY, binmode: true, - &block + & ) rescue Errno::EEXIST timestamp.succ! diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index 9e66affe9..2d86a8f5d 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -137,7 +137,7 @@ class AuthSourceLdap < AuthSource private - def with_timeout(&block) + def with_timeout(&) timeout = self.timeout timeout = 20 unless timeout && timeout > 0 Timeout.timeout(timeout) do diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7721997f6..10d2fe900 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -639,7 +639,7 @@ class Mailer < ActionMailer::Base end # Activates/desactivates email deliveries during +block+ - def self.with_deliveries(enabled = true, &block) + def self.with_deliveries(enabled = true, &) was_enabled = ActionMailer::Base.perform_deliveries ActionMailer::Base.perform_deliveries = !!enabled yield @@ -652,7 +652,7 @@ class Mailer < ActionMailer::Base # Using the asynchronous queue from a Rake task will generally not work because # Rake will likely end, causing the in-process thread pool to be deleted, before # any/all of the .deliver_later emails are processed - def self.with_synched_deliveries(&block) + def self.with_synched_deliveries(&) adapter = ActionMailer::MailDeliveryJob.queue_adapter ActionMailer::MailDeliveryJob.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter.new yield diff --git a/app/models/query.rb b/app/models/query.rb index 4e0088174..445261893 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -1097,7 +1097,7 @@ class Query < ApplicationRecord private - def grouped_query(&block) + def grouped_query(&) r = nil if grouped? r = yield base_group_scope @@ -1136,13 +1136,13 @@ class Query < ApplicationRecord group(group_by_statement) end - def total_for_custom_field(custom_field, scope, &block) + def total_for_custom_field(custom_field, scope, &) total = custom_field.format.total_for_scope(custom_field, scope) total = map_total(total) {|t| custom_field.format.cast_total_value(custom_field, t)} total end - def map_total(total, &block) + def map_total(total, &) if total.is_a?(Hash) total.each_key {|k| total[k] = yield total[k]} else diff --git a/app/models/user.rb b/app/models/user.rb index ee1303d41..0294e7d21 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -770,8 +770,8 @@ class User < Principal # NB: this method is not used anywhere in the core codebase as of # 2.5.2, but it's used by many plugins so if we ever want to remove # it it has to be carefully deprecated for a version or two. - def allowed_to_globally?(action, options={}, &block) - allowed_to?(action, nil, options.reverse_merge(:global => true), &block) + def allowed_to_globally?(action, options={}, &) + allowed_to?(action, nil, options.reverse_merge(:global => true), &) end def allowed_to_view_all_time_entries?(context) diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 04081c333..52e6d2a21 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -73,8 +73,8 @@ ActionMailer::Base.add_delivery_method :tmp_file, DeliveryMethods::TmpFile module ActionController module MimeResponds class Collector - def api(&block) - any(:xml, :json, &block) + def api(&) + any(:xml, :json, &) end end end diff --git a/lib/redmine/activity.rb b/lib/redmine/activity.rb index 0df7c6096..36663db6b 100644 --- a/lib/redmine/activity.rb +++ b/lib/redmine/activity.rb @@ -26,7 +26,7 @@ module Redmine @@providers = Hash.new {|h, k| h[k]=[]} class << self - def map(&block) + def map(&) yield self end diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index 4264c2e5d..5c031f069 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -60,7 +60,7 @@ module Redmine end # Yields to filter the activity scope - def scope_select(&block) + def scope_select(&) @scope = @scope.select {|t| yield t} end diff --git a/lib/redmine/export/csv.rb b/lib/redmine/export/csv.rb index 8e56b38f3..e0605a844 100644 --- a/lib/redmine/export/csv.rb +++ b/lib/redmine/export/csv.rb @@ -30,7 +30,7 @@ module Redmine include Redmine::I18n class << self - def generate(options = {}, &block) + def generate(options = {}, &) col_sep = (options[:field_separator].presence || l(:general_csv_separator)) encoding = Encoding.find(options[:encoding]) rescue Encoding.find(l(:general_csv_encoding)) @@ -41,7 +41,7 @@ module Redmine (+'').force_encoding(encoding) end - super(str, :col_sep => col_sep, :encoding => encoding, &block) + super(str, :col_sep => col_sep, :encoding => encoding, &) end end diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 93a279758..e3ebc0398 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -187,7 +187,7 @@ module Redmine end end - def parse_keyword(custom_field, keyword, &block) + def parse_keyword(custom_field, keyword, &) separator = Regexp.escape "," keyword = keyword.dup.to_s diff --git a/lib/redmine/pagination.rb b/lib/redmine/pagination.rb index 4ee55165f..f980cbdbc 100644 --- a/lib/redmine/pagination.rb +++ b/lib/redmine/pagination.rb @@ -152,7 +152,7 @@ module Redmine # Yields the given block with the text and parameters # for each pagination link and returns a string that represents the links - def pagination_links_each(paginator, count=nil, options={}, &block) + def pagination_links_each(paginator, count=nil, options={}, &) options.assert_valid_keys :per_page_links per_page_links = options.delete(:per_page_links) @@ -205,7 +205,7 @@ module Redmine info = ''.html_safe info << content_tag('span', "(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})", :class => 'items') + ' ' - if per_page_links != false && links = per_page_links(paginator, &block) + if per_page_links != false && links = per_page_links(paginator, &) info << content_tag('span', links.to_s, :class => 'per-page') end html << content_tag('span', info) @@ -214,7 +214,7 @@ module Redmine end # Renders the "Per page" links. - def per_page_links(paginator, &block) + def per_page_links(paginator, &) values = per_page_options(paginator.per_page, paginator.item_count) if values.any? links = values.collect do |n| diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb index f341d30e1..223b3927a 100644 --- a/lib/redmine/plugin.rb +++ b/lib/redmine/plugin.rb @@ -90,9 +90,9 @@ module Redmine # version '0.0.1' # requires_redmine version_or_higher: '3.0.0' # end - def self.register(id, &block) + def self.register(id, &) p = new(id) - p.instance_eval(&block) + p.instance_eval(&) # Set a default name if it was not provided during registration p.name(id.to_s.humanize) if p.name.nil? @@ -378,9 +378,9 @@ module Redmine # permission :view_contacts, { :contacts => [:list, :show] }, :public => true # permission :destroy_contacts, { :contacts => :destroy } # end - def project_module(name, &block) + def project_module(name, &) @project_module = name - self.instance_eval(&block) + self.instance_eval(&) @project_module = nil end diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index f28137ed5..15e719414 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -206,8 +206,8 @@ module Redmine self.class.logger end - def shellout(cmd, options = {}, &block) - self.class.shellout(cmd, options, &block) + def shellout(cmd, options = {}, &) + self.class.shellout(cmd, options, &) end # Path to the file where scm stderr output is logged diff --git a/lib/redmine/scm/adapters/bazaar_adapter.rb b/lib/redmine/scm/adapters/bazaar_adapter.rb index 559063c37..8b8cbb2bf 100644 --- a/lib/redmine/scm/adapters/bazaar_adapter.rb +++ b/lib/redmine/scm/adapters/bazaar_adapter.rb @@ -297,7 +297,7 @@ module Redmine @aro end - def scm_cmd(*args, &block) + def scm_cmd(*args, &) full_args = [] full_args += args full_args_locale = [] @@ -308,7 +308,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args_locale.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) if $? && $?.exitstatus != 0 raise ScmCommandAborted, "bzr exited with non-zero status: #{$?.exitstatus}" @@ -318,7 +318,7 @@ module Redmine end private :scm_cmd - def scm_cmd_no_raise(*args, &block) + def scm_cmd_no_raise(*args, &) full_args = [] full_args += args full_args_locale = [] @@ -329,7 +329,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args_locale.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) ret end diff --git a/lib/redmine/scm/adapters/cvs_adapter.rb b/lib/redmine/scm/adapters/cvs_adapter.rb index b8cc97001..07e882826 100644 --- a/lib/redmine/scm/adapters/cvs_adapter.rb +++ b/lib/redmine/scm/adapters/cvs_adapter.rb @@ -152,7 +152,7 @@ module Redmine # Returns all revisions found between identifier_from and identifier_to # in the repository. both identifier have to be dates or nil. # these method returns nothing but yield every result in block - def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block) + def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &) path_with_project_utf8 = path_with_proj(path) path_with_project_locale = scm_iconv(@path_encoding, 'UTF-8', path_with_project_utf8) logger.debug " revisions path:" + @@ -381,7 +381,7 @@ module Redmine end end - def scm_cmd(*args, &block) + def scm_cmd(*args, &) full_args = ['-d', root_url] full_args += args full_args_locale = [] @@ -392,7 +392,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args_locale.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) if $? && $?.exitstatus != 0 raise ScmCommandAborted, "cvs exited with non-zero status: #{$?.exitstatus}" diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index f946d2866..c7a5c6b66 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -440,7 +440,7 @@ module Redmine private - def git_cmd(args, options = {}, &block) + def git_cmd(args, options = {}, &) repo_path = root_url || url full_args = ['--git-dir', repo_path] if self.class.client_version_above?([1, 7, 2]) @@ -452,7 +452,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args.map {|e| shell_quote e.to_s}.join(' '), options, - &block + & ) if $? && $?.exitstatus != 0 raise ScmCommandAborted, "git exited with non-zero status: #{$?.exitstatus}" diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index c9a6dd22e..921c9fcc3 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -313,7 +313,7 @@ module Redmine private_constant :HG_EARLY_BOOL_ARG, :HG_EARLY_LIST_ARG # Runs 'hg' command with the given args - def hg(*args, &block) + def hg(*args, &) # as of hg 4.4.1, early parsing of bool options is not terminated at '--' if args.any? {|s| HG_EARLY_BOOL_ARG.match?(s)} raise HgCommandArgumentError, "malicious command argument detected" @@ -331,7 +331,7 @@ module Redmine ret = shellout( self.class.sq_bin + ' ' + full_args.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) if $? && $?.exitstatus != 0 raise HgCommandAborted, "hg exited with non-zero status: #{$?.exitstatus}" diff --git a/lib/redmine/search.rb b/lib/redmine/search.rb index 088ad5785..3605d866f 100644 --- a/lib/redmine/search.rb +++ b/lib/redmine/search.rb @@ -23,7 +23,7 @@ module Redmine @@available_search_types = [] class << self - def map(&block) + def map(&) yield self end diff --git a/lib/redmine/syntax_highlighting.rb b/lib/redmine/syntax_highlighting.rb index 69688a45a..b5785f837 100644 --- a/lib/redmine/syntax_highlighting.rb +++ b/lib/redmine/syntax_highlighting.rb @@ -72,7 +72,7 @@ module Redmine @formatter = formatter end - def stream(tokens, &b) + def stream(tokens, &) token_lines(tokens) do |line| line.each do |tok, val| yield @formatter.span(tok, val) diff --git a/lib/redmine/views/builders/structure.rb b/lib/redmine/views/builders/structure.rb index ab1e3e411..ad40e5867 100644 --- a/lib/redmine/views/builders/structure.rb +++ b/lib/redmine/views/builders/structure.rb @@ -27,7 +27,7 @@ module Redmine @response = response end - def array(tag, options={}, &block) + def array(tag, options={}, &) @struct << [] yield(self) ret = @struct.pop diff --git a/lib/redmine/views/builders/xml.rb b/lib/redmine/views/builders/xml.rb index 7ead34d7d..6acc70a6e 100644 --- a/lib/redmine/views/builders/xml.rb +++ b/lib/redmine/views/builders/xml.rb @@ -33,16 +33,16 @@ module Redmine end # Overrides Builder::XmlBase#tag! to format timestamps in ISO 8601 - def tag!(sym, *args, &block) + def tag!(sym, *args, &) if args.size == 1 && args.first.is_a?(::Time) - tag! sym, args.first.xmlschema, &block + tag!(sym, args.first.xmlschema, &) else super end end - def array(name, options={}, &block) - __send__ name, (options || {}).merge(:type => 'array'), &block + def array(name, options={}, &) + __send__(name, (options || {}).merge(:type => 'array'), &) end end end diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb index 7ac853594..9fecaf8a0 100644 --- a/test/functional/repositories_git_controller_test.rb +++ b/test/functional/repositories_git_controller_test.rb @@ -822,7 +822,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest private - def with_cache(&block) + def with_cache(&) before = ActionController::Base.perform_caching ActionController::Base.perform_caching = true yield diff --git a/test/object_helpers.rb b/test/object_helpers.rb index 49596fec6..b334f77a2 100644 --- a/test/object_helpers.rb +++ b/test/object_helpers.rb @@ -72,8 +72,8 @@ module ObjectHelpers tracker end - def Tracker.generate!(attributes={}, &block) - tracker = Tracker.generate(attributes, &block) + def Tracker.generate!(attributes={}, &) + tracker = Tracker.generate(attributes, &) tracker.save! tracker end @@ -102,8 +102,8 @@ module ObjectHelpers # Generates a saved Issue # Doesn't send notifications by default, use :notify => true to send them - def Issue.generate!(attributes={}, &block) - issue = Issue.generate(attributes, &block) + def Issue.generate!(attributes={}, &) + issue = Issue.generate(attributes, &) issue.save! issue.reload end @@ -155,8 +155,8 @@ module ObjectHelpers entry end - def TimeEntry.generate!(attributes={}, &block) - entry = TimeEntry.generate(attributes, &block) + def TimeEntry.generate!(attributes={}, &) + entry = TimeEntry.generate(attributes, &) entry.save! entry end diff --git a/test/test_helper.rb b/test/test_helper.rb index 975b5f883..ca4b3fe47 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -87,7 +87,7 @@ class ActiveSupport::TestCase Attachment.storage_path = "#{Rails.root}/test/fixtures/files" end - def with_settings(options, &block) + def with_settings(options, &) saved_settings = options.keys.inject({}) do |h, k| h[k] = case Setting[k] @@ -105,7 +105,7 @@ class ActiveSupport::TestCase end # Yields the block with user as the current user - def with_current_user(user, &block) + def with_current_user(user, &) saved_user = User.current User.current = user yield @@ -113,7 +113,7 @@ class ActiveSupport::TestCase User.current = saved_user end - def with_locale(locale, &block) + def with_locale(locale, &) saved_localed = ::I18n.locale ::I18n.locale = locale yield @@ -219,13 +219,13 @@ class ActiveSupport::TestCase # Asserts that a new record for the given class is created # and returns it - def new_record(klass, &block) - new_records(klass, 1, &block).first + def new_record(klass, &) + new_records(klass, 1, &).first end # Asserts that count new records for the given class are created # and returns them as an array order by object id - def new_records(klass, count, &block) + def new_records(klass, count, &) assert_difference "#{klass}.count", count do yield end diff --git a/test/unit/issue_nested_set_concurrency_test.rb b/test/unit/issue_nested_set_concurrency_test.rb index 3d5bde047..87443c548 100644 --- a/test/unit/issue_nested_set_concurrency_test.rb +++ b/test/unit/issue_nested_set_concurrency_test.rb @@ -124,7 +124,7 @@ class IssueNestedSetConcurrencyTest < ActiveSupport::TestCase private - def threaded(count, &block) + def threaded(count, &) with_settings :notified_events => [] do threads = [] count.times do |i| diff --git a/test/unit/lib/redmine/views/builders/json_test.rb b/test/unit/lib/redmine/views/builders/json_test.rb index 7622a4c19..afd772782 100644 --- a/test/unit/lib/redmine/views/builders/json_test.rb +++ b/test/unit/lib/redmine/views/builders/json_test.rb @@ -124,7 +124,7 @@ class Redmine::Views::Builders::JsonTest < ActiveSupport::TestCase end end - def assert_json_output(expected, &block) + def assert_json_output(expected, &) builder = Redmine::Views::Builders::Json.new(ActionDispatch::TestRequest.create, ActionDispatch::TestResponse.create) yield(builder) assert_equal(expected, ActiveSupport::JSON.decode(builder.output)) diff --git a/test/unit/lib/redmine/views/builders/xml_test.rb b/test/unit/lib/redmine/views/builders/xml_test.rb index 42ff882d7..22aee3635 100644 --- a/test/unit/lib/redmine/views/builders/xml_test.rb +++ b/test/unit/lib/redmine/views/builders/xml_test.rb @@ -60,7 +60,7 @@ class Redmine::Views::Builders::XmlTest < ActiveSupport::TestCase end end - def assert_xml_output(expected, &block) + def assert_xml_output(expected, &) builder = Redmine::Views::Builders::Xml.new(ActionDispatch::TestRequest.create, ActionDispatch::TestResponse.create) yield(builder) assert_equal('' + expected, builder.output) diff --git a/test/unit/mailer_localisation_test.rb b/test/unit/mailer_localisation_test.rb index c125e515d..a19644a15 100644 --- a/test/unit/mailer_localisation_test.rb +++ b/test/unit/mailer_localisation_test.rb @@ -131,7 +131,7 @@ class MailerLocalisationTest < ActiveSupport::TestCase private - def with_each_user_language(&block) + def with_each_user_language(&) user = User.find(2) valid_languages.each do |lang| user.update_attribute :language, lang -- 2.39.5