From daef3f226cb055857d5e1eb0b455b2d356cad6af Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 29 Dec 2008 18:47:51 -0600 Subject: [PATCH] not really committing anything, but git is complaining about changes being overwritten. --- app/models/page.rb | 2 +- spec/models/page_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/page.rb b/app/models/page.rb index 1195446..9cbd0d4 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -22,7 +22,7 @@ class Page < ActiveRecord::Base include AASM include ActionView::Helpers::DateHelper - named_scope :visible, lambda {|p| { :conditions => ["published = ? AND ( publish_at <= ? OR publish_at IS NULL )", true, Time.now.getgm ] } } + named_scope :visible, lambda {|p| { :conditions => ["published = ? AND (publish_at <= ? OR publish_at IS NULL )", true, Time.now.getgm] } } named_scope :self_and_siblings, lambda {|page| {:conditions => ["parent_id = ?", page.parent_id], :order => 'page_order'}} aasm_column :status diff --git a/spec/models/page_spec.rb b/spec/models/page_spec.rb index 7f54fb2..26896e9 100644 --- a/spec/models/page_spec.rb +++ b/spec/models/page_spec.rb @@ -22,6 +22,16 @@ end + describe "#visible" do + it "should return pages with publish_at values in the past or nil" do + # Rails is setting the publish_at values as nil when I specify the next two records in the fixtures file. What's up with that? -james + @visible_page = Page.create(:name => "Visible", :title => "I am visible", :publish_at => 1.days.ago ) + @invisible_page = Page.create(:name => "Invisible", :title => "I am invisible", :publish_at => Time.now + 1.days ) + Page.visible.find_by_name("Visible").should eql(@visible_page) + Page.visible.find_by_name("Invisible").should eql(nil) + end + end + describe '#full_title' do it "should override title if it is a different value" do @page = Page.find_by_name('home')