Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make open project running under Ruby 3.3 #14853

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions app/components/op_primer/component_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,31 @@

module OpPrimer
module ComponentHelpers
def flex_layout(**, &)
render(Primer::OpenProject::FlexLayout.new(**), &)
def flex_layout(**, &block)
render(Primer::OpenProject::FlexLayout.new(**), &block)
end

def grid_layout(css_class, **, &)
render(Primer::OpenProject::GridLayout.new(css_class:, **), &)
def grid_layout(css_class, **, &block)
render(Primer::OpenProject::GridLayout.new(css_class:, **), &block)
end

def box_collection(**, &)
render(OpPrimer::BoxCollectionComponent.new(**), &)
def box_collection(**, &block)
render(OpPrimer::BoxCollectionComponent.new(**), &block)
end

def component_collection(**, &)
render(OpPrimer::ComponentCollectionComponent.new(**), &)
def component_collection(**, &block)
render(OpPrimer::ComponentCollectionComponent.new(**), &block)
end

def border_box_row(wrapper_arguments, &)
def border_box_row(wrapper_arguments, &block)
if container
container.with_row(**wrapper_arguments, &)
container.with_row(**wrapper_arguments, &block)
else
container = Primer::Beta::BorderBox.new
row = container.registered_slots[:rows][:renderable_function]
.bind_call(container, **wrapper_arguments)

render(row, &)
render(row, &block)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/contracts/base_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def attribute_alias(db, outside)
attribute_aliases[db] = outside
end

def property(name, options = {}, &)
def property(name, options = {}, &block)
if (twin = options.delete(:form))
options[:twin] = twin
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/member_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def enterprise_allow_new_users?
!OpenProject::Enterprise.user_limit_reached? || !OpenProject::Enterprise.fail_fast?
end

def each_comma_separated(array, &)
array.map(&).flatten
def each_comma_separated(array, &block)
array.map(&block).flatten
end

def transform_array_of_comma_separated_ids(array)
Expand Down
18 changes: 9 additions & 9 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def authorize_for(controller, action, project: @project)
# @param [optional, Hash] parameters_for_method_reference Extra parameters for link_to
#
# When a block is given, skip the name parameter
def link_to_if_authorized(*args, &)
def link_to_if_authorized(*args, &block)
name = args.shift unless block_given?
options = args.shift || {}
html_options = args.shift
Expand All @@ -66,7 +66,7 @@ def link_to_if_authorized(*args, &)
return unless authorize_for(options[:controller] || params[:controller], options[:action])

if block_given?
link_to(options, html_options, *parameters_for_method_reference, &)
link_to(options, html_options, *parameters_for_method_reference, &block)
else
link_to(name, options, html_options, *parameters_for_method_reference)
end
Expand Down Expand Up @@ -118,11 +118,11 @@ def due_date_distance_in_words(date)
# Yields the given block for each project with its level in the tree
#
# Wrapper for Project#project_tree
def project_tree(projects, &)
Project.project_tree(projects, &)
def project_tree(projects, &block)
Project.project_tree(projects, &block)
end

def project_nested_ul(projects, &)
def project_nested_ul(projects, &block)
s = ''
if projects.any?
ancestors = []
Expand Down Expand Up @@ -217,8 +217,8 @@ def to_path_param(path)
path.to_s
end

def other_formats_links(&)
formats = capture(Redmine::Views::OtherFormatsBuilder.new(self), &)
def other_formats_links(&block)
formats = capture(Redmine::Views::OtherFormatsBuilder.new(self), &block)
unless formats.nil? || formats.strip.empty?
content_tag 'p', class: 'other-formats' do
(I18n.t(:label_export_to) + formats).html_safe
Expand Down Expand Up @@ -299,10 +299,10 @@ def highlight_default_language(lang_options)
end
end

def labelled_tabular_form_for(record, options = {}, &)
def labelled_tabular_form_for(record, options = {}, &block)
options.reverse_merge!(builder: TabularFormBuilder, html: {})
options[:html][:class] = 'form' unless options[:html].has_key?(:class)
form_for(record, options, &)
form_for(record, options, &block)
end

