##// END OF EJS Templates
Merged r9719, r9726, r9727 from trunk....
Jean-Philippe Lang -
r9546:bc945d78a625
parent child
Show More
@@ -43,7 +43,7 class ActivitiesController < ApplicationController
43 if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
43 if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
44 respond_to do |format|
44 respond_to do |format|
45 format.html {
45 format.html {
46 @events_by_day = events.group_by(&:event_date)
46 @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
47 render :layout => false if request.xhr?
47 render :layout => false if request.xhr?
48 }
48 }
49 format.atom {
49 format.atom {
@@ -178,7 +178,7 module ApplicationHelper
178 end
178 end
179
179
180 def format_activity_day(date)
180 def format_activity_day(date)
181 date == Date.today ? l(:label_today).titleize : format_date(date)
181 date == User.current.today ? l(:label_today).titleize : format_date(date)
182 end
182 end
183
183
184 def format_activity_description(text)
184 def format_activity_description(text)
@@ -352,7 +352,7 module ApplicationHelper
352 def time_tag(time)
352 def time_tag(time)
353 text = distance_of_time_in_words(Time.now, time)
353 text = distance_of_time_in_words(Time.now, time)
354 if @project
354 if @project
355 link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => time.to_date}, :title => format_time(time))
355 link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)}, :title => format_time(time))
356 else
356 else
357 content_tag('acronym', text, :title => format_time(time))
357 content_tag('acronym', text, :title => format_time(time))
358 end
358 end
@@ -848,12 +848,18 class Query < ActiveRecord::Base
848 s = []
848 s = []
849 if from
849 if from
850 from_yesterday = from - 1
850 from_yesterday = from - 1
851 from_yesterday_utc = Time.gm(from_yesterday.year, from_yesterday.month, from_yesterday.day)
851 from_yesterday_time = Time.local(from_yesterday.year, from_yesterday.month, from_yesterday.day)
852 s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from_yesterday_utc.end_of_day)])
852 if self.class.default_timezone == :utc
853 from_yesterday_time = from_yesterday_time.utc
854 end
855 s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from_yesterday_time.end_of_day)])
853 end
856 end
854 if to
857 if to
855 to_utc = Time.gm(to.year, to.month, to.day)
858 to_time = Time.local(to.year, to.month, to.day)
856 s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to_utc.end_of_day)])
859 if self.class.default_timezone == :utc
860 to_time = to_time.utc
861 end
862 s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to_time.end_of_day)])
857 end
863 end
858 s.join(' AND ')
864 s.join(' AND ')
859 end
865 end
@@ -370,6 +370,15 class User < Principal
370 end
370 end
371 end
371 end
372
372
373 # Returns the day of +time+ according to user's time zone
374 def time_to_date(time)
375 if time_zone.nil?
376 time.to_date
377 else
378 time.in_time_zone(time_zone).to_date
379 end
380 end
381
373 def logged?
382 def logged?
374 true
383 true
375 end
384 end
@@ -143,7 +143,7 class WikiPage < ActiveRecord::Base
143 if time = read_attribute(:updated_on)
143 if time = read_attribute(:updated_on)
144 # content updated_on was eager loaded with the page
144 # content updated_on was eager loaded with the page
145 begin
145 begin
146 @updated_on = Time.zone ? Time.zone.parse(time.to_s) : Time.parse(time.to_s)
146 @updated_on = (self.class.default_timezone == :utc ? Time.parse(time.to_s).utc : Time.parse(time.to_s).localtime)
147 rescue
147 rescue
148 end
148 end
149 else
149 else
@@ -26,6 +26,7 module RedmineApp
26 config.active_record.observers = :message_observer, :issue_observer, :journal_observer, :news_observer, :document_observer, :wiki_content_observer, :comment_observer
26 config.active_record.observers = :message_observer, :issue_observer, :journal_observer, :news_observer, :document_observer, :wiki_content_observer, :comment_observer
27
27
28 config.active_record.store_full_sti_class = true
28 config.active_record.store_full_sti_class = true
29 config.active_record.default_timezone = :local
29
30
30 # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31 # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31 # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32 # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
@@ -1,8 +1,8
1 ---
1 ---
2 issues_001:
2 issues_001:
3 created_on: <%= 3.days.ago.to_date.to_s(:db) %>
3 created_on: <%= 3.days.ago.to_s(:db) %>
4 project_id: 1
4 project_id: 1
5 updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
5 updated_on: <%= 1.day.ago.to_s(:db) %>
6 priority_id: 4
6 priority_id: 4
7 subject: Can't print recipes
7 subject: Can't print recipes
8 id: 1
8 id: 1
@@ -60,9 +60,9 issues_003:
60 lft: 1
60 lft: 1
61 rgt: 2
61 rgt: 2
62 issues_004:
62 issues_004:
63 created_on: <%= 5.days.ago.to_date.to_s(:db) %>
63 created_on: <%= 5.days.ago.to_s(:db) %>
64 project_id: 2
64 project_id: 2
65 updated_on: <%= 2.days.ago.to_date.to_s(:db) %>
65 updated_on: <%= 2.days.ago.to_s(:db) %>
66 priority_id: 4
66 priority_id: 4
67 subject: Issue on project 2
67 subject: Issue on project 2
68 id: 4
68 id: 4
@@ -77,9 +77,9 issues_004:
77 lft: 1
77 lft: 1
78 rgt: 2
78 rgt: 2
79 issues_005:
79 issues_005:
80 created_on: <%= 5.days.ago.to_date.to_s(:db) %>
80 created_on: <%= 5.days.ago.to_s(:db) %>
81 project_id: 3
81 project_id: 3
82 updated_on: <%= 2.days.ago.to_date.to_s(:db) %>
82 updated_on: <%= 2.days.ago.to_s(:db) %>
83 priority_id: 4
83 priority_id: 4
84 subject: Subproject issue
84 subject: Subproject issue
85 id: 5
85 id: 5
@@ -94,9 +94,9 issues_005:
94 lft: 1
94 lft: 1
95 rgt: 2
95 rgt: 2
96 issues_006:
96 issues_006:
97 created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
97 created_on: <%= 1.minute.ago.to_s(:db) %>
98 project_id: 5
98 project_id: 5
99 updated_on: <%= 1.minute.ago.to_date.to_s(:db) %>
99 updated_on: <%= 1.minute.ago.to_s(:db) %>
100 priority_id: 4
100 priority_id: 4
101 subject: Issue of a private subproject
101 subject: Issue of a private subproject
102 id: 6
102 id: 6
@@ -113,9 +113,9 issues_006:
113 lft: 1
113 lft: 1
114 rgt: 2
114 rgt: 2
115 issues_007:
115 issues_007:
116 created_on: <%= 10.days.ago.to_date.to_s(:db) %>
116 created_on: <%= 10.days.ago.to_s(:db) %>
117 project_id: 1
117 project_id: 1
118 updated_on: <%= 10.days.ago.to_date.to_s(:db) %>
118 updated_on: <%= 10.days.ago.to_s(:db) %>
119 priority_id: 5
119 priority_id: 5
120 subject: Issue due today
120 subject: Issue due today
121 id: 7
121 id: 7
@@ -133,9 +133,9 issues_007:
133 lft: 1
133 lft: 1
134 rgt: 2
134 rgt: 2
135 issues_008:
135 issues_008:
136 created_on: <%= 10.days.ago.to_date.to_s(:db) %>
136 created_on: <%= 10.days.ago.to_s(:db) %>
137 project_id: 1
137 project_id: 1
138 updated_on: <%= 10.days.ago.to_date.to_s(:db) %>
138 updated_on: <%= 10.days.ago.to_s(:db) %>
139 priority_id: 5
139 priority_id: 5
140 subject: Closed issue
140 subject: Closed issue
141 id: 8
141 id: 8
@@ -153,9 +153,9 issues_008:
153 lft: 1
153 lft: 1
154 rgt: 2
154 rgt: 2
155 issues_009:
155 issues_009:
156 created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
156 created_on: <%= 1.minute.ago.to_s(:db) %>
157 project_id: 5
157 project_id: 5
158 updated_on: <%= 1.minute.ago.to_date.to_s(:db) %>
158 updated_on: <%= 1.minute.ago.to_s(:db) %>
159 priority_id: 5
159 priority_id: 5
160 subject: Blocked Issue
160 subject: Blocked Issue
161 id: 9
161 id: 9
@@ -172,9 +172,9 issues_009:
172 lft: 1
172 lft: 1
173 rgt: 2
173 rgt: 2
174 issues_010:
174 issues_010:
175 created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
175 created_on: <%= 1.minute.ago.to_s(:db) %>
176 project_id: 5
176 project_id: 5
177 updated_on: <%= 1.minute.ago.to_date.to_s(:db) %>
177 updated_on: <%= 1.minute.ago.to_s(:db) %>
178 priority_id: 5
178 priority_id: 5
179 subject: Issue Doing the Blocking
179 subject: Issue Doing the Blocking
180 id: 10
180 id: 10
@@ -191,9 +191,9 issues_010:
191 lft: 1
191 lft: 1
192 rgt: 2
192 rgt: 2
193 issues_011:
193 issues_011:
194 created_on: <%= 3.days.ago.to_date.to_s(:db) %>
194 created_on: <%= 3.days.ago.to_s(:db) %>
195 project_id: 1
195 project_id: 1
196 updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
196 updated_on: <%= 1.day.ago.to_s(:db) %>
197 priority_id: 5
197 priority_id: 5
198 subject: Closed issue on a closed version
198 subject: Closed issue on a closed version
199 id: 11
199 id: 11
@@ -210,9 +210,9 issues_011:
210 lft: 1
210 lft: 1
211 rgt: 2
211 rgt: 2
212 issues_012:
212 issues_012:
213 created_on: <%= 3.days.ago.to_date.to_s(:db) %>
213 created_on: <%= 3.days.ago.to_s(:db) %>
214 project_id: 1
214 project_id: 1
215 updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
215 updated_on: <%= 1.day.ago.to_s(:db) %>
216 priority_id: 5
216 priority_id: 5
217 subject: Closed issue on a locked version
217 subject: Closed issue on a locked version
218 id: 12
218 id: 12
@@ -229,9 +229,9 issues_012:
229 lft: 1
229 lft: 1
230 rgt: 2
230 rgt: 2
231 issues_013:
231 issues_013:
232 created_on: <%= 5.days.ago.to_date.to_s(:db) %>
232 created_on: <%= 5.days.ago.to_s(:db) %>
233 project_id: 3
233 project_id: 3
234 updated_on: <%= 2.days.ago.to_date.to_s(:db) %>
234 updated_on: <%= 2.days.ago.to_s(:db) %>
235 priority_id: 4
235 priority_id: 4
236 subject: Subproject issue two
236 subject: Subproject issue two
237 id: 13
237 id: 13
@@ -247,9 +247,9 issues_013:
247 rgt: 2
247 rgt: 2
248 issues_014:
248 issues_014:
249 id: 14
249 id: 14
250 created_on: <%= 15.days.ago.to_date.to_s(:db) %>
250 created_on: <%= 15.days.ago.to_s(:db) %>
251 project_id: 3
251 project_id: 3
252 updated_on: <%= 15.days.ago.to_date.to_s(:db) %>
252 updated_on: <%= 15.days.ago.to_s(:db) %>
253 priority_id: 5
253 priority_id: 5
254 subject: Private issue on public project
254 subject: Private issue on public project
255 fixed_version_id:
255 fixed_version_id:
@@ -424,7 +424,38 class UserTest < ActiveSupport::TestCase
424 assert_equal 'jsmith', @jsmith.reload.name
424 assert_equal 'jsmith', @jsmith.reload.name
425 end
425 end
426 end
426 end
427
427
428 def test_today_should_return_the_day_according_to_user_time_zone
429 preference = User.find(1).pref
430 date = Date.new(2012, 05, 15)
431 time = Time.gm(2012, 05, 15, 23, 30).utc # 2012-05-15 23:30 UTC
432 Date.stubs(:today).returns(date)
433 Time.stubs(:now).returns(time)
434
435 preference.update_attribute :time_zone, 'Baku' # UTC+4
436 assert_equal '2012-05-16', User.find(1).today.to_s
437
438 preference.update_attribute :time_zone, 'La Paz' # UTC-4
439 assert_equal '2012-05-15', User.find(1).today.to_s
440
441 preference.update_attribute :time_zone, ''
442 assert_equal '2012-05-15', User.find(1).today.to_s
443 end
444
445 def test_time_to_date_should_return_the_date_according_to_user_time_zone
446 preference = User.find(1).pref
447 time = Time.gm(2012, 05, 15, 23, 30).utc # 2012-05-15 23:30 UTC
448
449 preference.update_attribute :time_zone, 'Baku' # UTC+4
450 assert_equal '2012-05-16', User.find(1).time_to_date(time).to_s
451
452 preference.update_attribute :time_zone, 'La Paz' # UTC-4
453 assert_equal '2012-05-15', User.find(1).time_to_date(time).to_s
454
455 preference.update_attribute :time_zone, ''
456 assert_equal '2012-05-15', User.find(1).time_to_date(time).to_s
457 end
458
428 def test_fields_for_order_statement_should_return_fields_according_user_format_setting
459 def test_fields_for_order_statement_should_return_fields_according_user_format_setting
429 with_settings :user_format => 'lastname_coma_firstname' do
460 with_settings :user_format => 'lastname_coma_firstname' do
430 assert_equal ['users.lastname', 'users.firstname', 'users.id'], User.fields_for_order_statement
461 assert_equal ['users.lastname', 'users.firstname', 'users.id'], User.fields_for_order_statement
General Comments 0
You need to be logged in to leave comments. Login now