Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix ruby 2.7 deprecations

ulfertsae38be12c996
diff --git a/lib/open_project/form_tag_helper.rb b/lib/open_project/form_tag_helper.rb
index 20d430af006..052b654df38 100644
--- a/lib/open_project/form_tag_helper.rb
+++ b/lib/open_project/form_tag_helper.rb
@@ -88,8 +88,10 @@ module OpenProject
def text_formatting_wrapper(target_id, options = {})
return ''.html_safe unless target_id.present?
- helper = ::OpenProject::TextFormatting::Formats.rich_helper.new(self)
- helper.wikitoolbar_for target_id, options
+ ::OpenProject::TextFormatting::Formats
+ .rich_helper
+ .new(self)
+ .wikitoolbar_for target_id, **options
end
def styled_check_box_tag(name, value = '1', checked = false, options = {})
diff --git a/lib/tabular_form_builder.rb b/lib/tabular_form_builder.rb
index 3dadb32191b..530e1b84f7a 100644
--- a/lib/tabular_form_builder.rb
+++ b/lib/tabular_form_builder.rb
@@ -211,8 +211,10 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
def text_formatting_wrapper(target_id, options)
return ''.html_safe unless target_id.present?
- helper = ::OpenProject::TextFormatting::Formats.rich_helper.new(@template)
- helper.wikitoolbar_for target_id, options
+ ::OpenProject::TextFormatting::Formats
+ .rich_helper
+ .new(@template)
+ .wikitoolbar_for target_id, **options
end
def field_css_class(selector)
@@ -227,16 +229,12 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
def label_for_field(field, options = {})
return ''.html_safe if options[:no_label]
- text = get_localized_field(field, options[:label])
- label_options = { class: 'form--label', title: text }
-
- if options[:class].is_a?(Array)
- label_options[:class] << " #{options[:class].join(' ')}"
- elsif options[:class].is_a?(String)
- label_options[:class] << " #{options[:class]}"
- end
+ label_options = {
+ class: label_for_field_class(options[:class]),
+ title: get_localized_field(field, options[:label])
+ }
- content = h(text)
+ content = h(label_options[:title])
label_for_field_errors(content, label_options, field)
label_for_field_for(options, label_options, field)
label_for_field_prefix(content, options)
@@ -273,6 +271,17 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
end
end
+ def label_for_field_class(klass)
+ case klass
+ when Array
+ "form--label #{klass.join(' ')}"
+ when String
+ "form--label #{klass}"
+ else
+ "form--label"
+ end
+ end
+
def get_localized_field(field, label)
if label.is_a?(Symbol)
I18n.t(label)
diff --git a/spec/models/projects/scopes/visible_with_activated_time_activity_spec.rb b/spec/models/projects/scopes/visible_with_activated_time_activity_spec.rb
index 88e4e11d621..2aee4f69461 100644
--- a/spec/models/projects/scopes/visible_with_activated_time_activity_spec.rb
+++ b/spec/models/projects/scopes/visible_with_activated_time_activity_spec.rb
@@ -99,8 +99,8 @@ describe Projects::Scopes::VisibleWithActivatedTimeActivity, type: :model do
context 'with project specific overrides' do
before do
- TimeEntryActivitiesProject.insert(activity_id: activity.id, project_id: project.id, active: true)
- TimeEntryActivitiesProject.insert(activity_id: activity.id, project_id: other_project.id, active: false)
+ TimeEntryActivitiesProject.insert({ activity_id: activity.id, project_id: project.id, active: true })
+ TimeEntryActivitiesProject.insert({ activity_id: activity.id, project_id: other_project.id, active: false })
end
context 'and being active' do