2010-06-21 15:46:17 +00:00
|
|
|
require 'spec_helper'
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
describe Locomotive::Liquid::Drops::Page do
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
before(:each) do
|
|
|
|
@home = Factory.build(:page)
|
|
|
|
@home.stubs(:children).returns([
|
2010-07-23 20:09:54 +00:00
|
|
|
Page.new(:title => 'Child #1'),
|
2010-06-21 15:46:17 +00:00
|
|
|
Page.new(:title => 'Child #2'),
|
|
|
|
Page.new(:title => 'Child #3')
|
|
|
|
])
|
|
|
|
@home.children.last.stubs(:children).returns([
|
|
|
|
Page.new(:title => 'Child #3.1'),
|
|
|
|
Page.new(:title => 'Child #3.2')
|
|
|
|
])
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
context '#rendering' do
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
context '#children' do
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
it 'renders title of all children pages' do
|
|
|
|
content = render_template '{% for child in home.children %}{{ child.title }},{% endfor %}'
|
|
|
|
content.should == 'Child #1,Child #2,Child #3,'
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
context '#sub children' do
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
it 'renders title of all sub children pages' do
|
|
|
|
content = render_template '{% for child in home.children.last.children %}{{ child.title }},{% endfor %}'
|
|
|
|
content.should == 'Child #3.1,Child #3.2,'
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
def render_template(template = '', assigns = {})
|
|
|
|
assigns = {
|
|
|
|
'home' => @home
|
|
|
|
}.merge(assigns)
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-21 15:46:17 +00:00
|
|
|
Liquid::Template.parse(template).render assigns
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
|
|
|
end
|