Commit b475fd6aae8de79c7ae7c62be14b61991d1522a0

Authored by Leandro Santos
1 parent d86bcb8f
Exists in fix_sign_up_form

consider local time zone in tests

test/api/activities_test.rb
@@ -167,14 +167,14 @@ class ActivitiesTest < ActiveSupport::TestCase @@ -167,14 +167,14 @@ class ActivitiesTest < ActiveSupport::TestCase
167 ActionTracker::Record.destroy_all 167 ActionTracker::Record.destroy_all
168 a1 = create_activity(:target => person) 168 a1 = create_activity(:target => person)
169 a2 = create_activity(:target => person) 169 a2 = create_activity(:target => person)
170 - a2.updated_at = Time.zone.now 170 + a2.updated_at = Time.now.in_time_zone
171 a2.save 171 a2.save
172 172
173 - a1.updated_at = Time.zone.now + 3.hours 173 + a1.updated_at = Time.now.in_time_zone + 3.hours
174 a1.save! 174 a1.save!
175 175
176 176
177 - params[:timestamp] = Time.zone.now + 1.hours 177 + params[:timestamp] = Time.now.in_time_zone + 1.hours
178 get "/api/v1/profiles/#{person.id}/activities?#{params.to_query}" 178 get "/api/v1/profiles/#{person.id}/activities?#{params.to_query}"
179 json = JSON.parse(last_response.body) 179 json = JSON.parse(last_response.body)
180 180
test/api/articles_test.rb
@@ -335,10 +335,10 @@ class ArticlesTest < ActiveSupport::TestCase @@ -335,10 +335,10 @@ class ArticlesTest < ActiveSupport::TestCase
335 article_one = fast_create(Article, :profile_id => user.person.id, :name => "Another thing") 335 article_one = fast_create(Article, :profile_id => user.person.id, :name => "Another thing")
336 article_two = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") 336 article_two = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
337 337
338 - article_one.updated_at = Time.now + 3.hours 338 + article_one.updated_at = Time.now.in_time_zone + 3.hours
339 article_one.save! 339 article_one.save!
340 340
341 - params[:timestamp] = Time.now + 1.hours 341 + params[:timestamp] = Time.now.in_time_zone + 1.hours
342 get "/api/v1/articles/?#{params.to_query}" 342 get "/api/v1/articles/?#{params.to_query}"
343 json = JSON.parse(last_response.body) 343 json = JSON.parse(last_response.body)
344 344
test/api/communities_test.rb
@@ -164,10 +164,10 @@ class CommunitiesTest < ActiveSupport::TestCase @@ -164,10 +164,10 @@ class CommunitiesTest < ActiveSupport::TestCase
164 community1 = fast_create(Community, :public_profile => true) 164 community1 = fast_create(Community, :public_profile => true)
165 community2 = fast_create(Community) 165 community2 = fast_create(Community)
166 166
167 - community1.updated_at = Time.now + 3.hours 167 + community1.updated_at = Time.now.in_time_zone + 3.hours
168 community1.save! 168 community1.save!
169 169
170 - params[:timestamp] = Time.now + 1.hours 170 + params[:timestamp] = Time.now.in_time_zone + 1.hours
171 get "/api/v1/communities/?#{params.to_query}" 171 get "/api/v1/communities/?#{params.to_query}"
172 json = JSON.parse(last_response.body) 172 json = JSON.parse(last_response.body)
173 173
@@ -299,10 +299,10 @@ class CommunitiesTest < ActiveSupport::TestCase @@ -299,10 +299,10 @@ class CommunitiesTest < ActiveSupport::TestCase
299 community1 = fast_create(Community, :public_profile => true) 299 community1 = fast_create(Community, :public_profile => true)
300 community2 = fast_create(Community) 300 community2 = fast_create(Community)
301 301
302 - community1.updated_at = Time.now + 3.hours 302 + community1.updated_at = Time.now.in_time_zone + 3.hours
303 community1.save! 303 community1.save!
304 304
305 - params[:timestamp] = Time.now + 1.hours 305 + params[:timestamp] = Time.now.in_time_zone + 1.hours
306 get "/api/v1/communities/?#{params.to_query}" 306 get "/api/v1/communities/?#{params.to_query}"
307 json = JSON.parse(last_response.body) 307 json = JSON.parse(last_response.body)
308 308
test/api/task_test.rb
@@ -143,13 +143,13 @@ class TasksTest < ActiveSupport::TestCase @@ -143,13 +143,13 @@ class TasksTest < ActiveSupport::TestCase
143 143
144 should 'list tasks with timestamp' do 144 should 'list tasks with timestamp' do
145 t1 = create(Task, :requestor => person, :target => person) 145 t1 = create(Task, :requestor => person, :target => person)
146 - t2 = create(Task, :requestor => person, :target => person, :created_at => Time.zone.now) 146 + t2 = create(Task, :requestor => person, :target => person, :created_at => Time.now.in_time_zone)
147 147
148 - t1.created_at = Time.zone.now + 3.hours 148 + t1.created_at = Time.now.in_time_zone + 3.hours
149 t1.save! 149 t1.save!
150 150
151 151
152 - params[:timestamp] = Time.zone.now + 1.hours 152 + params[:timestamp] = Time.now.in_time_zone + 1.hours
153 get "/api/v1/tasks/?#{params.to_query}" 153 get "/api/v1/tasks/?#{params.to_query}"
154 json = JSON.parse(last_response.body) 154 json = JSON.parse(last_response.body)
155 155
test/unit/article_test.rb
@@ -226,7 +226,7 @@ class ArticleTest < ActiveSupport::TestCase @@ -226,7 +226,7 @@ class ArticleTest < ActiveSupport::TestCase
226 p = create_user('usr1').person 226 p = create_user('usr1').person
227 Article.destroy_all 227 Article.destroy_all
228 228
229 - now = Time.now 229 + now = Time.now.in_time_zone
230 230
231 first = create(Article, :name => 'first', :published => true, :created_at => now, :published_at => now, :profile_id => p.id) 231 first = create(Article, :name => 'first', :published => true, :created_at => now, :published_at => now, :profile_id => p.id)
232 second = create(Article, :name => 'second', :published => true, :updated_at => now, :published_at => now + 1.second, :profile_id => p.id) 232 second = create(Article, :name => 'second', :published => true, :updated_at => now, :published_at => now + 1.second, :profile_id => p.id)
@@ -728,7 +728,7 @@ class ArticleTest < ActiveSupport::TestCase @@ -728,7 +728,7 @@ class ArticleTest < ActiveSupport::TestCase
728 end 728 end
729 729
730 should 'fill published_at with current date if not set' do 730 should 'fill published_at with current date if not set' do
731 - now = Time.now 731 + now = Time.now.in_time_zone
732 Time.stubs(:now).returns(now) 732 Time.stubs(:now).returns(now)
733 a = create(Article, :name => 'Published at', :profile_id => profile.id) 733 a = create(Article, :name => 'Published at', :profile_id => profile.id)
734 assert_equal now, a.published_at 734 assert_equal now, a.published_at
@@ -1410,7 +1410,7 @@ class ArticleTest < ActiveSupport::TestCase @@ -1410,7 +1410,7 @@ class ArticleTest < ActiveSupport::TestCase
1410 1410
1411 should 'retrieve latest info from topic when has no comments' do 1411 should 'retrieve latest info from topic when has no comments' do
1412 forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id) 1412 forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id)
1413 - post = fast_create(TextileArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now, :author_id => profile.id) 1413 + post = fast_create(TextileArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now.in_time_zone, :author_id => profile.id)
1414 assert_equal post.updated_at, post.info_from_last_update[:date] 1414 assert_equal post.updated_at, post.info_from_last_update[:date]
1415 assert_equal profile.name, post.info_from_last_update[:author_name] 1415 assert_equal profile.name, post.info_from_last_update[:author_name]
1416 assert_equal profile.url, post.info_from_last_update[:author_url] 1416 assert_equal profile.url, post.info_from_last_update[:author_url]
@@ -1418,7 +1418,7 @@ class ArticleTest < ActiveSupport::TestCase @@ -1418,7 +1418,7 @@ class ArticleTest < ActiveSupport::TestCase
1418 1418
1419 should 'retrieve latest info from comment when has comments' do 1419 should 'retrieve latest info from comment when has comments' do
1420 forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id) 1420 forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id)
1421 - post = fast_create(TextileArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now) 1421 + post = fast_create(TextileArticle, :name => 'First post', :profile_id => profile.id, :parent_id => forum.id, :updated_at => Time.now.in_time_zone)
1422 post.comments << build(Comment, :name => 'Guest', :email => 'guest@example.com', :title => 'test comment', :body => 'hello!') 1422 post.comments << build(Comment, :name => 'Guest', :email => 'guest@example.com', :title => 'test comment', :body => 'hello!')
1423 assert_equal post.comments.last.created_at, post.info_from_last_update[:date] 1423 assert_equal post.comments.last.created_at, post.info_from_last_update[:date]
1424 assert_equal "Guest", post.info_from_last_update[:author_name] 1424 assert_equal "Guest", post.info_from_last_update[:author_name]
test/unit/dates_helper_test.rb
@@ -147,7 +147,7 @@ class DatesHelperTest &lt; ActiveSupport::TestCase @@ -147,7 +147,7 @@ class DatesHelperTest &lt; ActiveSupport::TestCase
147 end 147 end
148 148
149 should 'show how long it has passed since a specific date' do 149 should 'show how long it has passed since a specific date' do
150 - date = Time.zone.now 150 + date = Time.now.in_time_zone
151 assert_equal show_date(date, false, false, true), time_ago_in_words(date) 151 assert_equal show_date(date, false, false, true), time_ago_in_words(date)
152 end 152 end
153 153
test/unit/forum_test.rb
@@ -78,7 +78,7 @@ class ForumTest &lt; ActiveSupport::TestCase @@ -78,7 +78,7 @@ class ForumTest &lt; ActiveSupport::TestCase
78 forum = fast_create(Forum, :profile_id => p.id, :name => 'Forum test') 78 forum = fast_create(Forum, :profile_id => p.id, :name => 'Forum test')
79 newer = create(TextileArticle, :name => 'Post 2', :parent => forum, :profile => p) 79 newer = create(TextileArticle, :name => 'Post 2', :parent => forum, :profile => p)
80 older = create(TextileArticle, :name => 'Post 1', :parent => forum, :profile => p) 80 older = create(TextileArticle, :name => 'Post 1', :parent => forum, :profile => p)
81 - older.updated_at = Time.now - 1.month 81 + older.updated_at = Time.now.in_time_zone - 1.month
82 older.stubs(:record_timestamps).returns(false) 82 older.stubs(:record_timestamps).returns(false)
83 older.save! 83 older.save!
84 assert_equal [newer, older], forum.posts 84 assert_equal [newer, older], forum.posts
test/unit/person_notifier_test.rb
@@ -61,7 +61,7 @@ class PersonNotifierTest &lt; ActiveSupport::TestCase @@ -61,7 +61,7 @@ class PersonNotifierTest &lt; ActiveSupport::TestCase
61 @community.add_member(@member) 61 @community.add_member(@member)
62 ActionTracker::Record.delete_all 62 ActionTracker::Record.delete_all
63 comment = Comment.create!(:author => @admin, :title => 'test comment', :body => 'body!', :source => @article ) 63 comment = Comment.create!(:author => @admin, :title => 'test comment', :body => 'body!', :source => @article )
64 - @member.last_notification = DateTime.now + 1.day 64 + @member.last_notification = DateTime.now.in_time_zone + 1.day
65 assert_no_difference 'ActionMailer::Base.deliveries.count' do 65 assert_no_difference 'ActionMailer::Base.deliveries.count' do
66 notify 66 notify
67 end 67 end
@@ -88,7 +88,7 @@ class PersonNotifierTest &lt; ActiveSupport::TestCase @@ -88,7 +88,7 @@ class PersonNotifierTest &lt; ActiveSupport::TestCase
88 88
89 should 'schedule next mail at notification time' do 89 should 'schedule next mail at notification time' do
90 @member.notification_time = 12 90 @member.notification_time = 12
91 - time = Time.now 91 + time = Time.now.in_time_zone
92 @member.notifier.schedule_next_notification_mail 92 @member.notifier.schedule_next_notification_mail
93 job = Delayed::Job.handler_like(PersonNotifier::NotifyJob.name).last 93 job = Delayed::Job.handler_like(PersonNotifier::NotifyJob.name).last
94 assert job.run_at >= time + @member.notification_time.hours 94 assert job.run_at >= time + @member.notification_time.hours
@@ -140,7 +140,7 @@ class PersonNotifierTest &lt; ActiveSupport::TestCase @@ -140,7 +140,7 @@ class PersonNotifierTest &lt; ActiveSupport::TestCase
140 end 140 end
141 141
142 should 'reschedule with changed notification time' do 142 should 'reschedule with changed notification time' do
143 - time = Time.now 143 + time = Time.now.in_time_zone
144 assert_difference 'job_count(PersonNotifier::NotifyJob)', 1 do 144 assert_difference 'job_count(PersonNotifier::NotifyJob)', 1 do
145 @member.notification_time = 2 145 @member.notification_time = 2
146 @member.save! 146 @member.save!
test/unit/profile_test.rb
@@ -1576,8 +1576,8 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1576,8 +1576,8 @@ class ProfileTest &lt; ActiveSupport::TestCase
1576 1576
1577 should 'list all events' do 1577 should 'list all events' do
1578 profile = fast_create(Profile) 1578 profile = fast_create(Profile)
1579 - event1 = Event.new(:name => 'Ze Birthday', :start_date => DateTime.now)  
1580 - event2 = Event.new(:name => 'Mane Birthday', :start_date => DateTime.now >> 1) 1579 + event1 = Event.new(:name => 'Ze Birthday', :start_date => DateTime.now.in_time_zone)
  1580 + event2 = Event.new(:name => 'Mane Birthday', :start_date => DateTime.now.in_time_zone >> 1)
