Set published_time as Time.utc to avoid hackery needed later to compare dates.
This commit is contained in:
parent
ab1fa7ec32
commit
65f84593fa
1 changed files with 4 additions and 9 deletions
|
@ -72,20 +72,15 @@ module Refinery
|
||||||
|
|
||||||
describe ".published_dates_older_than" do
|
describe ".published_dates_older_than" do
|
||||||
before do
|
before do
|
||||||
@post1 = FactoryGirl.create(:blog_post, :published_at => Time.now - 20.minutes)
|
@post1 = FactoryGirl.create(:blog_post, :published_at => Time.utc(2012, 05, 01, 15, 20))
|
||||||
@post2 = FactoryGirl.create(:blog_post, :published_at => Time.now - 15.minutes)
|
@post2 = FactoryGirl.create(:blog_post, :published_at => Time.utc(2012, 05, 01, 15, 30))
|
||||||
FactoryGirl.create(:blog_post, :published_at => Time.now)
|
FactoryGirl.create(:blog_post, :published_at => Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns all published dates older than the argument" do
|
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, @post1.published_at]
|
||||||
expected = [@post2.published_at.to_i, @post1.published_at.to_i]
|
|
||||||
|
|
||||||
publish_times = []
|
described_class.published_dates_older_than(5.minutes.ago).should eq(expected)
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue