From d8cb8b20f41ffa7535ac8dadc6b8d8e2731ab718 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 24 Nov 2024 07:04:17 +0000 Subject: [PATCH] Fix: Time entry API returning `hours` as Rational instead of Float (#41819). Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@23304 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/timelog/index.api.rsb | 2 +- app/views/timelog/show.api.rsb | 2 +- test/integration/api_test/time_entries_test.rb | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/timelog/index.api.rsb b/app/views/timelog/index.api.rsb index 976714869..aa05de3b8 100644 --- a/app/views/timelog/index.api.rsb +++ b/app/views/timelog/index.api.rsb @@ -6,7 +6,7 @@ api.array :time_entries, api_meta(:total_count => @entry_count, :offset => @offs api.issue(:id => time_entry.issue_id) unless time_entry.issue.nil? api.user(:id => time_entry.user_id, :name => time_entry.user.name) unless time_entry.user.nil? api.activity(:id => time_entry.activity_id, :name => time_entry.activity.name) unless time_entry.activity.nil? - api.hours time_entry.hours + api.hours time_entry.hours.round(2).to_f api.comments time_entry.comments api.spent_on time_entry.spent_on api.created_on time_entry.created_on diff --git a/app/views/timelog/show.api.rsb b/app/views/timelog/show.api.rsb index 7fce2529a..36a8e8b72 100644 --- a/app/views/timelog/show.api.rsb +++ b/app/views/timelog/show.api.rsb @@ -4,7 +4,7 @@ api.time_entry do api.issue(:id => @time_entry.issue_id) unless @time_entry.issue.nil? api.user(:id => @time_entry.user_id, :name => @time_entry.user.name) unless @time_entry.user.nil? api.activity(:id => @time_entry.activity_id, :name => @time_entry.activity.name) unless @time_entry.activity.nil? - api.hours @time_entry.hours + api.hours @time_entry.hours.round(2).to_f api.comments @time_entry.comments api.spent_on @time_entry.spent_on api.created_on @time_entry.created_on diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb index bd417ab2d..66f7cf335 100644 --- a/test/integration/api_test/time_entries_test.rb +++ b/test/integration/api_test/time_entries_test.rb @@ -33,7 +33,9 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base get '/time_entries.xml', :headers => credentials('jsmith') assert_response :success assert_equal 'application/xml', @response.media_type - assert_select 'time_entries[type=array] time_entry id', :text => '2' + assert_select 'time_entries[type=array] time_entry id', :text => '4' + assert_select 'time_entry:has(id:contains(4)) hours', :text => '7.65' + assert_select 'time_entry:has(id:contains(3)) hours', :text => '1.0' end test "GET /time_entries.xml with limit should return limited results" do @@ -44,10 +46,11 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base end test "GET /time_entries/:id.xml should return the time entry" do - get '/time_entries/2.xml', :headers => credentials('jsmith') + get '/time_entries/4.xml', :headers => credentials('jsmith') assert_response :success assert_equal 'application/xml', @response.media_type - assert_select 'time_entry id', :text => '2' + assert_select 'time_entry id', :text => '4' + assert_select 'time_entry hours', :text => '7.65' end test "GET /time_entries/:id.xml on closed project should return the time entry" do -- 2.39.5