conflict between the index scope in the page model and the mongoid index method

This commit is contained in:
dinedine 2011-01-27 10:49:42 +01:00
parent 0eb8471c00
commit 2e774b2a97
8 changed files with 8 additions and 7 deletions

View File

@ -38,7 +38,7 @@ class Page
## named scopes ##
scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb
scope :index, :where => { :slug => 'index', :depth => 0 }
scope :root, :where => { :slug => 'index', :depth => 0 }
scope :not_found, :where => { :slug => '404', :depth => 0 }
scope :published, :where => { :published => true }
scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } }

View File

@ -106,7 +106,7 @@ class Site
def destroy_pages
# pages is a tree so we just need to delete the root (as well as the page not found page)
self.pages.index.first.try(:destroy) && self.pages.not_found.first.try(:destroy)
self.pages.root.first.try(:destroy) && self.pages.not_found.first.try(:destroy)
end
end

View File

@ -11,6 +11,7 @@
%span= time_ago_in_words(page.updated_at)
- current_site.content_types.each do |content_type|
- next if content_type.new_record?
- item_on = (content_type.slug == @content_type.slug) rescue nil
= admin_submenu_item content_type.name, admin_contents_url(content_type.slug), :i18n => false, :css => (item_on ? 'on' : '') do
.header

View File

@ -97,7 +97,7 @@ module Locomotive
def find_parent(fullpath)
segments = fullpath.split('/')
return site.pages.index.first if segments.size == 1
return site.pages.root.first if segments.size == 1
segments.pop

View File

@ -6,7 +6,7 @@ module Locomotive
liquid_attributes << :name << :meta_keywords << :meta_description
def index
@index ||= @source.pages.index.first
@index ||= @source.pages.root.first
end
end

View File

@ -56,7 +56,7 @@ module Locomotive
@current_page = context.registers[:page]
children = (case @source
when 'site' then context.registers[:site].pages.index.minimal_attributes.first # start from home page
when 'site' then context.registers[:site].pages.root.minimal_attributes.first # start from home page
when 'parent' then @current_page.parent || @current_page
when 'page' then @current_page
else

View File

@ -57,7 +57,7 @@ describe Locomotive::Import::Job do
end
it 'inserts the index and 404 pages' do
@site.pages.index.first.should_not be_nil
@site.pages.root.first.should_not be_nil
@site.pages.not_found.first.should_not be_nil
end

View File

@ -19,7 +19,7 @@ describe Locomotive::Liquid::Tags::Nav do
@home.children.last.stubs(:children).returns(other_children)
pages = [@home]
pages.stubs(:index).returns(pages)
pages.stubs(:root).returns(pages)
pages.stubs(:minimal_attributes).returns(pages) # iso
@site = Factory.build(:site)
@site.stubs(:pages).returns(pages)