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

Specify `API::V3::Notifications::PropertyFactory` to look up descendants

Kabiru Mwenjafe32e9562618
diff --git a/lib/api/v3/notifications/property_factory.rb b/lib/api/v3/notifications/property_factory.rb
index f5786d253ef..5b450656df9 100644
--- a/lib/api/v3/notifications/property_factory.rb
+++ b/lib/api/v3/notifications/property_factory.rb
@@ -88,12 +88,7 @@ module API::V3::Notifications
end
@concrete_factory_for ||= Hash.new do |h, property_key|
- h[property_key] = if property_key == "shared"
- # for some reasons
- # API::V3::Notifications::PropertyFactory.const_defined?(property_key.camelcase)
- # returns true for shared only to fail on the constantize later on.
- API::V3::Notifications::PropertyFactory::Default
- elsif API::V3::Notifications::PropertyFactory.const_defined?(property_key.camelcase)
+ h[property_key] = if API::V3::Notifications::PropertyFactory.const_defined?(property_key.camelcase, false)
"API::V3::Notifications::PropertyFactory::#{property_key.camelcase}".constantize
else
API::V3::Notifications::PropertyFactory::Default
diff --git a/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb b/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb
index f146213883d..c0fb12c42cb 100644
--- a/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/notifications/notification_representer_rendering_spec.rb
@@ -103,7 +103,7 @@ RSpec.describe API::V3::Notifications::NotificationRepresenter, "rendering" do
end
describe "reason" do
- (Notification::REASONS.keys - %i[date_alert_start_date date_alert_due_date reminder]).each do |notification_reason|
+ (Notification::REASONS.keys - %i[date_alert_start_date date_alert_due_date]).each do |notification_reason|
context "for a #{notification_reason} reason" do
let(:reason) { notification_reason }
diff --git a/spec/lib/api/v3/notifications/property_factory_spec.rb b/spec/lib/api/v3/notifications/property_factory_spec.rb
index 653a567d106..3ad53e613c5 100644
--- a/spec/lib/api/v3/notifications/property_factory_spec.rb
+++ b/spec/lib/api/v3/notifications/property_factory_spec.rb
@@ -106,7 +106,7 @@ RSpec.describe API::V3::Notifications::PropertyFactory do
end
end
- (Notification::REASONS.keys - %i[date_alert_start_date date_alert_due_date reminder]).each do |possible_reason|
+ (Notification::REASONS.keys - %i[date_alert_start_date date_alert_due_date]).each do |possible_reason|
context "for a #{possible_reason} notification" do
let(:reason) { possible_reason }