Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
Updated pages fixture to include status column values. Updated page m…
Browse files Browse the repository at this point in the history
…odel to use named_scope for self_and_children.
  • Loading branch information
James Cook committed Dec 29, 2008
1 parent 4da6fc1 commit 535eaa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/page.rb
Expand Up @@ -23,6 +23,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 :self_and_siblings, lambda {|page| {:conditions => ["parent_id = ?", page.parent_id], :order => 'page_order'}}

aasm_column :status
aasm_initial_state :draft
Expand Down Expand Up @@ -85,9 +86,8 @@ def full_title
end
end

# TODO: Convert to named_scope
def self_and_siblings
Page.find(:all, :conditions => ["parent_id = ?", self.parent_id], :order => 'page_order')
Page.self_and_siblings self
end

def swap!(direction)
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/pages.yml
Expand Up @@ -26,6 +26,7 @@ home:
title: Home
full_title: Home Page
published: true
status: published
linked: true

second_level:
Expand All @@ -34,6 +35,7 @@ second_level:
title: Second Level
parent_id: 1
published: true
status: published
linked: true

third_level:
Expand All @@ -42,6 +44,7 @@ third_level:
title: Third Level
parent_id: 2
published: true
status: published
linked: true

fourth_level:
Expand All @@ -50,6 +53,7 @@ fourth_level:
title: Fourth Level
parent_id: 3
published: true
status: published
linked: true

unpublished:
Expand All @@ -58,6 +62,7 @@ unpublished:
title: Unpublished
parent_id: 2
published: false
status: draft
linked: false

swap_test:
Expand Down

0 comments on commit 535eaa5

Please sign in to comment.