Defect #30288
closedGroups are incorrect when grouping by date without user timezone set
0%
Description
- group count is not displayed
- The displayed created_on and group name date are different
- Use PostgreSQL or MySQL
- Database time zone is JST (It is not just JST)
- User's time zone is unset (User.current.time_zone is nil)
pry(main)> Issue.find(3).created_on Wed, 19 Jul 2006 19:07:27 UTC +00:00 pry(main)> Issue.find(2).created_on Wed, 19 Jul 2006 19:04:21 UTC +00:00
pry(main)> Issue.find(2).created_on.localtime.to_date # JST Thu, 20 Jul 2006 pry(main)> Issue.find(2).created_on.to_date # UTC Wed, 19 Jul 2006
In environments where the above conditions apply, the test of "IssuesControllerTest#test_index_grouped_by_created_on [test/functional/issues_controller_test.rb:365]" fails.
related: #13803
Files
Related issues
Updated by Go MAEDA almost 6 years ago
- Related to Feature #13803: Implement grouping issues by date (start, due, creation, update, closing dates) added
Updated by Marius BĂLTEANU almost 6 years ago
Do you think that it can have any connection with the issue from #16482?
Updated by Mizuki ISHIKAWA almost 6 years ago
- File fix-30288-v1.patch fix-30288-v1.patch added
Marius BALTEANU wrote:
Do you think that it can have any connection with the issue from #16482?
I think that this problem is a different problem from #16482.
source:/trunk/app/helpers/queries_helper.rb#L139 returned nil when the test failed.
At that time, result_count_by_group was {Thu, 20 Jul 2006=>2} and group was "Wed, 19 Jul 2006".
Issue 's created_on was converted to different time zones, JST and UTC, so they were on different dates.
method name | time zone | source |
i18n#format_time | localtime (Database time zone) | source:/trunk/lib/redmine/i18n.rb#L81 |
User#time_to_date | UTC | source:/trunk/app/models/user.rb#L543 |
I attached a patch with the default timezone of User#time_to_date change to localtime (Database time zone).
In my environment, applying this patch solves the problem.
Updated by Marius BĂLTEANU almost 6 years ago
- Assignee set to Jean-Philippe Lang
- Target version set to 4.1.0
Updated by Jean-Philippe Lang over 5 years ago
- Subject changed from Group name and group count are incorrect when grouping by date (TimeWithZone) to Groups are incorrect when grouping by date without user timezone set
- Status changed from New to Closed
- Resolution set to Fixed
Patch committed, thanks!
Updated by Go MAEDA over 5 years ago
- Target version deleted (
4.1.0)
Removing the target version. This fix is a part of #13803 which will be delivered in upcoming 4.1.0, so it is not necessary to publish in the changelog.
Updated by Go MAEDA over 5 years ago
- Status changed from Closed to Reopened
r18264 broke a test. Probably it fails depending on the current time.
$ date -R ; bin/rails test test/functional/my_controller_test.rb:204 Mon, 24 Jun 2019 08:29:07 +0900 Run options: --seed 30392 # Running: F Failure: MyControllerTest#test_page_with_activity [/Users/maeda/redmines/redmine-trunk/test/functional/my_controller_test.rb:212]: Expected at least 1 element matching "a[href="/activity?from=2019-06-23&user_id=2"]", found 0.. Expected 0 to be >= 1. bin/rails test test/functional/my_controller_test.rb:204
Updated by Mizuki ISHIKAWA over 5 years ago
Go MAEDA wrote:
r18264 broke a test. Probably it fails depending on the current time.
[...]
I think that the test succeeds by changing as below.
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb
index 069cfdc336..81df1d56c4 100644
--- a/test/functional/my_controller_test.rb
+++ b/test/functional/my_controller_test.rb
@@ -205,13 +205,14 @@ class MyControllerTest < Redmine::ControllerTest
user = User.find(2)
user.pref.my_page_layout = {'top' => ['activity']}
user.pref.save!
+ latest_issue = Issue.generate!
get :page
assert_response :success
assert_select 'div#block-activity' do
assert_select 'h3' do
- assert_select 'a[href=?]', activity_path(from: Date.current, user_id: user.id), :text => 'Activity'
+ assert_select 'a[href=?]', activity_path(from: user.time_to_date(latest_issue.created_on), user_id: user.id), :text => 'Activity'
end
assert_select 'div#activity' do
assert_select 'dt', 10
Updated by Mizuki ISHIKAWA over 5 years ago
This change may be better than the #30288#note-10 change.
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb
index 069cfdc336..42a028d407 100644
--- a/test/functional/my_controller_test.rb
+++ b/test/functional/my_controller_test.rb
@@ -204,6 +204,7 @@ class MyControllerTest < Redmine::ControllerTest
def test_page_with_activity
user = User.find(2)
user.pref.my_page_layout = {'top' => ['activity']}
+ user.pref.time_zone = 'UTC'
user.pref.save!
get :page
@@ -211,7 +212,7 @@ class MyControllerTest < Redmine::ControllerTest
assert_select 'div#block-activity' do
assert_select 'h3' do
- assert_select 'a[href=?]', activity_path(from: Date.current, user_id: user.id), :text => 'Activity'
+ assert_select 'a[href=?]', activity_path(from: User.current.today, user_id: user.id), :text => 'Activity'
end
assert_select 'div#activity' do
assert_select 'dt', 10
Updated by Go MAEDA over 5 years ago
- Related to Defect #31620: ActivitiesControllerTest#test_previous_project_index fails depending on the current time and zone added