From 6f5eec18c696c7a0c6790e6b1ccb461ad5f775a3 Mon Sep 17 00:00:00 2001 From: Alex Sanford Date: Fri, 1 Jun 2012 14:28:10 -0300 Subject: [PATCH] Fixed issue with page drop slug on templatized pages --- lib/locomotive/liquid/drops/page.rb | 2 +- spec/lib/locomotive/liquid/drops/page_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/locomotive/liquid/drops/page.rb b/lib/locomotive/liquid/drops/page.rb index 98e91b21..83033e46 100644 --- a/lib/locomotive/liquid/drops/page.rb +++ b/lib/locomotive/liquid/drops/page.rb @@ -10,7 +10,7 @@ module Locomotive end 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 def parent diff --git a/spec/lib/locomotive/liquid/drops/page_spec.rb b/spec/lib/locomotive/liquid/drops/page_spec.rb index c9d6f103..cc4b2cb0 100644 --- a/spec/lib/locomotive/liquid/drops/page_spec.rb +++ b/spec/lib/locomotive/liquid/drops/page_spec.rb @@ -81,6 +81,22 @@ describe Locomotive::Liquid::Drops::Page do 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 before(:each) do