diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /lib/api/time_tracking_endpoints.rb | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'lib/api/time_tracking_endpoints.rb')
-rw-r--r-- | lib/api/time_tracking_endpoints.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/api/time_tracking_endpoints.rb b/lib/api/time_tracking_endpoints.rb index 3534edc3831..d68057a1947 100644 --- a/lib/api/time_tracking_endpoints.rb +++ b/lib/api/time_tracking_endpoints.rb @@ -55,10 +55,11 @@ module API issuable_key = "#{issuable_name}_iid".to_sym desc "Set a time estimate for a #{issuable_name}" do - detail " Sets an estimated time of work for this #{issuable_name}." + detail "Sets an estimated time of work for this #{issuable_name}." success Entities::IssuableTimeStats failure [ { code: 401, message: 'Unauthorized' }, + { code: 400, message: 'Bad request' }, { code: 404, message: 'Not found' } ] tags [issuable_collection_name] @@ -70,8 +71,14 @@ module API post ":id/#{issuable_collection_name}/:#{issuable_key}/time_estimate" do authorize! admin_issuable_key, load_issuable - status :ok - update_issuable(time_estimate: Gitlab::TimeTrackingFormatter.parse(params.delete(:duration))) + time_estimate = Gitlab::TimeTrackingFormatter.parse(params.delete(:duration), keep_zero: true) + + if time_estimate && time_estimate >= 0 + status :ok + update_issuable(time_estimate: time_estimate) + else + bad_request!(reason: 'Time estimate must have a valid format and be greater than or equal to zero.') + end end desc "Reset the time estimate for a project #{issuable_name}" do |