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
[#62217] allow custom fields that are not enabled in project
Eric Schubertb9c3a7de9e94
diff --git a/app/models/types/patterns/token_property_mapper.rb b/app/models/types/patterns/token_property_mapper.rbindex a739a0e3fec..f9e8aa18118 100644--- a/app/models/types/patterns/token_property_mapper.rb+++ b/app/models/types/patterns/token_property_mapper.rb@@ -33,6 +33,7 @@ module Typesclass TokenPropertyMapperDEFAULT_FUNCTION = ->(key, context) doreturn nil if context.nil?+ return nil unless context.respond_to?(key.to_sym)context.public_send(key.to_sym)end.currydiff --git a/spec/models/types/patterns/token_property_mapper_spec.rb b/spec/models/types/patterns/token_property_mapper_spec.rbindex 8a4c9b8b318..3340c3d71d6 100644--- a/spec/models/types/patterns/token_property_mapper_spec.rb+++ b/spec/models/types/patterns/token_property_mapper_spec.rb@@ -66,6 +66,12 @@ RSpec.describe Types::Patterns::TokenPropertyMapper doendend+ shared_let(:not_activated_custom_field) do+ create(:boolean_wp_custom_field).tap do |custom_field|+ work_package.type.custom_fields << custom_field+ end+ end+described_class::TOKEN_PROPERTY_MAP.each_pair do |key, details|it "the token named #{key} resolves successfully" doexpect { details[:fn].call(work_package) }.not_to raise_error@@ -78,6 +84,12 @@ RSpec.describe Types::Patterns::TokenPropertyMapper doexpect(function.call(work_package)).to eq(%w[A B])end+ it "must return nil if custom field is not activated in project" do+ function = described_class.new.fetch :"custom_field_#{not_activated_custom_field.id}"+ expect { function.call(work_package) }.not_to raise_error+ expect(function.call(work_package)).to be_nil+ end+it "returns all possible tokens" docf = string_custom_fieldtokens = described_class.new.tokens_for_type(work_package.type)