Fixed issue with page drop slug on templatized pages

This commit is contained in:
Alex Sanford 2012-06-01 14:28:10 -03:00
parent bc63cd8acf
commit 6f5eec18c6
2 changed files with 17 additions and 1 deletions

View File

@ -10,7 +10,7 @@ module Locomotive
end end
def slug def slug
self._source.templatized? ? self._source.content_type.slug.singularize : self._source.slug self._source.templatized? ? @context['entry']._slug.singularize : self._source.slug
end end
def parent def parent

View File

@ -81,6 +81,22 @@ describe Locomotive::Liquid::Drops::Page do
end end
context '#rendering page slug' do
it 'renders the slug of a normal page' do
render_template('{{ home.slug }}').should == 'index'
end
it 'renders the content instance slug instead for a templatized page' do
templatized = FactoryGirl.build(:page, :title => 'Lorem ipsum template', :templatized => true)
entry = Locomotive::Liquid::Drops::ContentEntry.new(mock('entry', :_slug => 'my_entry'))
render_template('{{ page.slug }}', 'page' => templatized, 'entry' => entry).should == 'my_entry'
end
end
context '#rendering page with editable_elements' do context '#rendering page with editable_elements' do
before(:each) do before(:each) do