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

replace deprecated access to errors

ulfertse4bced1a5c04
diff --git a/app/services/custom_actions/update_work_package_service.rb b/app/services/custom_actions/update_work_package_service.rb
index 818b9cac7b9..4c6f17c0f1e 100644
--- a/app/services/custom_actions/update_work_package_service.rb
+++ b/app/services/custom_actions/update_work_package_service.rb
@@ -76,7 +76,7 @@ class CustomActions::UpdateWorkPackageService
end
def without_invalid_actions(actions, errors)
- invalid_keys = errors.keys.map { |k| append_id(k) }
+ invalid_keys = errors.attribute_names.map { |k| append_id(k) }
actions.reject { |a| invalid_keys.include?(append_id(a.key)) }
end
@@ -88,6 +88,6 @@ class CustomActions::UpdateWorkPackageService
end
def append_id(sym)
- sym.to_s.chomp('_id') + '_id'
+ "#{sym.to_s.chomp('_id')}_id"
end
end
diff --git a/spec/services/custom_actions/update_work_package_service_spec.rb b/spec/services/custom_actions/update_work_package_service_spec.rb
index 93be89dbe2f..0ba57057f50 100644
--- a/spec/services/custom_actions/update_work_package_service_spec.rb
+++ b/spec/services/custom_actions/update_work_package_service_spec.rb
@@ -70,7 +70,7 @@ describe CustomActions::UpdateWorkPackageService do
end
end
let!(:update_wp_service) do
- wp_service_instance = double('WorkPackages::UpdateService instance')
+ wp_service_instance = instance_double(WorkPackages::UpdateService)
allow(WorkPackages::UpdateService)
.to receive(:new)
@@ -164,7 +164,7 @@ describe CustomActions::UpdateWorkPackageService do
allow(contract)
.to receive(:errors)
- .and_return(alter_action1.key => ['invalid'])
+ .and_return(instance_double(ActiveModel::Errors, attribute_names: [alter_action1.key]))
work_package.lock_version = 200
@@ -205,7 +205,7 @@ describe CustomActions::UpdateWorkPackageService do
allow(contract)
.to receive(:errors)
- .and_return(base: ['invalid'])
+ .and_return(instance_double(ActiveModel::Errors, attribute_names: [:base]))
work_package.lock_version = 200