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

Add weekday resource link to api/v3/days

Dombi Attila12e6b898db2c
diff --git a/lib/api/v3/days/day_representer.rb b/lib/api/v3/days/day_representer.rb
index 26566ade244..85592d597c7 100644
--- a/lib/api/v3/days/day_representer.rb
+++ b/lib/api/v3/days/day_representer.rb
@@ -34,6 +34,13 @@ module API::V3::Days
self_link path: :day, id_attribute: :date
+ link :weekday do
+ {
+ href: api_v3_paths.days_week_day(represented.day_of_week),
+ title: represented.name
+ }
+ end
+
links :nonWorkingReasons do
next if represented.working
diff --git a/spec/lib/api/v3/days/day_representer_spec.rb b/spec/lib/api/v3/days/day_representer_spec.rb
index 70b807a5f63..f0069adeba5 100644
--- a/spec/lib/api/v3/days/day_representer_spec.rb
+++ b/spec/lib/api/v3/days/day_representer_spec.rb
@@ -120,5 +120,16 @@ describe ::API::V3::Days::DayRepresenter do
end
end
end
+
+ describe 'weekday' do
+ it 'links to the weekday resource' do
+ expected_json = {
+ href: '/api/v3/days/week/2',
+ title: 'Tuesday'
+ }.to_json
+
+ expect(subject).to be_json_eql(expected_json).at_path('_links/weekday')
+ end
+ end
end
end