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 translation of dry validation contracts

Jan Sandbrink389835e6bfc3
diff --git a/app/contracts/custom_fields/hierarchy/generate_root_contract.rb b/app/contracts/custom_fields/hierarchy/generate_root_contract.rb
index bb8323c8790..108e260f99c 100644
--- a/app/contracts/custom_fields/hierarchy/generate_root_contract.rb
+++ b/app/contracts/custom_fields/hierarchy/generate_root_contract.rb
@@ -30,9 +30,7 @@
module CustomFields
module Hierarchy
- class GenerateRootContract < Dry::Validation::Contract
- config.messages.backend = :i18n
-
+ class GenerateRootContract < DryApplicationContract
params do
required(:custom_field).filled(type?: CustomField)
end
diff --git a/app/contracts/custom_fields/hierarchy/insert_list_item_contract.rb b/app/contracts/custom_fields/hierarchy/insert_list_item_contract.rb
index 0a4cbb8a46f..2efc10d6603 100644
--- a/app/contracts/custom_fields/hierarchy/insert_list_item_contract.rb
+++ b/app/contracts/custom_fields/hierarchy/insert_list_item_contract.rb
@@ -30,8 +30,7 @@
module CustomFields
module Hierarchy
- class InsertListItemContract < Dry::Validation::Contract
- config.messages.backend = :i18n
+ class InsertListItemContract < DryApplicationContract
params do
required(:parent).filled(type?: CustomField::Hierarchy::Item)
diff --git a/app/contracts/custom_fields/hierarchy/insert_scored_item_contract.rb b/app/contracts/custom_fields/hierarchy/insert_scored_item_contract.rb
index 14ec96fefd2..4f95c87cdf9 100644
--- a/app/contracts/custom_fields/hierarchy/insert_scored_item_contract.rb
+++ b/app/contracts/custom_fields/hierarchy/insert_scored_item_contract.rb
@@ -30,9 +30,7 @@
module CustomFields
module Hierarchy
- class InsertScoredItemContract < Dry::Validation::Contract
- config.messages.backend = :i18n
-
+ class InsertScoredItemContract < DryApplicationContract
params do
required(:parent).filled(type?: CustomField::Hierarchy::Item)
required(:label).filled(:string)
diff --git a/app/contracts/custom_fields/hierarchy/update_list_item_contract.rb b/app/contracts/custom_fields/hierarchy/update_list_item_contract.rb
index 7bfbecd13f6..cb302386381 100644
--- a/app/contracts/custom_fields/hierarchy/update_list_item_contract.rb
+++ b/app/contracts/custom_fields/hierarchy/update_list_item_contract.rb
@@ -30,9 +30,7 @@
module CustomFields
module Hierarchy
- class UpdateListItemContract < Dry::Validation::Contract
- config.messages.backend = :i18n
-
+ class UpdateListItemContract < DryApplicationContract
params do
required(:item).filled(type?: CustomField::Hierarchy::Item)
optional(:label).filled(:string)
diff --git a/app/contracts/custom_fields/hierarchy/update_scored_item_contract.rb b/app/contracts/custom_fields/hierarchy/update_scored_item_contract.rb
index cddb5b282e7..7cab92cf8c0 100644
--- a/app/contracts/custom_fields/hierarchy/update_scored_item_contract.rb
+++ b/app/contracts/custom_fields/hierarchy/update_scored_item_contract.rb
@@ -30,8 +30,7 @@
module CustomFields
module Hierarchy
- class UpdateScoredItemContract < Dry::Validation::Contract
- config.messages.backend = :i18n
+ class UpdateScoredItemContract < DryApplicationContract
params do
required(:item).filled(type?: CustomField::Hierarchy::Item)
diff --git a/app/contracts/dry_application_contract.rb b/app/contracts/dry_application_contract.rb
new file mode 100644
index 00000000000..1e0aef3d8d2
--- /dev/null
+++ b/app/contracts/dry_application_contract.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+class DryApplicationContract < Dry::Validation::Contract
+ config.messages.backend = :i18n
+ config.messages.top_namespace = "op_dry_validation"
+ config.messages.load_paths = []
+end
diff --git a/app/contracts/work_package_types/copy_workflow_attribute_contract.rb b/app/contracts/work_package_types/copy_workflow_attribute_contract.rb
index 515d7e1fa04..547552e8977 100644
--- a/app/contracts/work_package_types/copy_workflow_attribute_contract.rb
+++ b/app/contracts/work_package_types/copy_workflow_attribute_contract.rb
@@ -29,9 +29,7 @@
#++
module WorkPackageTypes
- class CopyWorkflowAttributeContract < Dry::Validation::Contract
- config.messages.backend = :i18n
-
+ class CopyWorkflowAttributeContract < DryApplicationContract
params do
optional(:copy_workflow_from).filled(:string)
end
diff --git a/app/models/work_package_types/patterns/collection_contract.rb b/app/models/work_package_types/patterns/collection_contract.rb
index c518694360b..8cd5363a30a 100644
--- a/app/models/work_package_types/patterns/collection_contract.rb
+++ b/app/models/work_package_types/patterns/collection_contract.rb
@@ -30,9 +30,7 @@
module WorkPackageTypes
module Patterns
- class CollectionContract < Dry::Validation::Contract
- config.messages.backend = :i18n
-
+ class CollectionContract < DryApplicationContract
params do
optional(:subject).hash do
required(:blueprint).filled(:string)
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 220772dbc75..b1326f7f1c5 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -364,14 +364,23 @@ en:
concatenation:
single: "or"
- dry_validation:
+ op_dry_validation:
+ or: "or"
errors:
- defined: "must not be defined."
- int?: "must be an integer."
+ array?: "must be an array."
decimal?: "must be a decimal."
+ defined: "must not be defined."
+ eql?: "must be equal to %{left}."
filled?: "must be filled."
- key?: "is missing."
greater_or_equal_zero: "must be greater or equal to 0."
+ gteq?: "must be greater than or equal to %{num}."
+ hash?: "must be a hash."
+ included_in?:
+ arg:
+ default: "must be one of: %{list}."
+ range: "must be one of: %{list_left} - %{list_right}."
+ int?: "must be an integer."
+ key?: "is missing."
not_found: "not found."
rules:
copy_workflow_from:
@@ -387,6 +396,8 @@ en:
not_unique: "must be unique within the same hierarchy level."
parent:
not_descendant: "must be a descendant of the hierarchy root."
+ str?: "must be a string."
+ type?: "must be %{type}."
rules:
copy_workflow_from: "Type for workflow copy"
enabled: "Enabled"
diff --git a/lib/api/v3/custom_fields/hierarchy/get_items_parameter_contract.rb b/lib/api/v3/custom_fields/hierarchy/get_items_parameter_contract.rb
index 85a3902643c..7ea446ca30d 100644
--- a/lib/api/v3/custom_fields/hierarchy/get_items_parameter_contract.rb
+++ b/lib/api/v3/custom_fields/hierarchy/get_items_parameter_contract.rb
@@ -32,12 +32,7 @@ module API
module V3
module CustomFields
module Hierarchy
- class GetItemsParameterContract < Dry::Validation::Contract
- config.messages.backend = :i18n
-
- # ToDo: https://community.openproject.org/projects/openproject/work_packages/59238/activity
- config.messages.load_paths << "config/locales/en.yml"
-
+ class GetItemsParameterContract < DryApplicationContract
option :hierarchy_root
params do
diff --git a/modules/openid_connect/app/services/openid_connect/providers/update_service.rb b/modules/openid_connect/app/services/openid_connect/providers/update_service.rb
index 4c1d4e65d79..9bd67db3c9e 100644
--- a/modules/openid_connect/app/services/openid_connect/providers/update_service.rb
+++ b/modules/openid_connect/app/services/openid_connect/providers/update_service.rb
@@ -31,7 +31,7 @@
module OpenIDConnect
module Providers
class UpdateService < BaseServices::Update
- class AttributesContract < Dry::Validation::Contract
+ class AttributesContract < DryApplicationContract
json do
OpenIDConnect::Provider::DISCOVERABLE_STRING_ATTRIBUTES_MANDATORY.each do |attribute|
required(attribute).filled(:string)
diff --git a/modules/storages/app/common/storages/adapters/input/add_user_to_group_contract.rb b/modules/storages/app/common/storages/adapters/input/add_user_to_group_contract.rb
index f3a9b7b9bff..0c1deefc7ae 100644
--- a/modules/storages/app/common/storages/adapters/input/add_user_to_group_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/add_user_to_group_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class AddUserToGroupContract < Dry::Validation::Contract
+ class AddUserToGroupContract < DryApplicationContract
params do
required(:user).filled(:string)
required(:group).filled(:string)
diff --git a/modules/storages/app/common/storages/adapters/input/copy_template_folder_contract.rb b/modules/storages/app/common/storages/adapters/input/copy_template_folder_contract.rb
index 591110281fa..9857e06f2d7 100644
--- a/modules/storages/app/common/storages/adapters/input/copy_template_folder_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/copy_template_folder_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class CopyTemplateFolderContract < Dry::Validation::Contract
+ class CopyTemplateFolderContract < DryApplicationContract
params do
required(:source).filled(:string)
required(:destination).filled(:string)
diff --git a/modules/storages/app/common/storages/adapters/input/create_folder_contract.rb b/modules/storages/app/common/storages/adapters/input/create_folder_contract.rb
index 2e636ec955e..fa9e23865d0 100644
--- a/modules/storages/app/common/storages/adapters/input/create_folder_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/create_folder_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class CreateFolderContract < Dry::Validation::Contract
+ class CreateFolderContract < DryApplicationContract
params do
required(:folder_name).filled(:string)
required(:parent_location).filter(:filled?, :str?).value(AdapterTypes::Location)
diff --git a/modules/storages/app/common/storages/adapters/input/delete_folder_contract.rb b/modules/storages/app/common/storages/adapters/input/delete_folder_contract.rb
index 11dff8c46bf..e76d16fd436 100644
--- a/modules/storages/app/common/storages/adapters/input/delete_folder_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/delete_folder_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class DeleteFolderContract < Dry::Validation::Contract
+ class DeleteFolderContract < DryApplicationContract
params do
# FIXME: Should this be a Location?
required(:location).filled(:string)
diff --git a/modules/storages/app/common/storages/adapters/input/download_link_contract.rb b/modules/storages/app/common/storages/adapters/input/download_link_contract.rb
index f0d0531a1f4..8b3a35bef78 100644
--- a/modules/storages/app/common/storages/adapters/input/download_link_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/download_link_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class DownloadLinkContract < Dry::Validation::Contract
+ class DownloadLinkContract < DryApplicationContract
params do
required(:file_link).filled(type?: FileLink)
end
diff --git a/modules/storages/app/common/storages/adapters/input/file_info_contract.rb b/modules/storages/app/common/storages/adapters/input/file_info_contract.rb
index e0b3bb554d0..b2244ed6a0f 100644
--- a/modules/storages/app/common/storages/adapters/input/file_info_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/file_info_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class FileInfoContract < Dry::Validation::Contract
+ class FileInfoContract < DryApplicationContract
params do
required(:file_id).filled(:string)
end
diff --git a/modules/storages/app/common/storages/adapters/input/file_path_to_id_map_contract.rb b/modules/storages/app/common/storages/adapters/input/file_path_to_id_map_contract.rb
index 55d239e3f38..d7c612b8d22 100644
--- a/modules/storages/app/common/storages/adapters/input/file_path_to_id_map_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/file_path_to_id_map_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class FilePathToIdMapContract < Dry::Validation::Contract
+ class FilePathToIdMapContract < DryApplicationContract
params do
required(:folder).filter(:filled?, :str?).value(AdapterTypes::Location)
required(:depth).filled { (int? & gteq?(0)) | eql?(Float::INFINITY) }
diff --git a/modules/storages/app/common/storages/adapters/input/files_contract.rb b/modules/storages/app/common/storages/adapters/input/files_contract.rb
index d6d971c64d4..3f6f86ed88f 100644
--- a/modules/storages/app/common/storages/adapters/input/files_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/files_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class FilesContract < Dry::Validation::Contract
+ class FilesContract < DryApplicationContract
params do
required(:folder).filter(:filled?, :str?).value(AdapterTypes::Location)
end
diff --git a/modules/storages/app/common/storages/adapters/input/files_info_contract.rb b/modules/storages/app/common/storages/adapters/input/files_info_contract.rb
index d0e3615f996..aa6f6ad4582 100644
--- a/modules/storages/app/common/storages/adapters/input/files_info_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/files_info_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class FilesInfoContract < Dry::Validation::Contract
+ class FilesInfoContract < DryApplicationContract
params do
required(:file_ids).array(:string)
end
diff --git a/modules/storages/app/common/storages/adapters/input/group_users_contract.rb b/modules/storages/app/common/storages/adapters/input/group_users_contract.rb
index 8caf6f6860f..cc8103b70fe 100644
--- a/modules/storages/app/common/storages/adapters/input/group_users_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/group_users_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class GroupUsersContract < Dry::Validation::Contract
+ class GroupUsersContract < DryApplicationContract
params do
required(:group).filled(:string)
end
diff --git a/modules/storages/app/common/storages/adapters/input/open_file_link_contract.rb b/modules/storages/app/common/storages/adapters/input/open_file_link_contract.rb
index 904bc5e3701..95cf7293d39 100644
--- a/modules/storages/app/common/storages/adapters/input/open_file_link_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/open_file_link_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class OpenFileLinkContract < Dry::Validation::Contract
+ class OpenFileLinkContract < DryApplicationContract
params do
required(:file_id).filled(:string)
required(:open_location).maybe(:bool)
diff --git a/modules/storages/app/common/storages/adapters/input/remove_user_from_group_contract.rb b/modules/storages/app/common/storages/adapters/input/remove_user_from_group_contract.rb
index 8ee629eaeb3..0b518cadfff 100644
--- a/modules/storages/app/common/storages/adapters/input/remove_user_from_group_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/remove_user_from_group_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class RemoveUserFromGroupContract < Dry::Validation::Contract
+ class RemoveUserFromGroupContract < DryApplicationContract
params do
required(:user).filled(:string)
required(:group).filled(:string)
diff --git a/modules/storages/app/common/storages/adapters/input/rename_file_contract.rb b/modules/storages/app/common/storages/adapters/input/rename_file_contract.rb
index 23dc724d91a..6d517edcb94 100644
--- a/modules/storages/app/common/storages/adapters/input/rename_file_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/rename_file_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class RenameFileContract < Dry::Validation::Contract
+ class RenameFileContract < DryApplicationContract
params do
required(:new_name).filled(:string)
required(:location).filter(:filled?, :str?).value(AdapterTypes::Location)
diff --git a/modules/storages/app/common/storages/adapters/input/set_permissions_contract.rb b/modules/storages/app/common/storages/adapters/input/set_permissions_contract.rb
index d101b3335cd..7e9a0342199 100644
--- a/modules/storages/app/common/storages/adapters/input/set_permissions_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/set_permissions_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class SetPermissionsContract < Dry::Validation::Contract
+ class SetPermissionsContract < DryApplicationContract
params do
required(:file_id).filled(:string)
required(:user_permissions).array(:hash) do
diff --git a/modules/storages/app/common/storages/adapters/input/strategy_contract.rb b/modules/storages/app/common/storages/adapters/input/strategy_contract.rb
index 9b7149660b0..59931415bf2 100644
--- a/modules/storages/app/common/storages/adapters/input/strategy_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/strategy_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class StrategyContract < Dry::Validation::Contract
+ class StrategyContract < DryApplicationContract
AUTH_METHODS = %i[noop basic_auth oauth_client_credentials oauth_user_token sso_user_token bearer_token].to_set.freeze
params do
diff --git a/modules/storages/app/common/storages/adapters/input/upload_link_contract.rb b/modules/storages/app/common/storages/adapters/input/upload_link_contract.rb
index 54763be553b..4b99018ce6b 100644
--- a/modules/storages/app/common/storages/adapters/input/upload_link_contract.rb
+++ b/modules/storages/app/common/storages/adapters/input/upload_link_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Input
- class UploadLinkContract < Dry::Validation::Contract
+ class UploadLinkContract < DryApplicationContract
params do
required(:folder_id).filled(:string)
required(:file_name).filled(:string)
diff --git a/modules/storages/app/common/storages/adapters/providers/nextcloud/provider_results/capabilities_contract.rb b/modules/storages/app/common/storages/adapters/providers/nextcloud/provider_results/capabilities_contract.rb
index 7538503b3dd..50627f1c73c 100644
--- a/modules/storages/app/common/storages/adapters/providers/nextcloud/provider_results/capabilities_contract.rb
+++ b/modules/storages/app/common/storages/adapters/providers/nextcloud/provider_results/capabilities_contract.rb
@@ -33,7 +33,7 @@ module Storages
module Providers
module Nextcloud
module ProviderResults
- class CapabilitiesContract < Dry::Validation::Contract
+ class CapabilitiesContract < DryApplicationContract
params do
required(:app_enabled).filled(:bool)
required(:group_folder_enabled).filled(:bool)
diff --git a/modules/storages/app/common/storages/adapters/results/storage_file_collection_contract.rb b/modules/storages/app/common/storages/adapters/results/storage_file_collection_contract.rb
index 3eed6200bfb..16189841ca4 100644
--- a/modules/storages/app/common/storages/adapters/results/storage_file_collection_contract.rb
+++ b/modules/storages/app/common/storages/adapters/results/storage_file_collection_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Results
- class StorageFileCollectionContract < Dry::Validation::Contract
+ class StorageFileCollectionContract < DryApplicationContract
params do
required(:files).array(AdapterTypes::StorageFileInstance)
required(:parent).filled(AdapterTypes::StorageFileInstance)
diff --git a/modules/storages/app/common/storages/adapters/results/storage_file_contract.rb b/modules/storages/app/common/storages/adapters/results/storage_file_contract.rb
index 299c8700cc7..cd6a11fd0d7 100644
--- a/modules/storages/app/common/storages/adapters/results/storage_file_contract.rb
+++ b/modules/storages/app/common/storages/adapters/results/storage_file_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Results
- class StorageFileContract < Dry::Validation::Contract
+ class StorageFileContract < DryApplicationContract
params do
before(:value_coercer) do |input|
input.to_h.compact
diff --git a/modules/storages/app/common/storages/adapters/results/storage_file_info_contract.rb b/modules/storages/app/common/storages/adapters/results/storage_file_info_contract.rb
index 88085033bc7..63d7dd391b1 100644
--- a/modules/storages/app/common/storages/adapters/results/storage_file_info_contract.rb
+++ b/modules/storages/app/common/storages/adapters/results/storage_file_info_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Results
- class StorageFileInfoContract < Dry::Validation::Contract
+ class StorageFileInfoContract < DryApplicationContract
params(StorageFileContract.schema) do
before(:value_coercer) do |input|
input.to_h.compact
diff --git a/modules/storages/app/common/storages/adapters/results/upload_link_contract.rb b/modules/storages/app/common/storages/adapters/results/upload_link_contract.rb
index 778e9a89601..f8716ab8cea 100644
--- a/modules/storages/app/common/storages/adapters/results/upload_link_contract.rb
+++ b/modules/storages/app/common/storages/adapters/results/upload_link_contract.rb
@@ -31,7 +31,7 @@
module Storages
module Adapters
module Results
- class UploadLinkContract < Dry::Validation::Contract
+ class UploadLinkContract < DryApplicationContract
params do
required(:destination).filled { uri?(:https) }
required(:method).filled(AdapterTypes::HTTPVerb)
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index fbcaab475ae..5467de31e52 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -32,7 +32,6 @@
# This file got generated by the open_project:plugin generator.
# It is loaded by `modules/storages/lib/open_project/storages.rb` when the plugin
# gets loaded.
-require "dry/validation"
Dry::Validation.load_extensions(:monads)
diff --git a/spec/contracts/custom_fields/hierarchy/insert_list_item_contract_spec.rb b/spec/contracts/custom_fields/hierarchy/insert_list_item_contract_spec.rb
index 2f94324e40e..fad946b3584 100644
--- a/spec/contracts/custom_fields/hierarchy/insert_list_item_contract_spec.rb
+++ b/spec/contracts/custom_fields/hierarchy/insert_list_item_contract_spec.rb
@@ -53,7 +53,7 @@ RSpec.describe CustomFields::Hierarchy::InsertListItemContract do
it "is invalid" do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(parent: ["must be CustomField::Hierarchy::Item"])
+ expect(result.errors.to_h).to include(parent: ["must be CustomField::Hierarchy::Item."])
end
end
@@ -67,7 +67,7 @@ RSpec.describe CustomFields::Hierarchy::InsertListItemContract do
it "is invalid" do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(label: [I18n.t("dry_validation.errors.rules.label.not_unique")])
+ expect(result.errors.to_h).to include(label: ["must be unique within the same hierarchy level."])
end
context "if another locale is set" do
@@ -77,7 +77,7 @@ RSpec.describe CustomFields::Hierarchy::InsertListItemContract do
I18n.config.enforce_available_locales = false
I18n.backend.store_translations(
:mo,
- { dry_validation: {
+ { op_dry_validation: {
errors: { rules: { label: { not_unique: mordor } } }
} }
)
@@ -105,7 +105,7 @@ RSpec.describe CustomFields::Hierarchy::InsertListItemContract do
it "is invalid with localized validation errors" do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(short: [I18n.t("dry_validation.errors.rules.short.not_unique")])
+ expect(result.errors.to_h).to include(short: ["must be unique within the same hierarchy level."])
end
end
@@ -124,7 +124,7 @@ RSpec.describe CustomFields::Hierarchy::InsertListItemContract do
it "is invalid" do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(short: [I18n.t("dry_validation.errors.str?")])
+ expect(result.errors.to_h).to include(short: ["must be a string."])
end
end
diff --git a/spec/contracts/custom_fields/hierarchy/insert_scored_item_contract_spec.rb b/spec/contracts/custom_fields/hierarchy/insert_scored_item_contract_spec.rb
index 6c0f5e26f07..175bc3c5829 100644
--- a/spec/contracts/custom_fields/hierarchy/insert_scored_item_contract_spec.rb
+++ b/spec/contracts/custom_fields/hierarchy/insert_scored_item_contract_spec.rb
@@ -46,9 +46,7 @@ RSpec.describe CustomFields::Hierarchy::InsertScoredItemContract do
end
end
- context "when inputs are empty",
- skip: "dry validation custom locales are not loaded correctly when running this spec together " \
- "with others from this folder." do
+ context "when inputs are empty" do
let(:params) { { parent:, label: "", score: "" } }
it "is invalid" do
@@ -59,9 +57,7 @@ RSpec.describe CustomFields::Hierarchy::InsertScoredItemContract do
end
end
- context "when inputs are missing",
- skip: "dry validation custom locales are not loaded correctly when running this spec together " \
- "with others from this folder." do
+ context "when inputs are missing" do
let(:params) { { parent: } }
it "is invalid" do
@@ -79,7 +75,7 @@ RSpec.describe CustomFields::Hierarchy::InsertScoredItemContract do
it "is invalid" do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(parent: ["must be CustomField::Hierarchy::Item"])
+ expect(result.errors.to_h).to include(parent: ["must be CustomField::Hierarchy::Item."])
end
end
@@ -91,7 +87,7 @@ RSpec.describe CustomFields::Hierarchy::InsertScoredItemContract do
it "is invalid" do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(label: [I18n.t("dry_validation.errors.rules.label.not_unique")])
+ expect(result.errors.to_h).to include(label: ["must be unique within the same hierarchy level."])
end
context "if another locale is set" do
@@ -101,7 +97,7 @@ RSpec.describe CustomFields::Hierarchy::InsertScoredItemContract do
I18n.config.enforce_available_locales = false
I18n.backend.store_translations(
:mo,
- { dry_validation: {
+ { op_dry_validation: {
errors: { rules: { label: { not_unique: mordor } } }
} }
)
@@ -127,7 +123,7 @@ RSpec.describe CustomFields::Hierarchy::InsertScoredItemContract do
it "is invalid with localized validation errors" do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(score: [I18n.t("dry_validation.errors.decimal?")])
+ expect(result.errors.to_h).to include(score: ["must be a decimal."])
end
end
diff --git a/spec/contracts/custom_fields/hierarchy/update_list_item_contract_spec.rb b/spec/contracts/custom_fields/hierarchy/update_list_item_contract_spec.rb
index cc8f5b8a3f4..44e1094f49c 100644
--- a/spec/contracts/custom_fields/hierarchy/update_list_item_contract_spec.rb
+++ b/spec/contracts/custom_fields/hierarchy/update_list_item_contract_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe CustomFields::Hierarchy::UpdateListItemContract do
it("is invalid") do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(item: ["must be CustomField::Hierarchy::Item"])
+ expect(result.errors.to_h).to include(item: ["must be CustomField::Hierarchy::Item."])
end
end
diff --git a/spec/contracts/custom_fields/hierarchy/update_scored_item_contract_spec.rb b/spec/contracts/custom_fields/hierarchy/update_scored_item_contract_spec.rb
index 44c1741b9d0..8e4853078d4 100644
--- a/spec/contracts/custom_fields/hierarchy/update_scored_item_contract_spec.rb
+++ b/spec/contracts/custom_fields/hierarchy/update_scored_item_contract_spec.rb
@@ -69,7 +69,7 @@ RSpec.describe CustomFields::Hierarchy::UpdateScoredItemContract do
it("is invalid") do
result = subject.call(params)
expect(result).to be_failure
- expect(result.errors.to_h).to include(item: ["must be CustomField::Hierarchy::Item"])
+ expect(result.errors.to_h).to include(item: ["must be CustomField::Hierarchy::Item."])
end
end
diff --git a/spec/requests/api/v3/custom_fields/hierarchy/items_api_spec.rb b/spec/requests/api/v3/custom_fields/hierarchy/items_api_spec.rb
index 76719237e79..4907ef5557b 100644
--- a/spec/requests/api/v3/custom_fields/hierarchy/items_api_spec.rb
+++ b/spec/requests/api/v3/custom_fields/hierarchy/items_api_spec.rb
@@ -84,13 +84,13 @@ RSpec.describe "API v3 custom field hierarchy items", :webmock, content_type: :j
context "if parent is set to an undefined value" do
let(:path) { api_v3_paths.custom_field_items(custom_field.id, "wrong item") }
- it_behaves_like "error response", 400, "InvalidQuery", "Parent #{I18n.t('dry_validation.errors.int?')}"
+ it_behaves_like "error response", 400, "InvalidQuery", "Parent must be an integer."
end
context "if depth is negative" do
let(:path) { api_v3_paths.custom_field_items(custom_field.id, nil, -1) }
- it_behaves_like "error response", 400, "InvalidQuery", "Depth #{I18n.t('dry_validation.errors.greater_or_equal_zero')}"
+ it_behaves_like "error response", 400, "InvalidQuery", "Depth must be greater or equal to 0."
end
end
end
diff --git a/spec/services/work_package_types/set_attributes_service_spec.rb b/spec/services/work_package_types/set_attributes_service_spec.rb
index 28cc56da6ff..764eb152913 100644
--- a/spec/services/work_package_types/set_attributes_service_spec.rb
+++ b/spec/services/work_package_types/set_attributes_service_spec.rb
@@ -68,7 +68,7 @@ module WorkPackageTypes
it "adds an error on the patterns attribute" do
result = service.call(params)
- expect(result.errors.details).to eq(patterns: [{ error: "Enabled is missing" }])
+ expect(result.errors.details).to eq(patterns: [{ error: "Enabled is missing." }])
end
it "does not override the already existing value on the model" do