1581 profile.events << [event1, event2] 1581 profile.events << [event1, event2]
1582 assert_includes profile.events, event1 1582 assert_includes profile.events, event1
1583 assert_includes profile.events, event2 1583 assert_includes profile.events, event2
@@ -1586,7 +1586,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1586,7 +1586,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
1586 should 'list events by day' do 1586 should 'list events by day' do
1587 profile = fast_create(Profile) 1587 profile = fast_create(Profile)
1588 1588
1589 - today = DateTime.now 1589 + today = DateTime.now.in_time_zone
1590 yesterday_event = Event.new(:name => 'Joao Birthday', :start_date => today - 1.day) 1590 yesterday_event = Event.new(:name => 'Joao Birthday', :start_date => today - 1.day)
1591 today_event = Event.new(:name => 'Ze Birthday', :start_date => today) 1591 today_event = Event.new(:name => 'Ze Birthday', :start_date => today)
1592 tomorrow_event = Event.new(:name => 'Mane Birthday', :start_date => today + 1.day) 1592 tomorrow_event = Event.new(:name => 'Mane Birthday', :start_date => today + 1.day)
@@ -1612,7 +1612,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1612,7 +1612,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
1612 should 'list events in a range' do 1612 should 'list events in a range' do
1613 profile = fast_create(Profile) 1613 profile = fast_create(Profile)
1614 1614
1615 - today = DateTime.now 1615 + today = DateTime.now.in_time_zone
1616 event_in_range = Event.new(:name => 'Noosfero Conference', :start_date => today - 2.day, :end_date => today + 2.day) 1616 event_in_range = Event.new(:name => 'Noosfero Conference', :start_date => today - 2.day, :end_date => today + 2.day)
1617 event_in_day = Event.new(:name => 'Ze Birthday', :start_date => today) 1617 event_in_day = Event.new(:name => 'Ze Birthday', :start_date => today)
1618 1618
@@ -1626,7 +1626,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1626,7 +1626,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
1626 should 'not list events out of range' do 1626 should 'not list events out of range' do
1627 profile = fast_create(Profile) 1627 profile = fast_create(Profile)
1628 1628
1629 - today = DateTime.now 1629 + today = DateTime.now.in_time_zone
1630 event_in_range1 = Event.new(:name => 'Foswiki Conference', :start_date => today - 2.day, :end_date => today + 2.day) 1630 event_in_range1 = Event.new(:name => 'Foswiki Conference', :start_date => today - 2.day, :end_date => today + 2.day)
1631 event_in_range2 = Event.new(:name => 'Debian Conference', :start_date => today - 2.day, :end_date => today + 3.day) 1631 event_in_range2 = Event.new(:name => 'Debian Conference', :start_date => today - 2.day, :end_date => today + 3.day)
1632 event_out_of_range = Event.new(:name => 'Ze Birthday', :start_date => today - 5.day, :end_date => today - 3.day) 1632 event_out_of_range = Event.new(:name => 'Ze Birthday', :start_date => today - 5.day, :end_date => today - 3.day)
@@ -1640,9 +1640,9 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1640,9 +1640,9 @@ class ProfileTest &lt; ActiveSupport::TestCase
1640 1640
1641 should 'sort events by date' do 1641 should 'sort events by date' do
1642 profile = fast_create(Profile) 1642 profile = fast_create(Profile)
1643 - event1 = Event.new(:name => 'Noosfero Hackaton', :start_date => DateTime.now)  
1644 - event2 = Event.new(:name => 'Debian Day', :start_date => DateTime.now - 1)  
1645 - event3 = Event.new(:name => 'Fisl 10', :start_date => DateTime.now + 1) 1643 + event1 = Event.new(:name => 'Noosfero Hackaton', :start_date => DateTime.now.in_time_zone)
  1644 + event2 = Event.new(:name => 'Debian Day', :start_date => DateTime.now.in_time_zone - 1)
  1645 + event3 = Event.new(:name => 'Fisl 10', :start_date => DateTime.now.in_time_zone + 1)
