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 schema and update link to time entry

ulferts1a6e693651cf
diff --git a/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb b/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb
index 83dba608f4c..dc04f0c2fe3 100644
--- a/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb
+++ b/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb
@@ -56,6 +56,10 @@ module API
schema :user,
type: 'User'
+ schema :comment,
+ type: 'Formattable',
+ required: false
+
schema_with_allowed_link :work_package,
has_default: false,
required: false,
diff --git a/lib/api/v3/time_entries/time_entry_representer.rb b/lib/api/v3/time_entries/time_entry_representer.rb
index 30af8f3156f..268f59cf872 100644
--- a/lib/api/v3/time_entries/time_entry_representer.rb
+++ b/lib/api/v3/time_entries/time_entry_representer.rb
@@ -50,6 +50,15 @@ module API
}
end
+ link :update do
+ next unless update_allowed?
+
+ {
+ href: api_v3_paths.time_entry_form(represented.id),
+ method: :post
+ }
+ end
+
link :delete do
next unless update_allowed?
@@ -59,6 +68,12 @@ module API
}
end
+ link :schema do
+ {
+ href: api_v3_paths.time_entry_schema
+ }
+ end
+
property :id
formattable_property :comments,
diff --git a/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb b/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
index 08aaff22d3c..be15e7a8b74 100644
--- a/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
@@ -98,7 +98,6 @@ describe 'Status action board', type: :feature, js: true do
new_status_id: open_status.id)
}
-
let(:filters) { ::Components::WorkPackages::Filters.new }
before do
diff --git a/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb b/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb
index 1ec941c6bc8..fc77954870d 100644
--- a/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb
+++ b/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb
@@ -48,7 +48,7 @@ describe ::API::V3::TimeEntries::Schemas::TimeEntrySchemaRepresenter do
allow(contract)
.to receive(:writable?) do |attribute|
- %w(spent_on hours project work_package activity).include?(attribute.to_s)
+ %w(spent_on hours project work_package activity comment).include?(attribute.to_s)
end
allow(contract)
@@ -114,6 +114,17 @@ describe ::API::V3::TimeEntries::Schemas::TimeEntrySchemaRepresenter do
end
end
+ describe 'comment' do
+ let(:path) { 'comment' }
+
+ it_behaves_like 'has basic schema properties' do
+ let(:type) { 'Formattable' }
+ let(:name) { TimeEntry.human_attribute_name('comment') }
+ let(:required) { false }
+ let(:writable) { true }
+ end
+ end
+
describe 'createdAt' do
let(:path) { 'createdAt' }
diff --git a/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb b/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb
index bc0cb079925..2f7aa4b4472 100644
--- a/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb
@@ -99,6 +99,11 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do
let(:title) { activity.name }
end
+ it_behaves_like 'has an untitled link' do
+ let(:link) { 'schema' }
+ let(:href) { api_v3_paths.time_entry_schema }
+ end
+
context 'custom value' do
let(:custom_field) do
FactoryBot.build_stubbed(:time_entry_custom_field, field_format: 'user')
@@ -141,6 +146,12 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do
let(:method) { :patch }
end
+ it_behaves_like 'has an untitled link' do
+ let(:link) { 'update' }
+ let(:href) { api_v3_paths.time_entry_form(time_entry.id) }
+ let(:method) { :post }
+ end
+
it_behaves_like 'has an untitled link' do
let(:link) { 'delete' }
let(:href) { api_v3_paths.time_entry(time_entry.id) }
@@ -154,6 +165,10 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do
let(:link) { 'updateImmediately' }
end
+ it_behaves_like 'has no link' do
+ let(:link) { 'update' }
+ end
+
it_behaves_like 'has no link' do
let(:link) { 'delete' }
end