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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix ruby 2.7 deprecations (#8867)
ulfertsa112999dcca5
diff --git a/app/models/group.rb b/app/models/group.rbindex 8a37e71820b..9913ca005c1 100644--- a/app/models/group.rb+++ b/app/models/group.rb@@ -85,7 +85,7 @@ class Group < Principal::Groups::AddUsersService.new(self, current_user: User.current)- .call(user_ids)+ .call(ids: user_ids).tap do |result|raise "Failed to add to group #{result.message}" if result.failure?enddiff --git a/app/services/base_services/base_callable.rb b/app/services/base_services/base_callable.rbindex a95a8c51cfd..43b9746d136 100644--- a/app/services/base_services/base_callable.rb+++ b/app/services/base_services/base_callable.rb@@ -43,7 +43,7 @@ module BaseServicesprotected- def perform(params)+ def perform(params = {})raise NotImplementedErrorendenddiff --git a/app/services/custom_actions/update_work_package_service.rb b/app/services/custom_actions/update_work_package_service.rbindex 3f878f9c6d7..6788f91a4b7 100644--- a/app/services/custom_actions/update_work_package_service.rb+++ b/app/services/custom_actions/update_work_package_service.rb@@ -47,7 +47,7 @@ class CustomActions::UpdateWorkPackageServiceresult = ::WorkPackages::UpdateService.new(user: user,model: work_package)- .call({})+ .call(**{})block_with_result(result, &block)enddiff --git a/app/services/groups/add_users_service.rb b/app/services/groups/add_users_service.rbindex 8f421dea442..88ec3439b74 100644--- a/app/services/groups/add_users_service.rb+++ b/app/services/groups/add_users_service.rb@@ -38,9 +38,9 @@ module Groupscontract_class: Groups::AddUsersContractend- def after_validate(user_ids, _call)+ def after_validate(params, _call)::Group.transaction do- add_to_user_and_projects(user_ids)+ add_to_user_and_projects(params[:ids])endenddiff --git a/app/services/work_packages/bulk/update_service.rb b/app/services/work_packages/bulk/update_service.rbindex ee131d40ca3..7bbb3d0c530 100644--- a/app/services/work_packages/bulk/update_service.rb+++ b/app/services/work_packages/bulk/update_service.rb@@ -69,7 +69,7 @@ module WorkPackagesservice_call = WorkPackages::UpdateService.new(user: user, model: work_package)- .call(attributes.merge(send_notifications: params[:send_notification] == '1').symbolize_keys)+ .call(**attributes.merge(send_notifications: params[:send_notification] == '1').symbolize_keys)if service_call.success?saved << work_package.iddiff --git a/app/services/work_packages/move_service.rb b/app/services/work_packages/move_service.rbindex c30f4cec956..527391905bb 100644--- a/app/services/work_packages/move_service.rb+++ b/app/services/work_packages/move_service.rb@@ -43,14 +43,14 @@ class WorkPackages::MoveServiceWorkPackages::CopyService.new(user: user,work_package: wp)- .call(attributes.symbolize_keys)+ .call(**attributes.symbolize_keys)enddef update(attributes)WorkPackages::UpdateService.new(user: user,model: work_package)- .call(attributes.symbolize_keys)+ .call(**attributes.symbolize_keys)enddef copy_with_updated_parent_id(wp, attributes, ancestors)diff --git a/config/routes.rb b/config/routes.rbindex ce44a6808f5..2e375c7af16 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -42,7 +42,10 @@ OpenProject::Application.routes.draw doget '/issues(/)' => redirect("#{rails_relative_url_root}/work_packages")# The URI.escape doesn't escape / unless you ask it to.# see https://github.com/rails/rails/issues/5688- get '/issues/*rest' => redirect { |params, _req| "#{rails_relative_url_root}/work_packages/#{URI.escape(params[:rest])}" }+ get '/issues/*rest' => redirect { |params, _req|+ "#{rails_relative_url_root}/work_packages/#{URI::RFC2396_Parser.new.escape(params[:rest])}"+ }+# Respond with 410 gone for APIV2 callsmatch '/api/v2(/*unmatched_route)', to: proc { [410, {}, ['']] }, via: :all@@ -50,7 +53,9 @@ OpenProject::Application.routes.draw do# Redirect wp short url for work packages to full URLget '/wp(/)' => redirect("#{rails_relative_url_root}/work_packages")- get '/wp/*rest' => redirect { |params, _req| "#{rails_relative_url_root}/work_packages/#{URI.escape(params[:rest])}" }+ get '/wp/*rest' => redirect { |params, _req|+ "#{rails_relative_url_root}/work_packages/#{URI::RFC2396_Parser.new.escape(params[:rest])}"+ }# Add catch method for Rack OmniAuth to allow route helpers# Note: This renders a 404 in rails but is caught by omniauth in Rack beforediff --git a/lib/api/v3/attachments/attachment_upload_representer.rb b/lib/api/v3/attachments/attachment_upload_representer.rbindex fa186bc6e85..950ab196139 100644--- a/lib/api/v3/attachments/attachment_upload_representer.rb+++ b/lib/api/v3/attachments/attachment_upload_representer.rb@@ -72,7 +72,7 @@ module APIattr_reader :attachment- def initialize(attachment, options = {})+ def initialize(attachment, current_user:)superfog_hash = DirectFogUploader.direct_fog_hash attachment: attachmentdiff --git a/lib/open_project/patches/carrierwave.rb b/lib/open_project/patches/carrierwave_sanitized_file.rbsimilarity index 52%rename from lib/open_project/patches/carrierwave.rbrename to lib/open_project/patches/carrierwave_sanitized_file.rbindex aec0c69f921..8951e55e8fc 100644--- a/lib/open_project/patches/carrierwave.rb+++ b/lib/open_project/patches/carrierwave_sanitized_file.rb@@ -5,7 +5,12 @@ require 'carrierwave/storage/fog'# All we did is add `options[:expire_at]`.## @todo Upgrade to CarrierWave 2.0.2 to make this patch obsolete.-module OpenProject::Patches::Carrierwave++if Gem.loaded_specs["carrierwave"].version > Gem::Version.new('1.3.1')+ raise "Check if these patches of Carrierwave are still required"+end++module OpenProject::Patches::FogFileextend ActiveSupport::Concernincluded do@@ -16,24 +21,24 @@ module OpenProject::Patches::Carrierwavelocal_file = local_directory.files.new(:key => path)expire_at = options[:expire_at] || ::Fog::Time.now + @uploader.fog_authenticated_url_expirationcase @uploader.fog_credentials[:provider]- when 'AWS', 'Google'- # Older versions of fog-google do not support options as a parameter- if url_options_supported?(local_file)- local_file.url(expire_at, options)- else- warn "Options hash not supported in #{local_file.class}. You may need to upgrade your Fog provider."- local_file.url(expire_at)- end- when 'Rackspace'- connection.get_object_https_url(@uploader.fog_directory, path, expire_at, options)- when 'OpenStack'- connection.get_object_https_url(@uploader.fog_directory, path, expire_at)+ when 'AWS', 'Google'+ # Older versions of fog-google do not support options as a parameter+ if url_options_supported?(local_file)+ local_file.url(expire_at, options)else+ warn "Options hash not supported in #{local_file.class}. You may need to upgrade your Fog provider."local_file.url(expire_at)+ end+ when 'Rackspace'+ connection.get_object_https_url(@uploader.fog_directory, path, expire_at, options)+ when 'OpenStack'+ connection.get_object_https_url(@uploader.fog_directory, path, expire_at)+ else+ local_file.url(expire_at)endendendendend-CarrierWave::Storage::Fog::File.send(:include, OpenProject::Patches::Carrierwave)+CarrierWave::Storage::Fog::File.send(:include, OpenProject::Patches::FogFile)diff --git a/lib/open_project/patches/fog_file.rb b/lib/open_project/patches/fog_file.rbnew file mode 100644index 00000000000..4265dc6ea3b--- /dev/null+++ b/lib/open_project/patches/fog_file.rb@@ -0,0 +1,19 @@+if Gem.loaded_specs["carrierwave"].version > Gem::Version.new('1.3.1')+ raise "Check if these patches of Carrierwave are still required"+end++module OpenProject::Patches::CarrierwaveSanitizedFile+ extend ActiveSupport::Concern++ included do+ # create the directory if it doesn't exist+ # Overwritten to avoid ruby 2.7 deprecations+ def mkdir!(path, directory_permissions)+ options = {}+ options[:mode] = directory_permissions if directory_permissions+ FileUtils.mkdir_p(File.dirname(path), **options) unless File.exist?(File.dirname(path))+ end+ end+end++CarrierWave::SanitizedFile.send(:include, OpenProject::Patches::CarrierwaveSanitizedFile)diff --git a/modules/bim/app/services/bim/bcf/issues/create_service.rb b/modules/bim/app/services/bim/bcf/issues/create_service.rbindex 681789e146f..356628c6465 100644--- a/modules/bim/app/services/bim/bcf/issues/create_service.rb+++ b/modules/bim/app/services/bim/bcf/issues/create_service.rb@@ -63,11 +63,13 @@ module Bim::Bcf::WorkPackages::UpdateService.new(user: user, model: work_package)- .call(params)+ .call(**params)enddef create_work_package(params)- ::WorkPackages::CreateService.new(user: user).call(params)+ ::WorkPackages::CreateService+ .new(user: user)+ .call(**params)enddef work_package_id_from_links(links)diff --git a/modules/bim/app/services/bim/bcf/issues/update_service.rb b/modules/bim/app/services/bim/bcf/issues/update_service.rbindex 1096980ee50..27a90c7779b 100644--- a/modules/bim/app/services/bim/bcf/issues/update_service.rb+++ b/modules/bim/app/services/bim/bcf/issues/update_service.rb@@ -38,7 +38,7 @@ module Bim::Bcf.new(model: model.work_package,user: user,contract_class: ::WorkPackages::UpdateContract)- .call(params)+ .call(**params)if wp_call.success?issue_params = params.slice(*Bim::Bcf::Issue::SETTABLE_ATTRIBUTES)diff --git a/modules/bim/lib/open_project/bim/bcf_xml/issue_reader.rb b/modules/bim/lib/open_project/bim/bcf_xml/issue_reader.rbindex 94e934c3170..90727378d25 100644--- a/modules/bim/lib/open_project/bim/bcf_xml/issue_reader.rb+++ b/modules/bim/lib/open_project/bim/bcf_xml/issue_reader.rb@@ -70,7 +70,7 @@ module OpenProject::Bim::BcfXmldef create_work_packageattributes = work_package_attributes.merge(project: project)- call = WorkPackages::CreateService.new(user: user).call(attributes)+ call = WorkPackages::CreateService.new(user: user).call(**attributes)force_overwrite(call.result) if call.success?diff --git a/modules/costs/spec/requests/api/time_entry_resource_spec.rb b/modules/costs/spec/requests/api/time_entry_resource_spec.rbindex 9029ffd2a70..6802780c710 100644--- a/modules/costs/spec/requests/api/time_entry_resource_spec.rb+++ b/modules/costs/spec/requests/api/time_entry_resource_spec.rb@@ -456,7 +456,7 @@ describe 'API v3 time_entry resource', type: :request docontext 'if sending an activity the project disables' dolet(:disable_activity) do- TimeEntryActivitiesProject.insert activity_id: activity.id, project_id: project.id, active: false+ TimeEntryActivitiesProject.insert( { activity_id: activity.id, project_id: project.id, active: false } )endlet(:additional_setup) { -> { disable_activity } }@@ -549,7 +549,7 @@ describe 'API v3 time_entry resource', type: :request docontext 'if sending an activity the project disables' dolet(:disable_activity) do- TimeEntryActivitiesProject.insert activity_id: activity.id, project_id: project.id, active: false+ TimeEntryActivitiesProject.insert( { activity_id: activity.id, project_id: project.id, active: false } )endlet(:additional_setup) { -> { disable_activity } }diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rbindex 118f15ebbc6..a80d8225118 100644--- a/spec/factories/group_factory.rb+++ b/spec/factories/group_factory.rb@@ -42,7 +42,7 @@ FactoryBot.define doUser.system.run_given do |system_user|::Groups::AddUsersService.new(group, current_user: system_user)- .call(members.map(&:id))+ .call(ids: members.map(&:id)).on_failure { |call| raise call.message }endenddiff --git a/spec/models/projects/scopes/activated_time_activity_spec.rb b/spec/models/projects/scopes/activated_time_activity_spec.rbindex 0948b158045..d193fa0d310 100644--- a/spec/models/projects/scopes/activated_time_activity_spec.rb+++ b/spec/models/projects/scopes/activated_time_activity_spec.rb@@ -60,8 +60,8 @@ describe Projects::Scopes::ActivatedTimeActivity, type: :model docontext 'with project specific overrides' dobefore 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 } )endcontext 'and being active' dodiff --git a/spec/requests/api/v3/watcher_resource_spec.rb b/spec/requests/api/v3/watcher_resource_spec.rbindex dc7c6bcf490..c279d222d2a 100644--- a/spec/requests/api/v3/watcher_resource_spec.rb+++ b/spec/requests/api/v3/watcher_resource_spec.rb@@ -269,7 +269,7 @@ describe 'API v3 Watcher resource', type: :request, content_type: :json dopath = api_v3_paths.available_watchers work_package.idfilters = %([{ "name": { "operator": "~", "values": ["#{query}"] } }])- "#{path}?filters=#{URI::escape(filters)}"+ "#{path}?filters=#{URI::RFC2396_Parser.new.escape(filters)}"endcontext 'that does not exist' dodiff --git a/spec/services/groups/add_users_service_integration_spec.rb b/spec/services/groups/add_users_service_integration_spec.rbindex 561fbb34068..60d31ed574f 100644--- a/spec/services/groups/add_users_service_integration_spec.rb+++ b/spec/services/groups/add_users_service_integration_spec.rb@@ -48,7 +48,7 @@ describe Groups::AddUsersService, 'integration', type: :model dolet(:user2) { FactoryBot.create :user }let(:user_ids) { [user1.id, user2.id] }- subject { instance.call(user_ids) }+ subject { instance.call(ids: user_ids) }context 'as an admin user' dolet(:current_user) { admin }diff --git a/spec/services/work_packages/create_service_integration_spec.rb b/spec/services/work_packages/create_service_integration_spec.rbindex 1d5ecee8526..da5a5258063 100644--- a/spec/services/work_packages/create_service_integration_spec.rb+++ b/spec/services/work_packages/create_service_integration_spec.rb@@ -69,7 +69,7 @@ describe WorkPackages::CreateService, 'integration', type: :model doendlet(:service_result) doinstance- .call(attributes)+ .call(**attributes)endbefore do@@ -138,7 +138,7 @@ describe WorkPackages::CreateService, 'integration', type: :model doendit 'reports on invalid attachments and sets the new if everything is valid' do- result = instance.call(attributes.merge(attachment_ids: [other_users_attachment.id]))+ result = instance.call(**attributes.merge(attachment_ids: [other_users_attachment.id]))expect(result).to be_failure@@ -153,7 +153,7 @@ describe WorkPackages::CreateService, 'integration', type: :model doexpect(other_users_attachment.reload.container).to be_nil- result = instance.call(attributes.merge(attachment_ids: [users_attachment.id]))+ result = instance.call(**attributes.merge(attachment_ids: [users_attachment.id]))expect(result).to be_successdiff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rbindex 97f67566db2..a13991aa2b1 100644--- a/spec/services/work_packages/update_service_integration_spec.rb+++ b/spec/services/work_packages/update_service_integration_spec.rb@@ -104,7 +104,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model, with_maendsubject do- instance.call(attributes.merge(send_notifications: false).symbolize_keys)+ instance.call(**attributes.merge(send_notifications: false).symbolize_keys)enddescribe '#call' dodiff --git a/spec/services/work_packages/update_service_spec.rb b/spec/services/work_packages/update_service_spec.rbindex 63841d134e4..67174c21c06 100644--- a/spec/services/work_packages/update_service_spec.rb+++ b/spec/services/work_packages/update_service_spec.rb@@ -98,7 +98,7 @@ describe WorkPackages::UpdateService, type: :model doendshared_examples_for 'service call' do- subject { instance.call(call_attributes.merge(send_notifications: send_notifications).symbolize_keys) }+ subject { instance.call(**call_attributes.merge(send_notifications: send_notifications).symbolize_keys) }it 'is successful' doexpect(subject.success?).to be_truthydiff --git a/spec/support/queries/shared_get_individual_query_examples.rb b/spec/support/queries/shared_get_individual_query_examples.rbindex 75271691081..99b1b82c994 100644--- a/spec/support/queries/shared_get_individual_query_examples.rb+++ b/spec/support/queries/shared_get_individual_query_examples.rb@@ -31,7 +31,7 @@ shared_examples_for 'GET individual query' dolet(:filter) { [] }let(:path) doif filter.any?- params = URI.encode(JSON.dump(filter))+ params = CGI.escape(JSON.dump(filter))"#{base_path}?filters=#{params}"elsebase_pathdiff --git a/spec_legacy/unit/member_spec.rb b/spec_legacy/unit/member_spec.rbindex def31bf89e5..59037ddcd00 100644--- a/spec_legacy/unit/member_spec.rb+++ b/spec_legacy/unit/member_spec.rb@@ -26,7 +26,7 @@## See docs/COPYRIGHT.rdoc for more details.#++-require 'legacy_spec_helper'+require_relative '../legacy_spec_helper'describe Member, type: :model dobefore do