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
add new fields to API schema
Klaus Zanders60c90a3753de
diff --git a/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb b/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rbindex ef7efd5f554..c5906a0e9d3 100644--- a/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb+++ b/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb@@ -50,6 +50,15 @@ module APIschema :spent_on,type: "Date"+ schema :start_time,+ type: "DateTime",+ required: -> { TimeEntry.must_track_start_and_end_time? },+ writable: -> { TimeEntry.can_track_start_and_end_time? }++ schema :end_time,+ type: "DateTime",+ writable: false+schema :hours,type: "Duration"diff --git a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rbindex 3eee3e2c138..c30734b03df 100644--- a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb+++ b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb@@ -108,6 +108,53 @@ RSpec.describe API::V3::TimeEntries::Schemas::TimeEntrySchemaRepresenter doendend+ describe "startTime" do+ let(:path) { "startTime" }++ before do+ allow(TimeEntry).to receive_messages(+ can_track_start_and_end_time?: can_track_times,+ must_track_start_and_end_time?: must_track_times+ )+ end++ context "when start- and end-time tracking is disabled" do+ let(:can_track_times) { false }+ let(:must_track_times) { false }++ it_behaves_like "has basic schema properties" do+ let(:type) { "DateTime" }+ let(:name) { TimeEntry.human_attribute_name("start_time") }+ let(:required) { false }+ let(:writable) { false }+ end+ end++ context "when start- and end-time tracking is enabled" do+ let(:can_track_times) { true }+ let(:must_track_times) { false }++ it_behaves_like "has basic schema properties" do+ let(:type) { "DateTime" }+ let(:name) { TimeEntry.human_attribute_name("start_time") }+ let(:required) { false }+ let(:writable) { true }+ end+ end++ context "when start- and end-time tracking is enforced" do+ let(:can_track_times) { true }+ let(:must_track_times) { true }++ it_behaves_like "has basic schema properties" do+ let(:type) { "DateTime" }+ let(:name) { TimeEntry.human_attribute_name("start_time") }+ let(:required) { true }+ let(:writable) { true }+ end+ end+ end+describe "hours" dolet(:path) { "hours" }