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
[#43673] expose startDate, dueDate and overdue in iso8601 format
Dmitrii79c156690a06
diff --git a/lib/api/v3/user_preferences/notification_setting_representer.rb b/lib/api/v3/user_preferences/notification_setting_representer.rbindex 31f92c5de45..959bcd524b1 100644--- a/lib/api/v3/user_preferences/notification_setting_representer.rb+++ b/lib/api/v3/user_preferences/notification_setting_representer.rb@@ -34,6 +34,45 @@ module APINotificationSetting.all_settings.each do |setting|property setting++ property :start_date,+ exec_context: :decorator,+ getter: ->(*) do+ datetime_formatter.format_duration_from_hours(represented.overdue,+ allow_nil: true)+ end++ property :due_date,+ exec_context: :decorator,+ getter: ->(*) do+ datetime_formatter.format_duration_from_hours(represented.overdue,+ allow_nil: true)+ end++ property :overdue,+ exec_context: :decorator,+ getter: ->(*) do+ datetime_formatter.format_duration_from_hours(represented.overdue,+ allow_nil: true)+ end++ def start_date=(value)+ represented.start_date = datetime_formatter.parse_duration_to_days(value,+ 'start_date',+ allow_nil: true)+ end++ def due_date=(value)+ represented.due_date = datetime_formatter.parse_duration_to_days(value,+ 'due_date',+ allow_nil: true)+ end++ def overdue=(value)+ represented.overdue = datetime_formatter.parse_duration_to_days(value,+ 'startDate',+ allow_nil: true)+ endendassociated_resource :project,diff --git a/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb b/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rbindex ba80bfdaaae..a3d44c2cc07 100644--- a/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb+++ b/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb@@ -41,7 +41,7 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,}})end- let(:notification_setting) { build(:notification_setting, overdue: 0) }+ let(:notification_setting) { build(:notification_setting, start_date: 72, due_date: 72, overdue: 72) }let(:user) { build_stubbed(:user, preference:) }let(:representer) { described_class.new(preference, current_user: user) }@@ -80,11 +80,17 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,it 'renders them as a nested array' doexpect(subject).to have_json_type(Array).at_path('notifications')expect(subject).to be_json_eql(nil.to_json).at_path('notifications/0/_links/project/href')+ date_keys = [NotificationSetting::START_DATE, NotificationSetting::DUE_DATE, NotificationSetting::OVERDUE]NotificationSetting.all_settings.each do |key|- expect(subject)- .to be_json_eql(notification_setting.send(key).to_json)- .at_path("notifications/0/#{key.to_s.camelize(:lower)}")+ if date_keys.include?(key)+ expect(subject).to be_json_eql("P3D".to_json)+ .at_path("notifications/0/#{key.to_s.camelize(:lower)}")+ else+ expect(subject)+ .to be_json_eql(notification_setting.send(key).to_json)+ .at_path("notifications/0/#{key.to_s.camelize(:lower)}")+ endendendend