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

[#59765] added scope for custom fields

Eric Schubertfc165bffca05
diff --git a/app/models/custom_actions/actions/custom_field.rb b/app/models/custom_actions/actions/custom_field.rb
index 2406a08cb22..374b3406218 100644
--- a/app/models/custom_actions/actions/custom_field.rb
+++ b/app/models/custom_actions/actions/custom_field.rb
@@ -49,8 +49,7 @@ class CustomActions::Actions::CustomField < CustomActions::Actions::Base
def self.all
WorkPackageCustomField
- .where.not(field_format: %w(hierarchy))
- .order(:name)
+ .usable_as_custom_action
.map do |cf|
create_subclass(cf)
end
diff --git a/app/models/work_package_custom_field.rb b/app/models/work_package_custom_field.rb
index 1b1a68fe5bc..0c1776abe2a 100644
--- a/app/models/work_package_custom_field.rb
+++ b/app/models/work_package_custom_field.rb
@@ -49,6 +49,11 @@ class WorkPackageCustomField < CustomField
end
}
+ scope :usable_as_custom_action, -> {
+ where.not(field_format: %w[hierarchy])
+ order(:name)
+ }
+
def self.summable
where(field_format: %w[int float])
end
diff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rb
index e8cea930e9a..05c68c59438 100644
--- a/spec/models/custom_actions/actions/custom_field_spec.rb
+++ b/spec/models/custom_actions/actions/custom_field_spec.rb
@@ -98,7 +98,7 @@ RSpec.describe CustomActions::Actions::CustomField do
describe ".all" do
before do
allow(WorkPackageCustomField)
- .to receive(:order)
+ .to receive(:usable_as_custom_action)
.and_return(custom_fields)
end