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
[#43677] Add milestone type date alert to the notification representer api
Dombi Attila3b53eeb45838
diff --git a/docs/api/apiv3/components/examples/values_property_date.yml b/docs/api/apiv3/components/examples/values_property_date.ymlnew file mode 100644index 00000000000..534a3c6e3e8--- /dev/null+++ b/docs/api/apiv3/components/examples/values_property_date.yml@@ -0,0 +1,11 @@+# Example: Values::Property+---+value:+ _type: 'Values::Property'+ property: 'date'+ value: '2021-01-01'+ _links:+ self:+ href: 'api/v3/notifications/123/details/0'+ schema:+ href: 'api/v3/values/schemas/date'diff --git a/docs/api/apiv3/components/examples/values_property_date_schema.yml b/docs/api/apiv3/components/examples/values_property_date_schema.ymlnew file mode 100644index 00000000000..1da6010ca47--- /dev/null+++ b/docs/api/apiv3/components/examples/values_property_date_schema.yml@@ -0,0 +1,13 @@+# Example: Values::Property schema+---+value:+ _type: 'Schema'+ property:+ name: 'Property'+ type: 'String'+ value:+ name: 'Date'+ type: 'Date'+ _links:+ self:+ href: 'api/v3/values/schemas/date'diff --git a/docs/api/apiv3/components/examples/values_property_due_date.yml b/docs/api/apiv3/components/examples/values_property_due_date.ymlnew file mode 100644index 00000000000..98a63e9f81d--- /dev/null+++ b/docs/api/apiv3/components/examples/values_property_due_date.yml@@ -0,0 +1,11 @@+# Example: Values::Property+---+value:+ _type: 'Values::Property'+ property: 'dueDate'+ value: '2021-01-01'+ _links:+ self:+ href: 'api/v3/notifications/123/details/0'+ schema:+ href: 'api/v3/values/schemas/dueDate'diff --git a/docs/api/apiv3/components/examples/values_property_due_date_schema.yml b/docs/api/apiv3/components/examples/values_property_due_date_schema.ymlnew file mode 100644index 00000000000..b903c9b0413--- /dev/null+++ b/docs/api/apiv3/components/examples/values_property_due_date_schema.yml@@ -0,0 +1,13 @@+# Example: Values::Property schema+---+value:+ _type: 'Schema'+ property:+ name: 'Property'+ type: 'String'+ value:+ name: 'Due date'+ type: 'Date'+ _links:+ self:+ href: 'api/v3/values/schemas/dueDate'diff --git a/docs/api/apiv3/components/examples/values_property_schema.yml b/docs/api/apiv3/components/examples/values_property_start_date_schema.ymlsimilarity index 100%rename from docs/api/apiv3/components/examples/values_property_schema.ymlrename to docs/api/apiv3/components/examples/values_property_start_date_schema.ymldiff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.ymlindex 49a5cb76b25..e933ff3e413 100644--- a/docs/api/apiv3/openapi-spec.yml+++ b/docs/api/apiv3/openapi-spec.yml@@ -462,17 +462,25 @@ components:"$ref": "./components/examples/query.yml"QuerySchemaModel:"$ref": "./components/examples/query_schema.yml"- ValuesPropertySchema:- "$ref": "./components/examples/values_property_schema.yml"+ ValuesPropertyStartDateSchema:+ "$ref": "./components/examples/values_property_start_date_schema.yml"+ ValuesPropertyDueDateSchema:+ "$ref": "./components/examples/values_property_due_date_schema.yml"+ ValuesPropertyDateSchema:+ "$ref": "./components/examples/values_property_date_schema.yml"ValuesPropertyStartDate:"$ref": "./components/examples/values_property_start_date.yml"+ ValuesPropertyDueDate:+ "$ref": "./components/examples/values_property_due_date.yml"+ ValuesPropertyDate:+ "$ref": "./components/examples/values_property_date.yml"Views:"$ref": "./components/examples/views.yml"ViewWorkPackagesTable:"$ref": "./components/examples/view_work_packages_table.yml"ViewTeamPlanner:"$ref": "./components/examples/view_team_planner.yml"-+responses:InvalidRequestBody:"$ref": "./components/responses/invalid_request_body.yml"diff --git a/docs/api/apiv3/paths/notification_details.yml b/docs/api/apiv3/paths/notification_details.ymlindex 9e318db2e9b..73908fccbd8 100644--- a/docs/api/apiv3/paths/notification_details.yml+++ b/docs/api/apiv3/paths/notification_details.yml@@ -31,6 +31,10 @@ get:examples:'Start date notification detail':$ref: '../components/examples/values_property_start_date.yml'+ 'Due date notification detail':+ $ref: '../components/examples/values_property_due_date.yml'+ 'Date notification detail for milestone work package':+ $ref: '../components/examples/values_property_date.yml'description: OK'404':content:diff --git a/docs/api/apiv3/paths/values_schema.yml b/docs/api/apiv3/paths/values_schema.ymlindex 391220546ab..89a0ab84e38 100644--- a/docs/api/apiv3/paths/values_schema.yml+++ b/docs/api/apiv3/paths/values_schema.yml@@ -19,7 +19,11 @@ get:"$ref": "../components/schemas/schema_model.yml"examples:'Values::Property Start date schema':- $ref: '../components/examples/values_property_schema.yml'+ $ref: '../components/examples/values_property_start_date_schema.yml'+ 'Values::Property Due date schema':+ $ref: '../components/examples/values_property_due_date_schema.yml'+ 'Values::Property Date schema for Milestone work package':+ $ref: '../components/examples/values_property_date_schema.yml'description: OKheaders: {}'404':diff --git a/lib/api/v3/notifications/property_factory.rb b/lib/api/v3/notifications/property_factory.rbindex 7a1601afe86..ff2bd09cee8 100644--- a/lib/api/v3/notifications/property_factory.rb+++ b/lib/api/v3/notifications/property_factory.rb@@ -32,7 +32,8 @@ module API::V3::NotificationsPROPERTY_FOR_REASON = {date_alert_start_date: "start_date",- date_alert_due_date: "due_date"+ date_alert_due_date: "due_date",+ date_alert_date: "date"}.freezeDATE_ALERT_REASONS = %w(date_alert_start_date date_alert_due_date).freeze@@ -41,17 +42,22 @@ module API::V3::Notifications# Fetch the collection of details for a notificationdef details_for(notification)- concrete_factory_for(notification.reason)+ concrete_factory_for(notification).for(notification)end# Fetch the collection of schemas for the provided notifications.def schemas_for(notifications)- detail_properties = notifications.map(&:reason).to_set.reduce([]) do |properties, reason|- property = PROPERTY_FOR_REASON[reason.to_sym]- properties << property if property- properties+ detail_properties = notifications.reduce(Set.new) do |properties, notification|+ next properties unless PROPERTY_FOR_REASON.has_key?(notification.reason.to_sym)++ properties << if notification.resource.is_milestone?+ PROPERTY_FOR_REASON[:date_alert_date]+ else+ PROPERTY_FOR_REASON[notification.reason.to_sym]+ endend+::API::V3::Values::Schemas::ValueSchemaFactory.all_for(detail_properties)end@@ -74,16 +80,22 @@ module API::V3::Notificationsendend- def concrete_factory_for(reason)- @concrete_factory_for ||= Hash.new do |h, reason_key|- h[reason_key] = if API::V3::Notifications::PropertyFactory.const_defined?(reason_key.camelcase)- "API::V3::Notifications::PropertyFactory::#{reason_key.camelcase}".constantize- else- API::V3::Notifications::PropertyFactory::Default- end+ def concrete_factory_for(notification)+ property_name = notification.reason++ if notification.reason.in?(DATE_ALERT_REASONS) && notification.resource&.is_milestone?+ property_name = 'date_alert_date'+ end++ @concrete_factory_for ||= Hash.new do |h, property_key|+ h[property_key] = if API::V3::Notifications::PropertyFactory.const_defined?(property_key.camelcase)+ "API::V3::Notifications::PropertyFactory::#{property_key.camelcase}".constantize+ else+ API::V3::Notifications::PropertyFactory::Default+ endend- @concrete_factory_for[reason]+ @concrete_factory_for[property_name]endendenddiff --git a/lib/api/v3/notifications/property_factory/date_alert_date.rb b/lib/api/v3/notifications/property_factory/date_alert_date.rbnew file mode 100644index 00000000000..a3d1a7d3ca2--- /dev/null+++ b/lib/api/v3/notifications/property_factory/date_alert_date.rb@@ -0,0 +1,43 @@+# --copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-2022 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module API::V3::Notifications::PropertyFactory+ module DateAlertDate+ extend ::API::V3::Utilities::PathHelper++ module_function++ def for(notification)+ [+ ::API::V3::Values::PropertyDateRepresenter+ .new(::API::V3::Values::PropertyModel.new(:date, notification.resource.due_date),+ self_link: api_v3_paths.notification_detail(notification.id, 0))+ ]+ end+ end+enddiff --git a/lib/api/v3/values/schemas/value_schema_factory.rb b/lib/api/v3/values/schemas/value_schema_factory.rbindex ac09dea1cac..d5bb32a5bc4 100644--- a/lib/api/v3/values/schemas/value_schema_factory.rb+++ b/lib/api/v3/values/schemas/value_schema_factory.rb@@ -29,7 +29,7 @@module API::V3::Values::Schemasmodule ValueSchemaFactoryextend ::API::V3::Utilities::PathHelper- SUPPORTED = %w(start_date due_date).freeze+ SUPPORTED = %w(start_date due_date date).freezemodule_functiondiff --git a/spec/factories/notification_factory.rb b/spec/factories/notification_factory.rbindex b942d6c7279..4d61ad90cea 100644--- a/spec/factories/notification_factory.rb+++ b/spec/factories/notification_factory.rb@@ -8,6 +8,10 @@ FactoryBot.define dorecipient factory: :userprojectresource { association :work_package, project: }++ trait :for_milestone do+ resource { association :work_package, :is_milestone, project: }+ end# journal and actor are not listed by intend.# They will be set in the after_build callback.# But not listing them allows to identify if they have been provided, even if nil has been provided.diff --git a/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb b/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rbindex bb753d11beb..f84479fc5fb 100644--- a/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb@@ -16,7 +16,7 @@ describe "Notification center sidemenu", js: true doshared_let(:work_package2) { create(:work_package, project: project2, author: other_user) }shared_let(:work_package3) { create(:work_package, project: project3, author: other_user) }shared_let(:work_package4) { create(:work_package, project: project3, author: other_user) }- shared_let(:work_package5) { create(:work_package, project: project3, author: other_user) }+ shared_let(:work_package5) { create(:work_package, :is_milestone, project: project3, author: other_user) }let(:notification) docreate(:notification,diff --git a/spec/features/notifications/notification_center/notification_center_spec.rb b/spec/features/notifications/notification_center/notification_center_spec.rbindex 222f09d4ed6..e4823190e91 100644--- a/spec/features/notifications/notification_center/notification_center_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_spec.rb@@ -182,10 +182,11 @@ describe "Notification center", js: true, with_settings: { journal_aggregation_tproject: project1)endend- let(:overdue_work_package) do+ let(:overdue_milestone_work_package) do# Executing as current user to avoid notification creationUser.execute_as(recipient) docreate(:work_package,+ :is_milestone,due_date: 1.day.ago,project: project1)end@@ -210,7 +211,7 @@ describe "Notification center", js: true, with_settings: { journal_aggregation_tcreate(:notification,reason: :date_alert_due_date,recipient:,- resource: overdue_work_package,+ resource: overdue_milestone_work_package,project: project1,read_ian: false)end@@ -245,7 +246,7 @@ describe "Notification center", js: true, with_settings: { journal_aggregation_tcreate(:notification,reason: :mentioned,recipient:,- resource: overdue_work_package,+ resource: overdue_milestone_work_package,project: project1)# We need to wait for the bell to poll for updatesdiff --git a/spec/lib/api/v3/notifications/notification_collection_representer_spec.rb b/spec/lib/api/v3/notifications/notification_collection_representer_spec.rbindex 961c0a69602..865f499b965 100644--- a/spec/lib/api/v3/notifications/notification_collection_representer_spec.rb+++ b/spec/lib/api/v3/notifications/notification_collection_representer_spec.rb@@ -31,9 +31,9 @@ require 'spec_helper'describe ::API::V3::Notifications::NotificationCollectionRepresenter dolet(:self_base_link) { '/api/v3/notifications' }let(:user) { build_stubbed(:user) }+ let(:notification_list) { build_stubbed_list(:notification, 3) }let(:notifications) do- build_stubbed_list(:notification,- 3).tap do |items|+ notification_list.tap do |items|allow(items).to receive(:limit).with(page_size)@@ -99,15 +99,15 @@ describe ::API::V3::Notifications::NotificationCollectionRepresenter doendend- shared_examples_for 'rendering detailsSchemas' do |date_alert_reasons|+ shared_examples_for 'rendering detailsSchemas' do |reasons: [], expected_schemas: reasons|before do- date_alert_reasons.each_with_index do |reason, idx|+ reasons.each_with_index do |reason, idx|notifications[idx].reason = reasonendendit 'renders the required detailsSchemas' do- properties = date_alert_reasons.map do |reason|+ properties = expected_schemas.map do |reason|::API::V3::Notifications::PropertyFactory::PROPERTY_FOR_REASON[reason.to_sym]enddetails_schemas = ::API::V3::Values::Schemas::ValueSchemaFactory.all_for(properties)@@ -115,16 +115,42 @@ describe ::API::V3::Notifications::NotificationCollectionRepresenter doendend- context 'when a date alert start date notification is present' do- it_behaves_like 'rendering detailsSchemas', ['date_alert_start_date']+ context 'when a start date notification is present' do+ it_behaves_like 'rendering detailsSchemas', reasons: ['date_alert_start_date']end- context 'when a date alert due date notification is present' do- it_behaves_like 'rendering detailsSchemas', ['date_alert_due_date']+ context 'when a due date notification is present' do+ it_behaves_like 'rendering detailsSchemas', reasons: ['date_alert_due_date']+ end++ context 'when a due date and a start date notification is present for a milestone work package' do+ let(:notification_list) { build_stubbed_list(:notification, 3, :for_milestone) }++ it_behaves_like 'rendering detailsSchemas',+ reasons: ['date_alert_due_date', 'date_alert_start_date'],+ expected_schemas: ['date_alert_date']endcontext 'when both date alert notifications are present' do- it_behaves_like 'rendering detailsSchemas', ['date_alert_start_date', 'date_alert_due_date']+ it_behaves_like 'rendering detailsSchemas', reasons: ['date_alert_start_date', 'date_alert_due_date']+ end++ context 'when a list of mixed date alerts are present' do+ let(:notification_list) do+ [+ build_stubbed(:notification, :for_milestone, reason: 'date_alert_start_date'),+ build_stubbed(:notification, reason: 'date_alert_start_date'),+ build_stubbed(:notification, :for_milestone, reason: 'date_alert_due_date'),+ build_stubbed(:notification, reason: 'date_alert_due_date')+ ]+ end++ it_behaves_like 'rendering detailsSchemas',+ expected_schemas: [+ 'date_alert_date',+ 'date_alert_start_date',+ 'date_alert_due_date'+ ]endendenddiff --git a/spec/lib/api/v3/notifications/property_factory_spec.rb b/spec/lib/api/v3/notifications/property_factory_spec.rbindex 124aa4221cb..2b5c55491b9 100644--- a/spec/lib/api/v3/notifications/property_factory_spec.rb+++ b/spec/lib/api/v3/notifications/property_factory_spec.rb@@ -29,7 +29,8 @@require 'spec_helper'describe ::API::V3::Notifications::PropertyFactory do- let(:resource) { build_stubbed(:work_package) }+ let(:traits) { [] }+ let(:resource) { build_stubbed(:work_package, *traits) }let(:notification) dobuild_stubbed(:notification,@@ -50,6 +51,14 @@ describe ::API::V3::Notifications::PropertyFactory doexpect(described_class.details_for(notification)[0]).to be_a ::API::V3::Values::PropertyDateRepresenterend++ it 'sets the represented property to :start_date' do+ represented = described_class.details_for(notification)[0].represented+ expect(represented)+ .to be_a ::API::V3::Values::PropertyModel+ expect(represented.property)+ .to eq :start_date+ endendcontext 'for a date_alert_due_date notification' do@@ -64,6 +73,37 @@ describe ::API::V3::Notifications::PropertyFactory doexpect(described_class.details_for(notification)[0]).to be_a ::API::V3::Values::PropertyDateRepresenterend++ it 'sets the represented property to :due_date' do+ represented = described_class.details_for(notification)[0].represented+ expect(represented)+ .to be_a ::API::V3::Values::PropertyModel+ expect(represented.property)+ .to eq :due_date+ end+ end++ context 'for a date_alert_due_date notification with milestone work package' do+ let(:traits) { [:is_milestone] }+ let(:reason) { :date_alert_due_date }++ it 'returns one detail' do+ expect(described_class.details_for(notification).size)+ .to eq 1+ end++ it 'returns an array of `Values::Property` representers' do+ expect(described_class.details_for(notification)[0])+ .to be_a ::API::V3::Values::PropertyDateRepresenter+ end++ it 'sets the representer property to :date' do+ represented = described_class.details_for(notification)[0].represented+ expect(represented)+ .to be_a ::API::V3::Values::PropertyModel+ expect(represented.property)+ .to eq :date+ endend(Notification::REASONS.keys - %i[date_alert_start_date date_alert_due_date]).each do |possible_reason|@@ -82,8 +122,8 @@ describe ::API::V3::Notifications::PropertyFactory docontext 'for a date_alert_start_date notification' dolet(:reason) { :date_alert_start_date }- it 'returns one detail' do- expect(described_class.schemas_for([notification]).size)+ it 'returns one detail for the same type' do+ expect(described_class.schemas_for([notification, notification]).size).to eq 1end@@ -104,8 +144,8 @@ describe ::API::V3::Notifications::PropertyFactory docontext 'for a date_alert_due_date notification' dolet(:reason) { :date_alert_due_date }- it 'returns one detail' do- expect(described_class.schemas_for([notification]).size)+ it 'returns one detail for the same type' do+ expect(described_class.schemas_for([notification, notification]).size).to eq 1end@@ -123,21 +163,59 @@ describe ::API::V3::Notifications::PropertyFactory doendend+ context 'for a date_alert_due_date notification with milestone work package' do+ let(:traits) { [:is_milestone] }+ let(:reason) { :date_alert_due_date }++ it 'returns one detail for the same type' do+ expect(described_class.schemas_for([notification, notification]).size)+ .to eq 1+ end++ it 'returns an array of `Values::Schemas::PropertySchemaRepresenter` representers' do+ expect(described_class.schemas_for([notification])[0])+ .to be_a ::API::V3::Values::Schemas::PropertySchemaRepresenter+ end++ it 'returns `Values::Schemas::Model` representer for Date' do+ representer = described_class.schemas_for([notification])[0].represented+ expect(representer)+ .to be_a ::API::V3::Values::Schemas::Model+ expect(representer.name)+ .to eq "Date"+ end+ end+context 'for multiple notifications' dolet(:reason) { :date_alert_due_date }- let(:reason2) { :date_alert_start_date }+ let(:reason_start) { :date_alert_start_date }- let(:notification2) do+ let(:notification_start_date) dobuild_stubbed(:notification,resource:,- reason: reason2)+ reason: reason_start)end- let(:notifications) { [notification, notification2] }+ let(:notification_due_date_milestone) do+ build_stubbed(:notification, :for_milestone, reason:)+ end- it 'returns one detail' do+ let(:notification_start_date_milestone) do+ build_stubbed(:notification, :for_milestone, reason: reason_start)+ end++ let(:notifications) do+ [+ notification,+ notification_start_date,+ notification_due_date_milestone,+ notification_start_date_milestone+ ]+ end++ it 'returns two details for different types' doexpect(described_class.schemas_for(notifications).size)- .to eq 2+ .to eq 3endit 'returns an array of `Values::Schemas::PropertySchemaRepresenter` representers' do@@ -153,6 +231,8 @@ describe ::API::V3::Notifications::PropertyFactory do.to eq "Finish date"expect(representers.second.name).to eq "Start date"+ expect(representers.third.name)+ .to eq "Date"endenddiff --git a/spec/lib/api/v3/values/schemas/value_schema_factory_spec.rb b/spec/lib/api/v3/values/schemas/value_schema_factory_spec.rbindex 5d0594b867f..419bf127b43 100644--- a/spec/lib/api/v3/values/schemas/value_schema_factory_spec.rb+++ b/spec/lib/api/v3/values/schemas/value_schema_factory_spec.rb@@ -79,6 +79,25 @@ describe ::API::V3::Values::Schemas::ValueSchemaFactory doendend+ context 'for the date property (for milestones)' do+ let(:property) { 'date' }++ it 'returns a schema representer' do+ expect(described_class.for(property))+ .to eq representer_instance+ end++ it 'instantiates the representer with the proper params' do+ described_class.for(property)++ expect(::API::V3::Values::Schemas::PropertySchemaRepresenter)+ .to have_received(:new)+ .with(API::V3::Values::Schemas::Model.new(I18n.t('attributes.date'), 'Date'),+ current_user: nil,+ self_link: api_v3_paths.value_schema(property.camelcase(:lower)))+ end+ end+context 'for another property' dolet(:property) { 'bogus' }diff --git a/spec/requests/api/v3/notifications/details_resource_spec.rb b/spec/requests/api/v3/notifications/details_resource_spec.rbindex 9ae0fd51b1d..849ec42d27a 100644--- a/spec/requests/api/v3/notifications/details_resource_spec.rb+++ b/spec/requests/api/v3/notifications/details_resource_spec.rb@@ -39,6 +39,13 @@ describe ::API::V3::Notifications::NotificationsAPI,start_date: Date.yesterday,due_date: Date.tomorrow)end+ shared_let(:milestone_resource) do+ create(:work_package,+ :is_milestone,+ project:,+ start_date: Date.tomorrow,+ due_date: Date.tomorrow)+ endshared_let(:recipient) docreate(:user,member_in_project: project,@@ -46,6 +53,7 @@ describe ::API::V3::Notifications::NotificationsAPI,endlet(:notification) { create(:notification, recipient:, resource:, project:, reason:) }+ let(:milestone_notification) { create(:notification, recipient:, resource: milestone_resource, project:, reason:) }let(:reason) { :date_alert_start_date }# We have 1 detail item at maximum, and the id is coming@@ -113,6 +121,27 @@ describe ::API::V3::Notifications::NotificationsAPI,.at_path('_links/schema/href')endend++ context 'for a start date alert notification with a milestone resource' do+ let(:notification) { milestone_notification }+ let(:reason) { :date_alert_start_date }++ it 'can get the notification details for a start date' do+ send_request+ expect(last_response.body)+ .to be_json_eql('date'.to_json)+ .at_path('property')+ expect(last_response.body)+ .to be_json_eql(::API::V3::Utilities::DateTimeFormatter.format_date(resource.due_date).to_json)+ .at_path('value')+ expect(last_response.body)+ .to be_json_eql(notification_detail_path.to_json)+ .at_path('_links/self/href')+ expect(last_response.body)+ .to be_json_eql("/api/v3/values/schemas/date".to_json)+ .at_path('_links/schema/href')+ end+ endenddescribe 'admin user' dodiff --git a/spec/requests/api/v3/values/schemas/value_schema_resource_spec.rb b/spec/requests/api/v3/values/schemas/value_schema_resource_spec.rbindex 5385eee29d5..81ee47551d7 100644--- a/spec/requests/api/v3/values/schemas/value_schema_resource_spec.rb+++ b/spec/requests/api/v3/values/schemas/value_schema_resource_spec.rb@@ -85,6 +85,27 @@ describe ::API::V3::Values::Schemas::ValueSchemaAPI,endend+ context 'for a date' do+ let(:schema_id) { 'date' }++ it 'returns the schema', :aggregate_failures do+ expect(last_response.status)+ .to eq 200++ expect(last_response.body)+ .to be_json_eql('Schema'.to_json)+ .at_path('_type')++ expect(last_response.body)+ .to be_json_eql('Date'.to_json)+ .at_path('value/type')++ expect(last_response.body)+ .to be_json_eql('Date'.to_json)+ .at_path('value/name')+ end+ end+context 'for a non existing property' dolet(:schema_id) { 'bogus' }