parent_id and parent_ids are part of the attributes of the page entity

did committed Feb 26, 2015
commit 0977c3760bc02ae448479c99cd94545b1a108097
Showing 3 changed files with 18 additions and 4 deletions
locomotive/steam/adapters/filesystem/sanitizers/page.rb b/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb +2 -2
@@ @@ -44,8 +44,8 @@ module Locomotive::Steam
def set_parent_id(page)
parent_key = parent_fullpath(page)
- page.parent_ids = @parent_ids[parent_key] || []
- page.parent_id = @ids[parent_key]
+ page[:parent_ids] = @parent_ids[parent_key] || []
+ page[:parent_id] = @ids[parent_key]
@parent_ids[page._fullpath] = page.parent_ids + [page._id]
end
locomotive/steam/entities/page.rb b/lib/locomotive/steam/entities/page.rb +4 -2
@@ @@ -4,7 +4,7 @@ module Locomotive::Steam
include Locomotive::Steam::Models::Entity
- attr_accessor :parent_id, :parent_ids, :depth, :_fullpath, :content_entry
+ attr_accessor :depth, :_fullpath, :content_entry
def initialize(attributes)
super({
@@ @@ -16,7 +16,9 @@ module Locomotive::Steam
position: 99,
template: {},
editable_elements: {},
- redirect_url: {}
+ redirect_url: {},
+ parent_id: nil,
+ parent_ids: nil
}.merge(attributes))
end
spec/integration/repositories/page_repository_spec.rb +12 -0
@@ @@ -36,6 +36,18 @@ describe Locomotive::Steam::PageRepository do
it { expect(subject.size).to eq 2 }
end
+ describe '#root' do
+ subject { repository.root }
+ it { expect(subject.title[:en]).to eq 'Home page' }
+ it { expect(subject.title[:fr]).to eq "Page d'accueil" }
+ end
+
+ describe '#parent_of' do
+ let(:page) { repository.by_handle('about-us') }
+ subject { repository.parent_of(page) }
+ it { expect(subject.title[:en]).to eq 'Home page' }
+ end
+
end
context 'MongoDB' do