Skip to content

Commit

Permalink
adding archive specs and fixing code in .live method
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrett Heinlen authored and Garrett Heinlen committed Jul 12, 2012
1 parent 2a33ea7 commit 1a54d72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/refinery/news/item.rb
Expand Up @@ -68,7 +68,7 @@ def latest(limit = 10)
end

def live
not_expired.where( "publish_date <= ?", Time.now)
not_expired.where("publish_date <= ?", Time.now)
end

# rejects any page that has not been translated to the current locale.
Expand Down
13 changes: 13 additions & 0 deletions spec/models/refinery/news/item_spec.rb
Expand Up @@ -7,6 +7,19 @@ module News
let(:time_now) { Time.now }
let(:news_item) { Factory(:news_item) }

describe "#archive" do
let(:publish_date) { Time.new(2012,1,15) }
let(:future_date) { Time.new(2012,2,15) }
let(:archive_range) { Time.parse("01/12") }

it "should show 5 news items with publish dates in same month" do
5.times { Factory(:news_item, :publish_date => publish_date) }
5.times { Factory(:news_item, :publish_date => future_date) }

Refinery::News::Item.by_archive(archive_range).length.should == 5
end
end

describe "validations" do
subject do
news_item = Refinery::News::Item.create! :title => "Refinery CMS",
Expand Down

0 comments on commit 1a54d72

Please sign in to comment.