1646 profile.events << [event1, event2, event3] 1646 profile.events << [event1, event2, event3]
1647 assert_equal [event2, event1, event3], profile.events 1647 assert_equal [event2, event1, event3], profile.events
1648 end 1648 end
@@ -1708,7 +1708,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1708,7 +1708,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
1708 should 'find more recent profile' do 1708 should 'find more recent profile' do
1709 Profile.delete_all 1709 Profile.delete_all
1710 p1 = fast_create(Profile, :created_at => 4.days.ago) 1710 p1 = fast_create(Profile, :created_at => 4.days.ago)
1711 - p2 = fast_create(Profile, :created_at => Time.now) 1711 + p2 = fast_create(Profile, :created_at => Time.now.in_time_zone)
1712 p3 = fast_create(Profile, :created_at => 2.days.ago) 1712 p3 = fast_create(Profile, :created_at => 2.days.ago)
1713 assert_equal [p2,p3,p1] , Profile.more_recent 1713 assert_equal [p2,p3,p1] , Profile.more_recent
1714 1714
@@ -1739,19 +1739,19 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1739,19 +1739,19 @@ class ProfileTest &lt; ActiveSupport::TestCase
1739 1739
1740 should "return one activity on label if the profile has one action" do 1740 should "return one activity on label if the profile has one action" do
1741 p = fast_create(Profile) 1741 p = fast_create(Profile)
1742 - fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now) 1742 + fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now.in_time_zone)
1743 assert_equal 1, p.recent_actions.count 1743 assert_equal 1, p.recent_actions.count
1744 assert_equal "one activity", p.more_active_label 1744 assert_equal "one activity", p.more_active_label
1745 end 1745 end
1746 1746
1747 should "return number of activities on label if the profile has more than one action" do 1747 should "return number of activities on label if the profile has more than one action" do
1748 p = fast_create(Profile) 1748 p = fast_create(Profile)
1749 - fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now)  
1750 - fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now) 1749 + fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now.in_time_zone)
  1750 + fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now.in_time_zone)