def back_url_hidden_field_tag(use_referer: true)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/members_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def global_member_role_deletion_link(member, role)
##
# Decorate the form_for helper for membership of a user or a group to a global
# role.
def global_role_membership_form_for(principal, global_member, options = {}, &)
def global_role_membership_form_for(principal, global_member, options = {}, &block)
args =
if global_member
{ url: principal_membership_path(principal, global_member), method: :patch }
else
{ url: principal_memberships_path(principal), method: :post }
end

form_for(:principal_roles, args.merge(options), &)
form_for(:principal_roles, args.merge(options), &block)
end

def principal_membership_path(principal, global_member, options = {})
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/password_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ module PasswordHelper
##
# Decorate the form_for helper with the request-for-confirmation directive
# when the user is internally authenticated.
def password_confirmation_form_for(record, options = {}, &)
def password_confirmation_form_for(record, options = {}, &block)
if password_confirmation_required?
options.reverse_merge!(html: {})
data = options[:html].fetch(:data, {})
options[:html][:data] = password_confirmation_data_attribute(data)
end

form_for(record, options, &)
form_for(record, options, &block)
end

##
# Decorate the form_tag helper with the request-for-confirmation directive
# when the user is internally authenticated.
def password_confirmation_form_tag(url_for_options = {}, options = {}, &)
def password_confirmation_form_tag(url_for_options = {}, options = {}, &block)
if password_confirmation_required?
data = options.fetch(:data, {})
options[:data] = password_confirmation_data_attribute(data)
end

form_tag(url_for_options, options, &)
form_tag(url_for_options, options, &block)
end

def password_confirmation_data_attribute(with_data = {})
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ def projects_with_level(projects)
end
end

def projects_with_levels_order_sensitive(projects, &)
def projects_with_levels_order_sensitive(projects, &block)
if sorted_by_lft?
project_tree(projects, &)
project_tree(projects, &block)
else
projects_with_level(projects, &)
projects_with_level(projects, &block)
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,17 @@ def setting_label(setting, options = {})
)
end

def setting_block(setting, options = {}, &)
setting_label(setting, options) + wrap_field_outer(options, &)
def setting_block(setting, options = {}, &block)
setting_label(setting, options) + wrap_field_outer(options, &block)
end

private

def wrap_field_outer(options, &)
def wrap_field_outer(options, &block)
if options[:label] == false
yield
else
content_tag(:span, class: 'form--field-container', &)
content_tag(:span, class: 'form--field-container', &block)
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/helpers/sort_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def to_query_hash
.to_h
end

def map_each(&)
to_a.map(&)
def map_each(&block)
to_a.map(&block)
end

def add!(key, asc)
Expand Down Expand Up @@ -341,11 +341,11 @@ def order_string(column, inverted: false)
end
end

def within_sort_header_tag_hierarchy(options, classes, &)
def within_sort_header_tag_hierarchy(options, classes, &block)
content_tag 'th', options do
content_tag 'div', class: 'generic-table--sort-header-outer' do
content_tag 'div', class: 'generic-table--sort-header' do
content_tag('span', class: classes, &)
content_tag('span', class: classes, &block)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/toolbar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def dom_title(raw_title, link_to = nil, title_class: nil, title_extra: nil)
end
end

def dom_toolbar(&)
def dom_toolbar(&block)
return '' unless block_given?

content_tag(:ul, class: 'toolbar-items', &)
content_tag(:ul, class: 'toolbar-items', &block)
end
end
2 changes: 1 addition & 1 deletion app/helpers/work_packages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def link_to_work_package(package, options = {})
end.html_safe
end

def work_package_list(work_packages, &)
def work_package_list(work_packages, &block)
ancestors = []
work_packages.each do |work_package|
while ancestors.any? && !work_package.is_descendant_of?(ancestors.last)
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ApplicationMailer < ActionMailer::Base

