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
Enable Boolean Custom Fields on Subject Patterns (#18930)
Marcello Rochaf2319838b258
diff --git a/app/models/types/patterns/token_property_mapper.rb b/app/models/types/patterns/token_property_mapper.rbindex e2c507b7d9c..70b4c17f273 100644--- a/app/models/types/patterns/token_property_mapper.rb+++ b/app/models/types/patterns/token_property_mapper.rb@@ -114,12 +114,11 @@ module Typesenddef all_work_package_cfs- WorkPackageCustomField.where.not(field_format: %w[text bool link empty]).order(:name)+ WorkPackageCustomField.where.not(field_format: %w[text link empty]).order(:name)enddef project_cfs- ProjectCustomField.where.not(field_format: %w[text bool link empty])- .where(admin_only: false, multi_value: false).order(:name)+ ProjectCustomField.where.not(field_format: %w[text link empty]).where(admin_only: false, multi_value: false).order(:name)endendenddiff --git a/spec/models/types/patterns/token_property_mapper_spec.rb b/spec/models/types/patterns/token_property_mapper_spec.rbindex f4ac4415664..705e4a20425 100644--- a/spec/models/types/patterns/token_property_mapper_spec.rb+++ b/spec/models/types/patterns/token_property_mapper_spec.rb@@ -57,6 +57,16 @@ RSpec.describe Types::Patterns::TokenPropertyMapper doendend+ shared_let(:boolean_custom_field) do+ create(:boolean_wp_custom_field).tap do |custom_field|+ project.work_package_custom_fields << custom_field+ work_package.type.custom_fields << custom_field++ work_package.send(:"custom_field_#{custom_field.id}=", true)+ work_package.save+ end+ end+shared_let(:mult_list_custom_field) docreate(:multi_list_wp_custom_field).tap doproject.work_package_custom_fields << it@@ -96,6 +106,14 @@ RSpec.describe Types::Patterns::TokenPropertyMapper doexpect(token.call(work_package)).to eq(%w[A B])end+ it "supports boolean custom fields" do+ token = described_class.new.tokens_for_type(work_package.type).detect do |t|+ t.key == :"custom_field_#{boolean_custom_field.id}"+ end++ expect(token.call(work_package)).to be(true)+ end+it "must return nil if custom field is not activated in project" dotoken = described_class.new.tokens_for_type(work_package.type).detect do |t|t.key == :"custom_field_#{not_activated_custom_field.id}"