1751 assert_equal 2, p.recent_actions.count 1751 assert_equal 2, p.recent_actions.count
1752 assert_equal "2 activities", p.more_active_label 1752 assert_equal "2 activities", p.more_active_label
1753 1753
1754 - fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now) 1754 + fast_create(ActionTracker::Record, :user_type => 'Profile', :user_id => p, :created_at => Time.now.in_time_zone)
1755 assert_equal 3, p.recent_actions.count 1755 assert_equal 3, p.recent_actions.count
1756 assert_equal "3 activities", p.more_active_label 1756 assert_equal "3 activities", p.more_active_label
1757 end 1757 end
@@ -2187,10 +2187,10 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -2187,10 +2187,10 @@ class ProfileTest &lt; ActiveSupport::TestCase
2187 end 2187 end
2188 2188
2189 should 'fetch profiles older than a specific date' do 2189 should 'fetch profiles older than a specific date' do
2190 - p1 = fast_create(Profile, :created_at => Time.now)  
2191 - p2 = fast_create(Profile, :created_at => Time.now - 1.day)  
2192 - p3 = fast_create(Profile, :created_at => Time.now - 2.days)  
2193 - p4 = fast_create(Profile, :created_at => Time.now - 3.days) 2190 + p1 = fast_create(Profile, :created_at => Time.now.in_time_zone)
  2191 + p2 = fast_create(Profile, :created_at => Time.now.in_time_zone - 1.day)
  2192 + p3 = fast_create(Profile, :created_at => Time.now.in_time_zone - 2.days)
  2193 + p4 = fast_create(Profile, :created_at => Time.now.in_time_zone - 3.days)
