From 65f84593fa2f9706cd9491425d9e572d4ab5b22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Sat, 5 May 2012 17:52:28 +0300 Subject: Set published_time as Time.utc to avoid hackery needed later to compare dates. --- spec/models/refinery/blog/post_spec.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'spec') diff --git a/spec/models/refinery/blog/post_spec.rb b/spec/models/refinery/blog/post_spec.rb index 19db0ca..2f34eb8 100644 --- a/spec/models/refinery/blog/post_spec.rb +++ b/spec/models/refinery/blog/post_spec.rb @@ -72,20 +72,15 @@ module Refinery describe ".published_dates_older_than" do before do - @post1 = FactoryGirl.create(:blog_post, :published_at => Time.now - 20.minutes) - @post2 = FactoryGirl.create(:blog_post, :published_at => Time.now - 15.minutes) + @post1 = FactoryGirl.create(:blog_post, :published_at => Time.utc(2012, 05, 01, 15, 20)) + @post2 = FactoryGirl.create(:blog_post, :published_at => Time.utc(2012, 05, 01, 15, 30)) FactoryGirl.create(:blog_post, :published_at => Time.now) end it "returns all published dates older than the argument" do - # I'm converting .to_i here and later because of millisecond comparison issue - expected = [@post2.published_at.to_i, @post1.published_at.to_i] + expected = [@post2.published_at, @post1.published_at] - publish_times = [] - described_class.published_dates_older_than(5.minutes.ago).each do |published_at| - publish_times << published_at.to_i - end - publish_times.should eq(expected) + described_class.published_dates_older_than(5.minutes.ago).should eq(expected) end end -- cgit v1.2.3