add tests
This commit is contained in:
parent
bc32848f6a
commit
d5464aa782
@ -34,6 +34,10 @@ class ContentInstance
|
||||
self.content_type.site_id
|
||||
end
|
||||
|
||||
def highlighted_field_value
|
||||
self.send(self.content_type.highlighted_field._name)
|
||||
end
|
||||
|
||||
def visible?
|
||||
self._visible || self._visible.nil?
|
||||
end
|
||||
@ -60,10 +64,6 @@ class ContentInstance
|
||||
Locomotive::Liquid::Drops::Content.new(self)
|
||||
end
|
||||
|
||||
def highlighted_field_value
|
||||
self.send(self.content_type.highlighted_field._name)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_slug
|
||||
|
@ -4,6 +4,11 @@ describe Locomotive::Liquid::Drops::Page do
|
||||
|
||||
before(:each) do
|
||||
@home = Factory.build(:page)
|
||||
end
|
||||
|
||||
context '#rendering tree' do
|
||||
|
||||
before(:each) do
|
||||
@home.stubs(:children).returns([
|
||||
Page.new(:title => 'Child #1'),
|
||||
Page.new(:title => 'Child #2'),
|
||||
@ -15,8 +20,6 @@ describe Locomotive::Liquid::Drops::Page do
|
||||
])
|
||||
end
|
||||
|
||||
context '#rendering' do
|
||||
|
||||
context '#children' do
|
||||
|
||||
it 'renders title of all children pages' do
|
||||
@ -37,6 +40,22 @@ describe Locomotive::Liquid::Drops::Page do
|
||||
|
||||
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 = {})
|
||||
assigns = {
|
||||
'home' => @home
|
||||
|
@ -52,6 +52,14 @@ describe ContentInstance do
|
||||
|
||||
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 = {})
|
||||
@content_type.contents.build({ :title => 'Locomotive', :description => 'Lorem ipsum....' }.merge(options))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user