2194 2194
2195 profiles = Profile.older_than(p2.created_at) 2195 profiles = Profile.older_than(p2.created_at)
2196 2196
@@ -2201,10 +2201,10 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -2201,10 +2201,10 @@ class ProfileTest &lt; ActiveSupport::TestCase
2201 end 2201 end
2202 2202
2203 should 'fetch profiles younger than a specific date' do 2203 should 'fetch profiles younger than a specific date' do
2204 - p1 = fast_create(Profile, :created_at => Time.now)  
2205 - p2 = fast_create(Profile, :created_at => Time.now - 1.day)  
2206 - p3 = fast_create(Profile, :created_at => Time.now - 2.days)  
2207 - p4 = fast_create(Profile, :created_at => Time.now - 3.days) 2204 + p1 = fast_create(Profile, :created_at => Time.now.in_time_zone)
  2205 + p2 = fast_create(Profile, :created_at => Time.now.in_time_zone - 1.day)
  2206 + p3 = fast_create(Profile, :created_at => Time.now.in_time_zone - 2.days)
  2207 + p4 = fast_create(Profile, :created_at => Time.now.in_time_zone - 3.days)
2208 2208
2209 profiles = Profile.younger_than(p3.created_at) 2209 profiles = Profile.younger_than(p3.created_at)
2210 2210
test/unit/task_test.rb
@@ -342,10 +342,10 @@ class TaskTest &lt; ActiveSupport::TestCase @@ -342,10 +342,10 @@ class TaskTest &lt; ActiveSupport::TestCase
342 342
343 should 'order tasks by some attribute correctly' do 343 should 'order tasks by some attribute correctly' do
344 Task.destroy_all 344 Task.destroy_all
345 - t1 = fast_create(Task, :status => 4, :created_at => Time.now + 1.hour)  
346 - t2 = fast_create(Task, :status => 3, :created_at => Time.now + 2.hour)  
347 - t3 = fast_create(Task, :status => 2, :created_at => Time.now + 3.hour)  
348 - t4 = fast_create(Task, :status => 1, :created_at => Time.now + 4.hour) 345 + t1 = fast_create(Task, :status => 4, :created_at => Time.now.in_time_zone + 1.hour)
  346 + t2 = fast_create(Task, :status => 3, :created_at => Time.now.in_time_zone + 2.hour)
  347 + t3 = fast_create(Task, :status => 2, :created_at => Time.now.in_time_zone + 3.hour)
  348 + t4 = fast_create(Task, :status => 1, :created_at => Time.now.in_time_zone + 4.hour)
