]> source.dussan.org Git - redmine.git/commitdiff
Merged r11471 from trunk (#5329).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 9 Mar 2013 09:15:42 +0000 (09:15 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 9 Mar 2013 09:15:42 +0000 (09:15 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@11565 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/helpers/time_report.rb
test/functional/time_entry_reports_controller_test.rb

index 870452758e0da4ec41d1dc04acdb18b8adf05d6c..09093dc95bec8df87095945101821588eecda356 100644 (file)
@@ -63,7 +63,7 @@ module Redmine
             when 'month'
               row['month'] = "#{row['tyear']}-#{row['tmonth']}"
             when 'week'
-              row['week'] = "#{row['tyear']}-#{row['tweek']}"
+              row['week'] = "#{row['spent_on'].cwyear}-#{row['tweek']}"
             when 'day'
               row['day'] = "#{row['spent_on']}"
             end
@@ -90,7 +90,7 @@ module Redmine
               @periods << "#{date_from.year}-#{date_from.month}"
               date_from = (date_from + 1.month).at_beginning_of_month
             when 'week'
-              @periods << "#{date_from.year}-#{date_from.to_date.cweek}"
+              @periods << "#{date_from.to_date.cwyear}-#{date_from.to_date.cweek}"
               date_from = (date_from + 7.day).at_beginning_of_week
             when 'day'
               @periods << "#{date_from.to_date}"
index 759d5d19bcc6b767b2d02d24eccab54e067054ff..76013614e46d4aeca168eb2bb9f3f68403a1e3d5 100644 (file)
@@ -125,6 +125,32 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
       :attributes => {:action => "/projects/ecookbook/issues/1/time_entries/report", :id => 'query_form'}
   end
 
+  def test_report_by_week_should_use_commercial_year
+    TimeEntry.delete_all
+    TimeEntry.generate!(:hours => '2', :spent_on => '2009-12-25') # 2009-52
+    TimeEntry.generate!(:hours => '4', :spent_on => '2009-12-31') # 2009-53
+    TimeEntry.generate!(:hours => '8', :spent_on => '2010-01-01') # 2009-53
+    TimeEntry.generate!(:hours => '16', :spent_on => '2010-01-05') # 2010-1
+
+    get :report, :columns => 'week', :from => "2009-12-25", :to => "2010-01-05", :criteria => ["project"]
+    assert_response :success
+
+    assert_select '#time-report thead tr' do
+      assert_select 'th:nth-child(1)', :text => 'Project'
+      assert_select 'th:nth-child(2)', :text => '2009-52'
+      assert_select 'th:nth-child(3)', :text => '2009-53'
+      assert_select 'th:nth-child(4)', :text => '2010-1'
+      assert_select 'th:nth-child(5)', :text => 'Total'
+    end
+    assert_select '#time-report tbody tr' do
+      assert_select 'td:nth-child(1)', :text => 'eCookbook'
+      assert_select 'td:nth-child(2)', :text => '2.00'
+      assert_select 'td:nth-child(3)', :text => '12.00'
+      assert_select 'td:nth-child(4)', :text => '16.00'
+      assert_select 'td:nth-child(5)', :text => '30.00' # Total
+    end
+  end
+
   def test_report_should_propose_association_custom_fields
     get :report
     assert_response :success