add tests
This commit is contained in:
parent
bc32848f6a
commit
d5464aa782
@ -34,6 +34,10 @@ class ContentInstance
|
|||||||
self.content_type.site_id
|
self.content_type.site_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def highlighted_field_value
|
||||||
|
self.send(self.content_type.highlighted_field._name)
|
||||||
|
end
|
||||||
|
|
||||||
def visible?
|
def visible?
|
||||||
self._visible || self._visible.nil?
|
self._visible || self._visible.nil?
|
||||||
end
|
end
|
||||||
@ -60,10 +64,6 @@ class ContentInstance
|
|||||||
Locomotive::Liquid::Drops::Content.new(self)
|
Locomotive::Liquid::Drops::Content.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def highlighted_field_value
|
|
||||||
self.send(self.content_type.highlighted_field._name)
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_slug
|
def set_slug
|
||||||
|
@ -4,18 +4,21 @@ describe Locomotive::Liquid::Drops::Page do
|
|||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@home = Factory.build(:page)
|
@home = Factory.build(:page)
|
||||||
@home.stubs(:children).returns([
|
|
||||||
Page.new(:title => 'Child #1'),
|
|
||||||
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
|
end
|
||||||
|
|
||||||
context '#rendering' do
|
context '#rendering tree' do
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
@home.stubs(:children).returns([
|
||||||
|
Page.new(:title => 'Child #1'),
|
||||||
|
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
|
||||||
|
|
||||||
context '#children' do
|
context '#children' do
|
||||||
|
|
||||||
@ -37,6 +40,22 @@ describe Locomotive::Liquid::Drops::Page do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context '#rendering page title' do
|
||||||
|
|
||||||
|
it 'renders the title of a normal page' do
|
||||||
|
render_template('{{ home.title }}').should == 'Home page'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders the content instance highlighted field instead for a templatized page' do
|
||||||
|
templatized = Factory.build(:page, :title => 'Lorem ipsum template', :templatized => true)
|
||||||
|
|
||||||
|
content_instance = Locomotive::Liquid::Drops::Content.new(mock('content_instance', :highlighted_field_value => 'Locomotive rocks !'))
|
||||||
|
|
||||||
|
render_template('{{ page.title }}', 'page' => templatized, 'content_instance' => content_instance).should == 'Locomotive rocks !'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def render_template(template = '', assigns = {})
|
def render_template(template = '', assigns = {})
|
||||||
assigns = {
|
assigns = {
|
||||||
'home' => @home
|
'home' => @home
|
||||||
|
@ -52,6 +52,14 @@ describe ContentInstance do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#requirements' do
|
||||||
|
|
||||||
|
it 'has public access to the highlighted field value' do
|
||||||
|
build_content.highlighted_field_value.should == 'Locomotive'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def build_content(options = {})
|
def build_content(options = {})
|
||||||
@content_type.contents.build({ :title => 'Locomotive', :description => 'Lorem ipsum....' }.merge(options))
|
@content_type.contents.build({ :title => 'Locomotive', :description => 'Lorem ipsum....' }.merge(options))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user