349 349
350 assert_equal [t1,t2,t3,t4], Task.order_by('created_at', 'asc') 350 assert_equal [t1,t2,t3,t4], Task.order_by('created_at', 'asc')
351 assert_equal [t4,t3,t2,t1], Task.order_by('created_at', 'desc') 351 assert_equal [t4,t3,t2,t1], Task.order_by('created_at', 'desc')
test/unit/time_scopes.rb
@@ -5,10 +5,10 @@ require_relative &quot;../test_helper&quot; @@ -5,10 +5,10 @@ require_relative &quot;../test_helper&quot;
5 5
6 class TimeScopesTest < ActiveSupport::TestCase 6 class TimeScopesTest < ActiveSupport::TestCase
7 should 'fetch profiles older than a specific date' do 7 should 'fetch profiles older than a specific date' do
8 - p1 = fast_create(Profile, :created_at => Time.now)  
9 - p2 = fast_create(Profile, :created_at => Time.now - 1.day)  
10 - p3 = fast_create(Profile, :created_at => Time.now - 2.days)  
11 - p4 = fast_create(Profile, :created_at => Time.now - 3.days) 8 + p1 = fast_create(Profile, :created_at => Time.now.in_time_zone)
  9 + p2 = fast_create(Profile, :created_at => Time.now.in_time_zone - 1.day)
  10 + p3 = fast_create(Profile, :created_at => Time.now.in_time_zone - 2.days)
  11 + p4 = fast_create(Profile, :created_at => Time.now.in_time_zone - 3.days)
