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
Include detailsSchemas in the NotificationCollectionRepresenter
Dombi Attila1d53e91a69e6
diff --git a/lib/api/v3/notifications/notification_collection_representer.rb b/lib/api/v3/notifications/notification_collection_representer.rbindex 728506f34d7..2df15c5d2f3 100644--- a/lib/api/v3/notifications/notification_collection_representer.rb+++ b/lib/api/v3/notifications/notification_collection_representer.rb@@ -30,6 +30,11 @@ module APImodule V3module Notificationsclass NotificationCollectionRepresenter < ::API::Decorators::OffsetPaginatedCollection+ property :detailsSchemas,+ getter: ->(*) { ::API::V3::Values::Schemas::ValueSchemaFactory.all },+ exec_context: :decorator,+ embedded: true+def initialize(models, self_link:, current_user:, query: {}, page: nil, per_page: nil, groups: nil)superdiff --git a/lib/api/v3/values/schemas/value_schema_factory.rb b/lib/api/v3/values/schemas/value_schema_factory.rbindex 3956acb91ed..ca16c919e2f 100644--- a/lib/api/v3/values/schemas/value_schema_factory.rb+++ b/lib/api/v3/values/schemas/value_schema_factory.rb@@ -29,6 +29,7 @@module API::V3::Values::Schemasmodule ValueSchemaFactoryextend ::API::V3::Utilities::PathHelper+ SUPPORTED = %w(start_date due_date).freezemodule_function@@ -41,10 +42,14 @@ module API::V3::Values::Schemasself_link: api_v3_paths.value_schema(property))end+ def all+ SUPPORTED.map { |property| self.for(property) }+ end+def supported?(property)# This is but a stub. Currently, only 'start_date' and 'due_date'# need to be supported so this simple approach works.- %w(start_date due_date).include?(property)+ SUPPORTED.include?(property)enddef model_for(property)diff --git a/spec/lib/api/v3/notifications/notification_collection_representer_spec.rb b/spec/lib/api/v3/notifications/notification_collection_representer_spec.rbindex c00bd0cef78..81fe6ca29f6 100644--- a/spec/lib/api/v3/notifications/notification_collection_representer_spec.rb+++ b/spec/lib/api/v3/notifications/notification_collection_representer_spec.rb@@ -79,6 +79,11 @@ describe ::API::V3::Notifications::NotificationCollectionRepresenter doit_behaves_like 'offset-paginated APIv3 collection', 3, 'notifications', 'Notification'+ it 'renders the available detailsSchemas' do+ details_schemas = ::API::V3::Values::Schemas::ValueSchemaFactory.all+ expect(subject).to be_json_eql(details_schemas.to_json).at_path('_embedded/detailsSchemas')+ end+context 'when passing groups' dolet(:groups) do[