engine/spec/models/locomotive/extensions/page/editable_elements_spec.rb

44 lines
1.7 KiB
Ruby
Raw Normal View History

2012-04-19 22:31:48 +00:00
require 'spec_helper'
describe Locomotive::Extensions::Page::EditableElements do
before(:each) do
@site = FactoryGirl.create(:site)
@home = @site.pages.root.first
@home.update_attributes :raw_template => "{% editable_short_text 'body' %}Lorem ipsum{% endeditable_short_text %}"
@sub_page_1 = FactoryGirl.create(:page, :slug => 'sub_page_1', :parent => @home, :raw_template => "{% extends 'parent' %}")
@sub_page_2 = FactoryGirl.create(:page, :slug => 'sub_page_2', :parent => @home, :raw_template => "{% extends 'parent' %}")
@sub_page_1_el = @sub_page_1.editable_elements.first
@sub_page_1_1 = FactoryGirl.create(:page, :slug => 'sub_page_1_1', :parent => @sub_page_1, :raw_template => "{% extends 'parent' %}")
end
describe 'modification of an element within the home page' do
before(:each) do
@home = Locomotive::Page.find(@home._id)
end
it 'changes the type of the element in all the children' do
@home.update_attributes :raw_template => "{% editable_long_text 'body' %}Lorem ipsum{% endeditable_long_text %}"
@sub_page_1.reload
@sub_page_1.editable_elements.first._type.should == 'Locomotive::EditableLongText'
@sub_page_1_1.reload
@sub_page_1_1.editable_elements.first._type.should == 'Locomotive::EditableLongText'
end
it 'changes the hint of the element in all the children' do
@home.update_attributes :raw_template => "{% editable_long_text 'body', hint: 'My very useful hint' %}Lorem ipsum{% endeditable_long_text %}"
@sub_page_1.reload
@sub_page_1.editable_elements.first.hint.should == 'My very useful hint'
@sub_page_1_1.reload
@sub_page_1_1.editable_elements.first.hint.should == 'My very useful hint'
end
end
end