12 12
13 profiles = Profile.older_than(p2.created_at) 13 profiles = Profile.older_than(p2.created_at)
14 14
@@ -19,10 +19,10 @@ class TimeScopesTest &lt; ActiveSupport::TestCase @@ -19,10 +19,10 @@ class TimeScopesTest &lt; ActiveSupport::TestCase
19 end 19 end
20 20
21 should 'fetch profiles younger than a specific date' do 21 should 'fetch profiles younger than a specific date' do
22 - p1 = fast_create(Profile, :created_at => Time.now)  
23 - p2 = fast_create(Profile, :created_at => Time.now - 1.day)  
24 - p3 = fast_create(Profile, :created_at => Time.now - 2.days)  
25 - p4 = fast_create(Profile, :created_at => Time.now - 3.days) 22 + p1 = fast_create(Profile, :created_at => Time.now.in_time_zone)
  23 + p2 = fast_create(Profile, :created_at => Time.now.in_time_zone - 1.day)
  24 + p3 = fast_create(Profile, :created_at => Time.now.in_time_zone - 2.days)
  25 + p4 = fast_create(Profile, :created_at => Time.now.in_time_zone - 3.days)
26 26
27 profiles = Profile.younger_than(p3.created_at) 27 profiles = Profile.younger_than(p3.created_at)
28 28