class << self
# Activates/deactivates email deliveries during +block+
def with_deliveries(temporary_state = true, &)
def with_deliveries(temporary_state = true, &block)
old_state = ActionMailer::Base.perform_deliveries
ActionMailer::Base.perform_deliveries = temporary_state
yield
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/member_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def send_mail(current_user, member, subject, message)
end
end

def in_member_locale(member, &)
def in_member_locale(member, &block)
raise ArgumentError unless member.principal.is_a?(User)

with_locale_for(member.principal, &)
with_locale_for(member.principal, &block)
end
end
2 changes: 1 addition & 1 deletion app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def self.most_recently_changed(*record_classes)
&.first # max column
end

def self.skip_optimistic_locking(&)
def self.skip_optimistic_locking(&block)
# TODO: The activerecord-import gem does not respect the ActiveRecord::Base.lock_optimistically
# flag, so a direct cleaning of the locking_column is necessary.
# Once the gem is updated we can use the ActiveRecord::Base.lock_optimistically = false, instead of
Expand Down
4 changes: 2 additions & 2 deletions app/models/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ def copy
attachment
end

def copy!(&)
attachment = copy(&)
def copy!(&block)
attachment = copy(&block)

attachment.save!
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/colors/hex_color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def rgb_colors
.map(&:hex) # to int
end

def rgb_modify(&)
def rgb_modify(&block)
rgb_colors
.map(&)
.map(&block)
.map(&:round)
.map { |val| [val, 255].min }
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/virtual_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def _define_virtual_attribute_setter(attribute)
end
end

def _define_virtual_attribute_getter(attribute, &)
def _define_virtual_attribute_getter(attribute, &block)
define_method attribute do
if instance_variable_get(:"@#{attribute}_set")
instance_variable_get(:"@#{attribute}")
else
value = instance_eval(&)
value = instance_eval(&block)

set_virtual_attribute_was(attribute, value)

Expand Down
4 changes: 2 additions & 2 deletions app/models/exports/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Register
class << self
attr_reader :lists, :singles, :formatters

def register(&)
instance_exec(&)
def register(&block)
instance_exec(&block)
end

def list(model, exporter)
Expand Down
4 changes: 2 additions & 2 deletions app/models/journal/notification_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class << self
# In case the method is called multiple times within itself, the first setting prevails.
# This allows to control the setting globally without having to pass the setting down the call stack in
# order to ensure all subsequent code follows the provided setting.
def with(send_notifications, &)
def with(send_notifications, &block)
if send_notifications.nil?
yield
elsif already_set?
log_warning(send_notifications)
yield
else
with_first(send_notifications, &)
with_first(send_notifications, &block)
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,20 @@ def build_projects_hierarchy(projects)
sort_by_name(result)
end

def project_tree_from_hierarchy(projects_hierarchy, level, &)
def project_tree_from_hierarchy(projects_hierarchy, level, &block)
projects_hierarchy.each do |hierarchy|
project = hierarchy[:project]
children = hierarchy[:children]
yield project, level
# recursively show children
project_tree_from_hierarchy(children, level + 1, &) if children.any?
project_tree_from_hierarchy(children, level + 1, &block) if children.any?
end
end

# Yields the given block for each project with its level in the tree
def project_tree(projects, &)
def project_tree(projects, &block)
projects_hierarchy = build_projects_hierarchy(projects)
project_tree_from_hierarchy(projects_hierarchy, 0, &)
project_tree_from_hierarchy(projects_hierarchy, 0, &block)
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/models/queries/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def column(query, column)
@columns[query] << column
end

def register(query, &)
Registration.new(query).instance_exec(&)
def register(query, &block)
Registration.new(query).instance_exec(&block)
end

attr_accessor :filters,
Expand Down
2 changes: 1 addition & 1 deletion app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def self.#{name}_writable?
class_eval src, __FILE__, __LINE__
end

def method_missing(method, *, &)
def method_missing(method, *, &block)
if exists?(accessor_base_name(method))
create_setting_accessors(accessor_base_name(method))

Expand Down
Loading
Loading