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
replaces reform & custom error handling
ulfertse2961fba143a
diff --git a/Gemfile b/Gemfileindex bd55a81fd49..24a3a344215 100644--- a/Gemfile+++ b/Gemfile@@ -285,13 +285,13 @@ gem 'bootsnap', '~> 1.4.5', require: false# API gemsgem 'grape', '~> 1.3.0'+gem 'roar', '~> 1.1.0'# CORS for APIgem 'rack-cors', '~> 1.1.1'-gem 'reform', '~> 2.2.0'-gem 'reform-rails', '~> 0.1.7'-gem 'roar', '~> 1.1.0'+# Required for contracts+gem 'disposable', '~> 0.4.7'platforms :mri, :mingw, :x64_mingw dogroup :postgres do@@ -302,7 +302,7 @@ platforms :mri, :mingw, :x64_mingw dogem 'activerecord-nulldb-adapter', '~> 0.4.0'# Have application level locks on the database to have a mutex shared between workers/hosts.- # We e.g. emply this to safeguard the creation of journals.+ # We e.g. employ this to safeguard the creation of journals.gem 'with_advisory_lock', '~> 4.6.0'enddiff --git a/Gemfile.lock b/Gemfile.lockindex f96e072fccc..dd85af452e9 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -792,12 +792,6 @@ GEMrecaptcha (5.5.0)jsonredcarpet (3.5.0)- reform (2.2.4)- disposable (>= 0.4.1)- representable (>= 2.4.0, < 3.1.0)- reform-rails (0.1.7)- activemodel (>= 3.2)- reform (>= 2.2.0)regexp_parser (1.7.0)representable (3.0.4)declarative (< 0.1.0)@@ -1023,6 +1017,7 @@ DEPENDENCIESdeckar01-task_list (~> 2.3.1)delayed_cron_job (~> 0.7.2)delayed_job_active_record (~> 4.1.4)+ disposable (~> 0.4.7)doorkeeper (~> 5.3.1)equivalent-xml (~> 0.6)escape_utils (~> 1.0)@@ -1104,8 +1099,6 @@ DEPENDENCIESrails-i18n (~> 6.0.0)rails_12factorrdoc (>= 2.4.2)- reform (~> 2.2.0)- reform-rails (~> 0.1.7)reporting_engine!request_store (~> 1.5.0)responders (~> 3.0)diff --git a/app/contracts/attribute_help_texts/base_contract.rb b/app/contracts/attribute_help_texts/base_contract.rbindex e7b27ce042c..a6c74249b4b 100644--- a/app/contracts/attribute_help_texts/base_contract.rb+++ b/app/contracts/attribute_help_texts/base_contract.rb@@ -32,11 +32,7 @@ module AttributeHelpTextsclass BaseContract < ::ModelContractinclude Attachments::ValidateReplacements- def validate- validate_user_allowed_to_manage-- super- end+ validate :validate_user_allowed_to_managedef self.modelAttributeHelpTextdiff --git a/app/contracts/custom_actions/execute_contract.rb b/app/contracts/custom_actions/execute_contract.rbindex e8acbf8ffc8..7418107bb59 100644--- a/app/contracts/custom_actions/execute_contract.rb+++ b/app/contracts/custom_actions/execute_contract.rb@@ -28,10 +28,8 @@# See docs/COPYRIGHT.rdoc for more details.#++-require 'model_contract'-module CustomActions- class ExecuteContract < Reform::Contract+ class ExecuteContract < ModelContractproperty :lock_versionproperty :work_package_id@@ -43,7 +41,7 @@ module CustomActionsdef work_package_visiblereturn unless model.work_package_id- unless WorkPackage.visible.where(id: model.work_package_id).exists?+ unless WorkPackage.visible(user).where(id: model.work_package_id).exists?errors.add(:work_package_id, :does_not_exist)endenddiff --git a/app/contracts/delete_contract.rb b/app/contracts/delete_contract.rbindex 155502ee5f0..75dce47b0f1 100644--- a/app/contracts/delete_contract.rb+++ b/app/contracts/delete_contract.rb@@ -37,11 +37,7 @@ class DeleteContract < ModelContractendend- def validate- user_allowed-- super- end+ validate :user_alloweddef user_allowedunless authorized?diff --git a/app/contracts/groups/base_contract.rb b/app/contracts/groups/base_contract.rbindex 25c8ad085aa..b12bb48b09d 100644--- a/app/contracts/groups/base_contract.rb+++ b/app/contracts/groups/base_contract.rb@@ -28,12 +28,7 @@module Groupsclass BaseContract < ::ModelContract-- def validate- user_allowed_to_manage-- super- end+ validate :user_allowed_to_managedef user_allowed_to_manageunless user.admin?diff --git a/app/contracts/members/base_contract.rb b/app/contracts/members/base_contract.rbindex c49c661b37d..2fe5bbfa3dc 100644--- a/app/contracts/members/base_contract.rb+++ b/app/contracts/members/base_contract.rb@@ -35,12 +35,8 @@ module Membersattribute :roles- def validate- user_allowed_to_manage- roles_grantable-- super- end+ validate :user_allowed_to_manage+ validate :roles_grantabledef user_allowed_to_manageif model.project && !user.allowed_to?(:manage_members, model.project)diff --git a/app/contracts/model_contract.rb b/app/contracts/model_contract.rbindex 741fb204d51..7db867d6dcf 100644--- a/app/contracts/model_contract.rb+++ b/app/contracts/model_contract.rb@@ -28,10 +28,24 @@# See docs/COPYRIGHT.rdoc for more details.#++-require 'reform'-require 'reform/form/active_model/model_validations'+class ModelContract < Disposable::Twin+ require "disposable/twin/composition" # Expose.+ include Expose++ feature Setup+ feature Setup::SkipSetter+ feature Default++ include ActiveModel::Validations+ extend ActiveModel::Naming+ extend ActiveModel::Translation++ delegate :id,+ to: :model++ # Allows human_attribute_name to resolve custom fields correctly+ extend Redmine::Acts::Customizable::HumanAttributeName-class ModelContract < Reform::Contractclass << selfdef writable_attributes@writable_attributes ||= []@@ -41,10 +55,6 @@ class ModelContract < Reform::Contract@writable_conditions ||= []end- def attribute_validations- @attribute_validations ||= []- end-def attribute_permissions@attribute_permissions ||= {}end@@ -59,15 +69,25 @@ class ModelContract < Reform::Contractattribute_aliases[db] = outsideend+ def property(name, options = {}, &block)+ if twin = options.delete(:form)+ options[:twin] = twin+ end++ if validates_options = options[:validates]+ validates name, validates_options+ end++ super+ end+def attribute(attribute, options = {}, &block)property attributeadd_writable(attribute, options[:writeable])attribute_permission(attribute, options[:permission])- if block- attribute_validations << block- end+ validate(attribute, &block) if blockenddef default_attribute_permission(permission)@@ -126,11 +146,9 @@ class ModelContract < Reform::Contractwritable_attributes.include?(attribute.to_s)end- def validate+ def validate(*args)+ super()readonly_attributes_unchanged- run_attribute_validations-- super# Allow subclasses to check only contract errorsreturn errors.empty? unless validate_model?@@ -141,7 +159,7 @@ class ModelContract < Reform::Contract# order to have them available at one place.# This is something we need as long as we have validations split# among the model and its contract.- errors.merge!(model.errors, [])+ errors.merge!(model.errors)errors.empty?end@@ -154,7 +172,11 @@ class ModelContract < Reform::Contractenddef self.model- @model ||= name.deconstantize.singularize.constantize+ @model ||= begin+ name.deconstantize.singularize.constantize+ rescue NameError+ ActiveRecord::Base+ endend# use activerecord as the base scope instead of 'activemodel' to be compatible@@ -198,14 +220,6 @@ class ModelContract < Reform::Contractchangedend- def run_attribute_validations- attribute_validations.each { |validation| instance_exec(&validation) }- end-- def attribute_validations- collect_ancestor_attributes(:attribute_validations)- end-def collect_ancestor_attribute_aliases@ancestor_attribute_aliases ||= collect_ancestor_attributes(:attribute_aliases)enddiff --git a/app/contracts/oauth/application_contract.rb b/app/contracts/oauth/application_contract.rbindex 34d1c8c36ae..61abc073d97 100644--- a/app/contracts/oauth/application_contract.rb+++ b/app/contracts/oauth/application_contract.rb@@ -34,11 +34,7 @@ module OAuth::Doorkeeper::Applicationend- def validate- validate_client_credential_user-- super- end+ validate :validate_client_credential_userattribute :nameattribute :redirect_uridiff --git a/app/contracts/projects/archive_contract.rb b/app/contracts/projects/archive_contract.rbindex db28eaad028..3d4701770c0 100644--- a/app/contracts/projects/archive_contract.rb+++ b/app/contracts/projects/archive_contract.rb@@ -30,12 +30,8 @@ module Projectsclass ArchiveContract < ModelContractinclude Projects::Archiver- def validate- validate_admin_only- validate_no_foreign_wp_references-- super- end+ validate :validate_admin_only+ validate :validate_no_foreign_wp_referencesprotecteddiff --git a/app/contracts/projects/base_contract.rb b/app/contracts/projects/base_contract.rbindex 8c360707bab..e8f57d77489 100644--- a/app/contracts/projects/base_contract.rb+++ b/app/contracts/projects/base_contract.rb@@ -52,11 +52,7 @@ module Projectsvalidate_templated_set_by_adminend- def validate- validate_user_allowed_to_manage-- super- end+ validate :validate_user_allowed_to_managedef assignable_parentsProjectdiff --git a/app/contracts/projects/instantiate_template_contract.rb b/app/contracts/projects/instantiate_template_contract.rbindex baef08a3fab..7c3976ac17c 100644--- a/app/contracts/projects/instantiate_template_contract.rb+++ b/app/contracts/projects/instantiate_template_contract.rb@@ -34,11 +34,7 @@ module Projects.where(templated: true)end- def validate- validate_user_allowed_to_instantiate_template-- super- end+ validate :validate_user_allowed_to_instantiate_templateprivatediff --git a/app/contracts/projects/unarchive_contract.rb b/app/contracts/projects/unarchive_contract.rbindex d733b6bb543..1a878e85fc8 100644--- a/app/contracts/projects/unarchive_contract.rb+++ b/app/contracts/projects/unarchive_contract.rb@@ -30,12 +30,8 @@ module Projectsclass UnarchiveContract < ModelContractinclude Projects::Archiver- def validate- validate_admin_only- validate_all_ancestors_active-- super- end+ validate :validate_admin_only+ validate :validate_all_ancestors_activeprotecteddiff --git a/app/contracts/queries/base_contract.rb b/app/contracts/queries/base_contract.rbindex c0f95e11efc..cb4e2e1ffee 100644--- a/app/contracts/queries/base_contract.rb+++ b/app/contracts/queries/base_contract.rb@@ -58,11 +58,8 @@ module QueriesQueryend- def validate- validate_project- user_allowed_to_make_public- super- end+ validate :validate_project+ validate :user_allowed_to_make_publicdef validate_projecterrors.add :project, :error_not_found if project_id.present? && !project_visible?diff --git a/app/contracts/queries/update_contract.rb b/app/contracts/queries/update_contract.rbindex 3db1a8f39e6..60e0f2b0ab6 100644--- a/app/contracts/queries/update_contract.rb+++ b/app/contracts/queries/update_contract.rb@@ -31,10 +31,7 @@ require 'queries/base_contract'module Queriesclass UpdateContract < BaseContract- def validate- user_allowed_to_change- super- end+ validate :user_allowed_to_change### Check if the current user may save the changesdiff --git a/app/contracts/relations/base_contract.rb b/app/contracts/relations/base_contract.rbindex 92f3816cbab..f34f11f4de1 100644--- a/app/contracts/relations/base_contract.rb+++ b/app/contracts/relations/base_contract.rb@@ -51,6 +51,7 @@ module Relationsdef validate!(*args)# same as before_validation callbackmodel.send(:reverse_if_needed)+superenddiff --git a/app/contracts/relations/create_contract.rb b/app/contracts/relations/create_contract.rbindex 66fce6e1f0d..64ee3f59bf5 100644--- a/app/contracts/relations/create_contract.rb+++ b/app/contracts/relations/create_contract.rb@@ -1,4 +1,5 @@#-- encoding: UTF-8+#-- copyright# OpenProject is an open source project management software.# Copyright (C) 2012-2020 the OpenProject GmbHdiff --git a/app/contracts/roles/base_contract.rb b/app/contracts/roles/base_contract.rbindex ba8f1e7d11b..c295fb350e8 100644--- a/app/contracts/roles/base_contract.rb+++ b/app/contracts/roles/base_contract.rb@@ -31,11 +31,7 @@ module Rolesattribute :nameattribute :assignable- def validate- check_permission_prerequisites-- super- end+ validate :check_permission_prerequisitesdef assignable_permissionsif model.is_a?(GlobalRole)@@ -83,10 +79,9 @@ module Rolesdef add_unmet_dependency_error(selected, unmet)errors.add(:permissions,- I18n.t(:'activerecord.errors.models.role.permissions.dependency_missing',- permission: I18n.t("permission_#{selected}"),- dependency: I18n.t("permission_#{unmet}")),- error_symbol: :dependency_missing)+ :dependency_missing,+ permission: I18n.t("permission_#{selected}"),+ dependency: I18n.t("permission_#{unmet}"))endendenddiff --git a/app/contracts/roles/create_contract.rb b/app/contracts/roles/create_contract.rbindex daaab77eddc..40f656125c5 100644--- a/app/contracts/roles/create_contract.rb+++ b/app/contracts/roles/create_contract.rb@@ -30,11 +30,7 @@ module Rolesclass CreateContract < BaseContractattribute :type- def validate- type_in_allowed-- super- end+ validate :type_in_allowedprivatediff --git a/app/contracts/users/base_contract.rb b/app/contracts/users/base_contract.rbindex 755ccff2358..c9ffd7ead54 100644--- a/app/contracts/users/base_contract.rb+++ b/app/contracts/users/base_contract.rb@@ -48,11 +48,7 @@ module UsersUserend- def validate- existing_auth_source-- super- end+ validate :existing_auth_sourceprivatediff --git a/app/contracts/users/update_contract.rb b/app/contracts/users/update_contract.rbindex 857acbc7fe2..e08c7478cd4 100644--- a/app/contracts/users/update_contract.rb+++ b/app/contracts/users/update_contract.rb@@ -32,11 +32,7 @@ require 'users/base_contract'module Usersclass UpdateContract < BaseContract- def validate- user_allowed_to_update-- super- end+ validate :user_allowed_to_updateprivatediff --git a/app/contracts/versions/base_contract.rb b/app/contracts/versions/base_contract.rbindex 56422487603..680a7c2e7c6 100644--- a/app/contracts/versions/base_contract.rb+++ b/app/contracts/versions/base_contract.rb@@ -38,13 +38,9 @@ module Versions:new_record?,to: :model- def validate- user_allowed_to_manage- validate_project_is_set- validate_sharing_included-- super- end+ validate :user_allowed_to_manage+ validate :validate_project_is_set+ validate :validate_sharing_includedattribute :nameattribute :descriptiondiff --git a/app/contracts/versions/delete_contract.rb b/app/contracts/versions/delete_contract.rbindex ec4b5d6d5ed..be972ba7cbc 100644--- a/app/contracts/versions/delete_contract.rb+++ b/app/contracts/versions/delete_contract.rb@@ -30,11 +30,7 @@ module Versionsclass DeleteContract < ::DeleteContractdelete_permission :manage_versions- def validate- validate_no_work_packages_attached-- super- end+ validate :validate_no_work_packages_attachedprotecteddiff --git a/app/contracts/work_packages/create_contract.rb b/app/contracts/work_packages/create_contract.rbindex 3823cf6a17f..c6ce14f9f61 100644--- a/app/contracts/work_packages/create_contract.rb+++ b/app/contracts/work_packages/create_contract.rb@@ -39,11 +39,7 @@ module WorkPackagesdefault_attribute_permission :add_work_packages- def validate- user_allowed_to_add-- super- end+ validate :user_allowed_to_addprivatediff --git a/app/helpers/error_message_helper.rb b/app/helpers/error_message_helper.rbindex 14975692e07..4890629c9e1 100644--- a/app/helpers/error_message_helper.rb+++ b/app/helpers/error_message_helper.rb@@ -45,11 +45,7 @@ module ErrorMessageHelpererror_messages = errors.full_messages- errors.details.each do |attribute, details|- details.each do |error|- object.errors.add(attribute, error[:error], **error.except(:error))- end- end+ object.errors.merge!(errors)render_error_messages_partial(error_messages, object: object)enddiff --git a/app/models/custom_actions/actions/assigned_to.rb b/app/models/custom_actions/actions/assigned_to.rbindex 661e05e15e1..311b2d49d11 100644--- a/app/models/custom_actions/actions/assigned_to.rb+++ b/app/models/custom_actions/actions/assigned_to.rb@@ -91,8 +91,8 @@ class CustomActions::Actions::AssignedTo < CustomActions::Actions::Basedef validate_me_value(errors)if has_me_value? && !User.current.logged?errors.add :actions,- I18n.t(:'activerecord.errors.models.custom_actions.not_logged_in', name: human_name),- error_symbol: :not_logged_in+ :not_logged_in,+ name: human_nameendenddiff --git a/app/models/custom_actions/actions/base.rb b/app/models/custom_actions/actions/base.rbindex ac2b694c1f1..fadb64ffebe 100644--- a/app/models/custom_actions/actions/base.rb+++ b/app/models/custom_actions/actions/base.rb@@ -97,16 +97,16 @@ class CustomActions::Actions::Basedef validate_value_required(errors)if required? && values.empty?errors.add :actions,- I18n.t(:'activerecord.errors.models.custom_actions.empty', name: human_name),- error_symbol: :empty+ :empty,+ name: human_nameendenddef validate_only_one_value(errors)if !multi_value? && values.length > 1errors.add :actions,- I18n.t(:'activerecord.errors.models.custom_actions.only_one_allowed', name: human_name),- error_symbol: :only_one_allowed+ :only_one_allowed,+ name: human_nameendendenddiff --git a/app/models/custom_actions/actions/strategies/validate_in_range.rb b/app/models/custom_actions/actions/strategies/validate_in_range.rbindex 9426a90009c..12aa7639de2 100644--- a/app/models/custom_actions/actions/strategies/validate_in_range.rb+++ b/app/models/custom_actions/actions/strategies/validate_in_range.rb@@ -52,20 +52,18 @@ module CustomActions::Actions::Strategies::ValidateInRangedef validate_smaller_than_maximum(errors)if maximum && values[0] > maximumerrors.add :actions,- I18n.t(:'activerecord.errors.models.custom_actions.smaller_than_or_equal_to',- name: human_name,- count: maximum),- error_symbol: :smaller_than_or_equal_to+ :smaller_than_or_equal_to,+ name: human_name,+ count: maximumendenddef validate_greater_than_minimum(errors)if minimum && values[0] < minimumerrors.add :actions,- I18n.t(:'activerecord.errors.models.custom_actions.greater_than_or_equal_to',- name: human_name,- count: minimum),- error_symbol: :greater_than_or_equal_to+ :greater_than_or_equal_to,+ name: human_name,+ count: minimumendendenddiff --git a/app/models/custom_actions/validate_allowed_value.rb b/app/models/custom_actions/validate_allowed_value.rbindex 75087e13191..2c9fed39eca 100644--- a/app/models/custom_actions/validate_allowed_value.rb+++ b/app/models/custom_actions/validate_allowed_value.rb@@ -28,8 +28,8 @@ module CustomActions::ValidateAllowedValueallowed_ids = allowed_values.map { |v| v[:value] }if values.to_set != (allowed_ids & values).to_seterrors.add attribute,- I18n.t(:'activerecord.errors.models.custom_actions.inclusion', name: human_name),- error_symbol: :inclusion+ :inclusion,+ name: human_nameendendenddiff --git a/app/models/member.rb b/app/models/member.rbindex 0280e71fec3..823a221a3a3 100644--- a/app/models/member.rb+++ b/app/models/member.rb@@ -30,7 +30,7 @@class Member < ApplicationRecordextend DeprecatedAliasbelongs_to :principal, foreign_key: 'user_id'- has_many :member_roles, dependent: :destroy, autosave: true+ has_many :member_roles, dependent: :destroy, autosave: true, validate: falsehas_many :roles, through: :member_rolesbelongs_to :projectdiff --git a/app/models/query.rb b/app/models/query.rbindex 935ea8884f6..d1f28207572 100644--- a/app/models/query.rb+++ b/app/models/query.rb@@ -122,7 +122,8 @@ class Query < ApplicationRecord(column_names - available_names).each do |name|errors.add :column_names,- I18n.t(:error_invalid_query_column, value: name)+ :invalid,+ value: nameendend@@ -131,14 +132,14 @@ class Query < ApplicationRecordsort_criteria.each do |name, _dir|unless available_criteria.include? name.to_s- errors.add :sort_criteria, I18n.t(:error_invalid_sort_criterion, value: name)+ errors.add :sort_criteria, :invalid, value: nameendendenddef validate_group_byunless group_by.blank? || groupable_columns.map(&:name).map(&:to_s).include?(group_by.to_s)- errors.add :group_by, I18n.t(:error_invalid_group_by, value: group_by)+ errors.add :group_by, :invalid, value: group_byendenddiff --git a/app/models/version.rb b/app/models/version.rbindex 810cab18325..a6af937bb6e 100644--- a/app/models/version.rb+++ b/app/models/version.rb@@ -46,7 +46,6 @@ class Version < ApplicationRecordvalidates_format_of :effective_date, with: /\A\d{4}-\d{2}-\d{2}\z/, message: :not_a_date, allow_nil: truevalidates_format_of :start_date, with: /\A\d{4}-\d{2}-\d{2}\z/, message: :not_a_date, allow_nil: truevalidates_inclusion_of :status, in: VERSION_STATUSES- validates_inclusion_of :sharing, in: VERSION_SHARINGSvalidate :validate_start_date_before_effective_datescope_classes ::Versions::Scopes::OrderBySemverNamediff --git a/config/application.rb b/config/application.rbindex 8e41ad373bb..9f5941db0e3 100644--- a/config/application.rb+++ b/config/application.rb@@ -126,6 +126,14 @@ module OpenProject# Fall back to default localeconfig.i18n.fallbacks = true+ # Activate being able to specify the format in which full_message works.+ # Doing this, it is e.g. possible to avoid having the format of '%{attribute} %{message}' which+ # will always prepend the attribute name to the error message.+ # The formats can then be specified using the `format:` key within the [local].yml file in every+ # layer of activerecord.errors down to the individual leve of the message, e.g.+ # activerecord.errors.models.project.attributes.types.format+ config.active_model.i18n_customize_full_message = true+# Enable cascade key lookup for i18nI18n.backend.class.send(:include, I18n::Backend::Cascade)diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 78b7bb14bde..1bf75736a6e 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -611,6 +611,7 @@ en:not_an_integer: "(%{name}) is not an integer."smaller_than_or_equal_to: "(%{name}) must be smaller than or equal to %{count}."greater_than_or_equal_to: "(%{name}) must be greater than or equal to %{count}."+ format: "%{message}"doorkeeper/application:attributes:redirect_uri:@@ -645,6 +646,15 @@ en:error_not_found: "not found"public:error_unauthorized: "- The user has no permission to create public views."+ group_by:+ invalid: "Can't group by: %{value}"+ format: "%{message}"+ column_names:+ invalid: "Invalid query column: %{value}"+ format: "%{message}"+ sort_criteria:+ invalid: "Can't sort by column: %{value}"+ format: "%{message}"group_by_hierarchies_exclusive: "is mutually exclusive with group by '%{group_by}'. You cannot activate both."filters:custom_fields:@@ -667,8 +677,9 @@ en:must_not_be_ssh: "must not be an SSH url."no_directory: "is not a directory."role:- permissions:- dependency_missing: "need to also include '%{dependency}' as '%{permission}' is selected."+ attributes:+ permissions:+ dependency_missing: "need to also include '%{dependency}' as '%{permission}' is selected."time_entry:attributes:hours:@@ -1113,9 +1124,6 @@ en:error_failed_to_delete_entry: 'Failed to delete this entry.'error_in_dependent: "Error attempting to alter dependent object: %{dependent_class} #%{related_id} - %{related_subject}: %{error}"error_invalid_selected_value: "Invalid selected value."- error_invalid_group_by: "Can't group by: %{value}"- error_invalid_query_column: "Invalid query column: %{value}"- error_invalid_sort_criterion: "Can't sort by column: %{value}"error_journal_attribute_not_present: "Journal does not contain attribute %{attribute}."error_pdf_export_too_many_columns: "Too many columns selected for the PDF export. Please reduce the number of columns."error_pdf_failed_to_export: "The PDF export could not be saved: %{error}"diff --git a/lib/api/errors/error_base.rb b/lib/api/errors/error_base.rbindex a0b43658eca..2b4697cd17c 100644--- a/lib/api/errors/error_base.rb+++ b/lib/api/errors/error_base.rb@@ -87,11 +87,12 @@ module APIerrors.keys.each do |attribute|api_attribute_name = ::API::Utilities::PropertyNameConverter.from_ar_name(attribute)- errors.symbols_and_messages_for(attribute).each do |symbol, full_message, _|++ errors.symbols_and_messages_for(attribute).each do |symbol, message|api_errors << if symbol == :error_readonly- ::API::Errors::UnwritableProperty.new(api_attribute_name, full_message)+ ::API::Errors::UnwritableProperty.new(api_attribute_name, message)else- ::API::Errors::Validation.new(api_attribute_name, full_message)+ ::API::Errors::Validation.new(api_attribute_name, message)endendenddiff --git a/lib/api/utilities/endpoints/modify.rb b/lib/api/utilities/endpoints/modify.rbindex 8c353859eb9..1ee81901f08 100644--- a/lib/api/utilities/endpoints/modify.rb+++ b/lib/api/utilities/endpoints/modify.rb@@ -59,10 +59,8 @@ module APIerrors = ActiveModel::Errors.new call.resultcall.dependent_results.each do |dr|- dr.errors.keys.each do |field|- dr.errors.symbols_and_messages_for(field).each do |symbol, full_message, _|- errors.add :base, symbol, message: dependent_error_message(dr.result, full_message)- end+ dr.errors.full_messages.each do |full_message|+ errors.add :base, :dependent_invalid, message: dependent_error_message(dr.result, full_message)endenddiff --git a/lib/api/v3/custom_actions/custom_actions_api.rb b/lib/api/v3/custom_actions/custom_actions_api.rbindex 0325a1babce..457f6c676be 100644--- a/lib/api/v3/custom_actions/custom_actions_api.rb+++ b/lib/api/v3/custom_actions/custom_actions_api.rb@@ -63,7 +63,7 @@ module APIendafter_validation do- contract = ::CustomActions::ExecuteContract.new(parsed_params)+ contract = ::CustomActions::ExecuteContract.new(parsed_params, current_user)unless contract.valid?fail ::API::Errors::ErrorBase.create_and_merge_errors(contract.errors)diff --git a/lib/open_project/patches/active_model_errors.rb b/lib/open_project/patches/active_model_errors.rbindex ada43241275..842a3585e55 100644--- a/lib/open_project/patches/active_model_errors.rb+++ b/lib/open_project/patches/active_model_errors.rb@@ -28,81 +28,19 @@# See docs/COPYRIGHT.rdoc for more details.#+++# This patch should no longer be necessary.+# But we have references to symbolds_and_messages_for as well as for symbols_for all over+# the code base.module OpenProject::ActiveModelErrorsPatch- ##- # ActiveRecord errors do provide no means to access the symbols initially used to create an- # error. E.g. errors.add :foo, :bar instantly translates :bar, making it hard to write code- # dependent on specific errors (which we use in the APIv3).- # We therefore add a second information store containing pairs of [symbol, translated_message].- def add(attribute, message = :invalid, options = {})- error_symbol = options.fetch(:error_symbol) { message }- super(attribute, message, options)-- if store_new_symbols?- if error_symbol.is_a?(Symbol)- symbol = error_symbol- partial_message = normalize_message(attribute, message, options)- full_message = full_message(attribute, partial_message)- else- symbol = :unknown- full_message = message- end-- writable_symbols_and_messages_for(attribute) << [symbol, full_message, partial_message]- end- end-def symbols_and_messages_for(attribute)- writable_symbols_and_messages_for(attribute).dup- end-- def symbols_for(attribute)- symbols_and_messages_for(attribute).map(&:first)- end-- def full_message(attribute, message)- return message if attribute == :base-- # if a model acts_as_customizable it will inject attributes like 'custom_field_1' into itself- # using attr_name_override we resolve names of such attributes.- # The rest of the method should reflect the original method implementation of ActiveModel- attr_name_override = nil- match = /\Acustom_field_(?<id>\d+)\z/.match(attribute)- if match- attr_name_override = CustomField.find_by(id: match[:id]).name- end+ symbols = details[attribute].map { |e| e[:error] }+ messages = full_messages_for(attribute)- attr_name = attribute.to_s.tr('.', '_').humanize- attr_name = @base.class.human_attribute_name(attribute, default: attr_name)- I18n.t(:"errors.format", default: '%{attribute} %{message}',- attribute: attr_name_override || attr_name,- message: message)+ symbols.zip(messages)end- # Need to do the house keeping along with AR::Errors- # so that the symbols are removed when a new validation round starts- def clear- super-- @error_symbols = Hash.new- end-- private-- def error_symbols- @error_symbols ||= Hash.new- end-- def writable_symbols_and_messages_for(attribute)- error_symbols[attribute.to_sym] ||= []- end-- # Kind of a hack: We need the possibility to temporarily disable symbol storing in the subclass- # Reform::Contract::Errors, because otherwise we end up with duplicate entries- # I feel dirty for doing that, but on the other hand I see no other way out... Please, stop me!- def store_new_symbols?- @store_new_symbols = true if @store_new_symbols.nil?- @store_new_symbols+ def symbols_for(attribute)+ details[attribute].map { |r| r[:error] }endenddiff --git a/lib/open_project/patches/reform.rb b/lib/open_project/patches/reform.rbdeleted file mode 100644index 8afd45dc12d..00000000000--- a/lib/open_project/patches/reform.rb+++ /dev/null@@ -1,79 +0,0 @@-#-- encoding: UTF-8--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-2020 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-2017 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 docs/COPYRIGHT.rdoc for more details.-#++--module OpenProject- module Patches- module Reform- def merge!(errors, prefix = [])- @store_new_symbols = false- super(errors, prefix)- @store_new_symbols = true-- errors.keys.each do |attribute|- errors.symbols_and_messages_for(attribute).each do |symbol, full_message, partial_message|- symbols_and_messages = writable_symbols_and_messages_for(attribute)- next if symbols_and_messages && symbols_and_messages.any? do |sam|- sam[0] === symbol &&- sam[1] === full_message &&- sam[2] === partial_message- end-- symbols_and_messages << [symbol, full_message, partial_message]- end- end- end- end- end-end--require "reform/form/active_model/validations"--Reform::Form.class_eval do- include Reform::Form::ActiveModel::Validations-end--Reform::Contract.class_eval do- include Reform::Form::ActiveModel::Validations-end--Reform::Form::ActiveModel::Validations::Validator.class_eval do- ##- # use activerecord as the base scope instead of 'activemodel' to be compatible- # to the messages we have already stored- def self.i18n_scope- :activerecord- end-end--require 'reform/contract'--class Reform::Form::ActiveModel::Errors- prepend OpenProject::Patches::Reform-enddiff --git a/lib/plugins/acts_as_customizable/init.rb b/lib/plugins/acts_as_customizable/init.rbindex 1d4fb6f71df..d0f701149c9 100644--- a/lib/plugins/acts_as_customizable/init.rb+++ b/lib/plugins/acts_as_customizable/init.rb@@ -28,4 +28,5 @@#-- encoding: UTF-8require File.dirname(__FILE__) + '/lib/acts_as_customizable'+require File.dirname(__FILE__) + '/lib/human_attribute_name'ActiveRecord::Base.send(:include, Redmine::Acts::Customizable)diff --git a/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rbindex 370ec990001..98ad1099273 100644--- a/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb+++ b/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb@@ -61,6 +61,7 @@ module Redminemodule InstanceMethodsdef self.included(base)base.extend ClassMethods+ base.extend HumanAttributeNameenddef available_custom_fields@@ -238,11 +239,11 @@ module Redminecustom_value.errors- .symbols_and_messages_for(attribute)- .each do |symbol, _, partial_message|+ .details[attribute]+ .each do |hash|# Use the generated message by the custom field# as it may contain specific parameters (e.g., :too_long requires :count)- errors.add(name, partial_message, error_symbol: symbol)+ errors.add(name, hash[:error], **hash.except(:error))endendenddiff --git a/lib/plugins/acts_as_customizable/lib/human_attribute_name.rb b/lib/plugins/acts_as_customizable/lib/human_attribute_name.rbnew file mode 100644index 00000000000..71bb9365083--- /dev/null+++ b/lib/plugins/acts_as_customizable/lib/human_attribute_name.rb@@ -0,0 +1,49 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 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-2017 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 docs/COPYRIGHT.rdoc for more details.+#++++module Redmine+ module Acts+ module Customizable+ module HumanAttributeName+ # If a model acts_as_customizable it will inject attributes like 'custom_field_1' into itself.+ # Using this method, they can now be i18ned same as every other attribute. This is for example+ # for error messages following the format of '%{attribute} %{message}' where `attribute` is resolved+ # by calling IncludingClass.human_attribute_name+ def human_attribute_name(attribute, options = {})+ match = /\Acustom_field_(?<id>\d+)\z/.match(attribute)++ if match+ CustomField.find_by(id: match[:id]).name+ else+ super+ end+ end+ end+ end+ end+enddiff --git a/modules/backlogs/spec/contracts/work_packages/update_contract_spec.rb b/modules/backlogs/spec/contracts/work_packages/update_contract_spec.rbindex 7287f963413..4f1d91150f0 100644--- a/modules/backlogs/spec/contracts/work_packages/update_contract_spec.rb+++ b/modules/backlogs/spec/contracts/work_packages/update_contract_spec.rb@@ -31,24 +31,24 @@ require 'spec_helper'describe WorkPackages::UpdateContract dolet(:work_package) doFactoryBot.create(:work_package,- done_ratio: 50,- estimated_hours: 6.0,- project: project)+ done_ratio: 50,+ estimated_hours: 6.0,+ project: project)endlet(:member) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) }- let (:project) { FactoryBot.create(:project) }+ let(:project) { FactoryBot.create(:project) }let(:current_user) { member }- let(:permissions) {- [- :view_work_packages,- :view_work_package_watchers,- :edit_work_packages,- :add_work_package_watchers,- :delete_work_package_watchers,- :manage_work_package_relations,- :add_work_package_notes+ let(:permissions) do+ %i[+ view_work_packages+ view_work_package_watchers+ edit_work_packages+ add_work_package_watchers+ delete_work_package_watchers+ manage_work_package_relations+ add_work_package_notes]- }+ endlet(:role) { FactoryBot.create :role, permissions: permissions }let(:changed_values) { [] }@@ -105,7 +105,7 @@ describe WorkPackages::UpdateContract dolet(:changed_values) { ['remaining_hours'] }it('is invalid') do- expect(contract.errors.symbols_for('remaining_hours')).to match_array([:error_readonly])+ expect(contract.errors.symbols_for(:remaining_hours)).to match_array([:error_readonly])endendenddiff --git a/modules/bim/app/contracts/bim/bcf/concerns/manage_bcf_guarded.rb b/modules/bim/app/contracts/bim/bcf/concerns/manage_bcf_guarded.rbindex 0d6fa40d41d..49bb8506c6c 100644--- a/modules/bim/app/contracts/bim/bcf/concerns/manage_bcf_guarded.rb+++ b/modules/bim/app/contracts/bim/bcf/concerns/manage_bcf_guarded.rb@@ -34,11 +34,7 @@ module Bim::Bcfextend ActiveSupport::Concernincluded do- def validate- validate_user_allowed_to_manage-- super- end+ validate :validate_user_allowed_to_manageprivatediff --git a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb b/modules/bim/app/contracts/bim/ifc_models/base_contract.rbindex 22f24772840..94cab76ac48 100644--- a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb+++ b/modules/bim/app/contracts/bim/ifc_models/base_contract.rb@@ -41,15 +41,11 @@ module Bim::Bim::IfcModels::IfcModelend- def validate- user_allowed_to_manage- user_is_uploader- ifc_attachment_existent- ifc_attachment_is_ifc- uploader_is_ifc_attachment_author-- super- end+ validate :user_allowed_to_manage+ validate :user_is_uploader+ validate :ifc_attachment_existent+ validate :ifc_attachment_is_ifc+ validate :uploader_is_ifc_attachment_authordef user_allowed_to_manageif model.project && !user.allowed_to?(:manage_ifc_models, model.project)diff --git a/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_mapper.rb b/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_mapper.rbindex a18cbbbbfa6..ed5fa4f4377 100644--- a/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_mapper.rb+++ b/modules/bim/app/representers/bim/bcf/api/v2_1/errors/error_mapper.rb@@ -46,9 +46,9 @@ module Bim::Bcf::API::V2_1::Errorsdef self.map(original_errors)mapped_errors = ActiveModel::Errors.new(new)- original_errors.send(:error_symbols).each do |key, errors|- errors.map(&:first).each do |error|- mapped_errors.add(error_key_mapper(key), error)+ original_errors.details.each do |key, errors|+ errors.each do |error|+ mapped_errors.add(error_key_mapper(key), error[:error], *error.except(:error))endenddiff --git a/modules/bim/spec/contracts/bcf/issues/create_contract_spec.rb b/modules/bim/spec/contracts/bcf/issues/create_contract_spec.rbindex d6bb44d5d3f..ad2471f1f84 100644--- a/modules/bim/spec/contracts/bcf/issues/create_contract_spec.rb+++ b/modules/bim/spec/contracts/bcf/issues/create_contract_spec.rb@@ -33,8 +33,8 @@ describe Bim::Bcf::Issues::CreateContract doit_behaves_like 'issues contract' dolet(:issue) doBim::Bcf::Issue.new(uuid: issue_uuid,- work_package: issue_work_package,- index: issue_index)+ work_package: issue_work_package,+ index: issue_index)endlet(:permissions) { [:manage_bcf] }diff --git a/modules/boards/spec/requests/api/v3/grids/grids_resource_spec.rb b/modules/boards/spec/requests/api/v3/grids/grids_resource_spec.rbindex 43ca65285d7..02f40854e67 100644--- a/modules/boards/spec/requests/api/v3/grids/grids_resource_spec.rb+++ b/modules/boards/spec/requests/api/v3/grids/grids_resource_spec.rb@@ -258,17 +258,9 @@ describe 'API v3 Grids resource for Board Grids', type: :request, content_type:it 'responds with 422 and mentions the error' doexpect(subject.status).to eq 422- expect(subject.body)- .to be_json_eql('Error'.to_json)- .at_path('_type')-- expect(subject.body)- .to be_json_eql("Widgets is outside of the grid.".to_json)- .at_path('_embedded/errors/0/message')-- expect(subject.body)- .to be_json_eql("Number of rows must be greater than 0.".to_json)- .at_path('_embedded/errors/1/message')+ expect(JSON.parse(subject.body)['_embedded']['errors'].map { |e| e['message'] })+ .to match_array ["Widgets is outside of the grid.",+ "Number of rows must be greater than 0."]endit 'does not persist the changes to widgets' do@@ -398,17 +390,10 @@ describe 'API v3 Grids resource for Board Grids', type: :request, content_type:.to be_json_eql('Error'.to_json).at_path('_type')- expect(subject.body)- .to be_json_eql("Widgets is outside of the grid.".to_json)- .at_path('_embedded/errors/0/message')-- expect(subject.body)- .to be_json_eql("Number of rows must be greater than 0.".to_json)- .at_path('_embedded/errors/1/message')-- expect(subject.body)- .to be_json_eql("Number of columns must be greater than 0.".to_json)- .at_path('_embedded/errors/2/message')+ expect(JSON.parse(subject.body)['_embedded']['errors'].map { |e| e['message'] })+ .to match_array ["Widgets is outside of the grid.",+ "Number of rows must be greater than 0.",+ "Number of columns must be greater than 0."]endenddiff --git a/modules/costs/app/contracts/time_entries/base_contract.rb b/modules/costs/app/contracts/time_entries/base_contract.rbindex 30c4a3f5c38..8d1b0b5650b 100644--- a/modules/costs/app/contracts/time_entries/base_contract.rb+++ b/modules/costs/app/contracts/time_entries/base_contract.rb@@ -43,13 +43,9 @@ module TimeEntriesTimeEntryend- def validate- validate_hours_are_in_range- validate_project_is_set- validate_work_package-- super- end+ validate :validate_hours_are_in_range+ validate :validate_project_is_set+ validate :validate_work_packageattribute :project_idattribute :work_package_iddiff --git a/modules/costs/app/contracts/time_entries/create_contract.rb b/modules/costs/app/contracts/time_entries/create_contract.rbindex c0823174cb6..ebb048df911 100644--- a/modules/costs/app/contracts/time_entries/create_contract.rb+++ b/modules/costs/app/contracts/time_entries/create_contract.rb@@ -30,12 +30,8 @@module TimeEntriesclass CreateContract < BaseContract- def validate- user_allowed_to_add- validate_user_current_user-- super- end+ validate :user_allowed_to_add+ validate :validate_user_current_userprivatediff --git a/modules/costs/app/contracts/time_entries/update_contract.rb b/modules/costs/app/contracts/time_entries/update_contract.rbindex 4fa996f8fe5..5af5199d342 100644--- a/modules/costs/app/contracts/time_entries/update_contract.rb+++ b/modules/costs/app/contracts/time_entries/update_contract.rb@@ -32,12 +32,12 @@ module TimeEntriesclass UpdateContract < BaseContractinclude UnchangedProject- def validate+ validate :validate_user_allowed_to_update++ def validate_user_allowed_to_updateunless user_allowed_to_update?errors.add :base, :error_unauthorizedend-- superend##diff --git a/modules/grids/app/contracts/grids/base_contract.rb b/modules/grids/app/contracts/grids/base_contract.rbindex 1cb4642538f..008cb5fd501 100644--- a/modules/grids/app/contracts/grids/base_contract.rb+++ b/modules/grids/app/contracts/grids/base_contract.rb@@ -44,24 +44,19 @@ module Gridsattribute_alias :type, :scope- def validate- validate_allowed- validate_registered_widgets- validate_widget_collisions- validate_widgets_within- validate_widgets_start_before_end-- run_registration_validations-- super- end-attribute :widgetsattribute :nameattribute :options+ validate :validate_allowed+ validate :validate_registered_widgets+ validate :validate_widget_collisions+ validate :validate_widgets_within+ validate :validate_widgets_start_before_end+ validate :run_registration_validations+def self.modelGridenddiff --git a/modules/grids/app/contracts/grids/delete_contract.rb b/modules/grids/app/contracts/grids/delete_contract.rbindex db3ac87f17c..c4ab9ed302e 100644--- a/modules/grids/app/contracts/grids/delete_contract.rb+++ b/modules/grids/app/contracts/grids/delete_contract.rb@@ -32,11 +32,7 @@ require 'grids/base_contract'module Gridsclass DeleteContract < BaseContract- def validate- validate_delete_allowed-- super- end+ validate :validate_delete_allowed### Check whether this grid can be deleted.diff --git a/modules/my_page/spec/requests/api/v3/grids/grids_resource_spec.rb b/modules/my_page/spec/requests/api/v3/grids/grids_resource_spec.rbindex 95cb1a28ea8..fe2ba9ecfba 100644--- a/modules/my_page/spec/requests/api/v3/grids/grids_resource_spec.rb+++ b/modules/my_page/spec/requests/api/v3/grids/grids_resource_spec.rb@@ -247,17 +247,9 @@ describe 'API v3 Grids resource', type: :request, content_type: :json doit 'responds with 422 and mentions the error' doexpect(subject.status).to eq 422- expect(subject.body)- .to be_json_eql('Error'.to_json)- .at_path('_type')-- expect(subject.body)- .to be_json_eql("Widgets is outside of the grid.".to_json)- .at_path('_embedded/errors/0/message')-- expect(subject.body)- .to be_json_eql("Number of rows must be greater than 0.".to_json)- .at_path('_embedded/errors/1/message')+ expect(JSON.parse(subject.body)['_embedded']['errors'].map { |e| e['message'] })+ .to match_array ["Widgets is outside of the grid.",+ "Number of rows must be greater than 0."]endit 'does not persist the changes to widgets' do@@ -383,17 +375,10 @@ describe 'API v3 Grids resource', type: :request, content_type: :json do.to be_json_eql('Error'.to_json).at_path('_type')- expect(subject.body)- .to be_json_eql("Widgets is outside of the grid.".to_json)- .at_path('_embedded/errors/0/message')-- expect(subject.body)- .to be_json_eql("Number of rows must be greater than 0.".to_json)- .at_path('_embedded/errors/1/message')-- expect(subject.body)- .to be_json_eql("Number of columns must be greater than 0.".to_json)- .at_path('_embedded/errors/2/message')+ expect(JSON.parse(subject.body)['_embedded']['errors'].map { |e| e['message'] })+ .to match_array ["Widgets is outside of the grid.",+ "Number of rows must be greater than 0.",+ "Number of columns must be greater than 0."]endendenddiff --git a/spec/models/custom_actions/actions/assigned_to_spec.rb b/spec/models/custom_actions/actions/assigned_to_spec.rbindex 16378ac98af..bba40a220c5 100644--- a/spec/models/custom_actions/actions/assigned_to_spec.rb+++ b/spec/models/custom_actions/actions/assigned_to_spec.rb@@ -39,13 +39,13 @@ describe CustomActions::Actions::AssignedTo, type: :model doFactoryBot.build_stubbed(:user)]allow(User).to receive_message_chain(:active_or_registered, :select, :order_by_name)- .and_return(users)+ .and_return(users)elseusers = [FactoryBot.build_stubbed(:user),FactoryBot.build_stubbed(:group)]allow(Principal).to receive_message_chain(:active_or_registered, :select, :order_by_name)- .and_return(users)+ .and_return(users)end[{ value: nil, label: '-' },@@ -105,7 +105,7 @@ describe CustomActions::Actions::AssignedTo, type: :model doendit 'validates the me value when executing' do- errors = ActiveModel::Errors.new(work_package)+ errors = ActiveModel::Errors.new(CustomAction.new)subject.validate errorsexpect(errors.symbols_for(:actions)).to be_emptyend@@ -118,7 +118,7 @@ describe CustomActions::Actions::AssignedTo, type: :model doendit 'validates the me value when executing' do- errors = ActiveModel::Errors.new(work_package)+ errors = ActiveModel::Errors.new(CustomAction.new)subject.validate errorsexpect(errors.symbols_for(:actions)).to include :not_logged_inend