engine/spec/models/locomotive/editable_element_spec.rb

56 lines
1.5 KiB
Ruby
Raw Normal View History

2011-02-27 10:33:49 +00:00
require 'spec_helper'
describe Locomotive::EditableElement do
2011-02-27 10:33:49 +00:00
before(:each) do
2011-08-25 21:28:56 +00:00
@site = FactoryGirl.create(:site)
2011-02-27 10:33:49 +00:00
@home = @site.pages.root.first
@home.update_attributes :raw_template => "{% block body %}{% editable_short_text 'body' %}Lorem ipsum{% endeditable_short_text %}{% endblock %}"
2011-08-25 21:28:56 +00:00
@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' %}")
2011-02-27 10:33:49 +00:00
2011-08-25 21:28:56 +00:00
@sub_page_1_1 = FactoryGirl.create(:page, :slug => 'sub_page_1_1', :parent => @sub_page_1, :raw_template => "{% extends 'parent' %}")
2011-02-27 10:33:49 +00:00
end
context 'in sub pages level #1' do
before(:each) do
@sub_page_1.reload
@sub_page_2.reload
end
it 'exists' do
@sub_page_1.editable_elements.size.should == 1
@sub_page_2.editable_elements.size.should == 1
end
it 'has a non-nil slug' do
@sub_page_1.editable_elements.first.slug.should == 'body'
end
end
context 'in sub pages level #2' do
before(:each) do
@sub_page_1_1.reload
end
it 'exists' do
@sub_page_1_1.editable_elements.size.should == 1
end
it 'has a non-nil slug' do
@sub_page_1_1.editable_elements.first.slug.should == 'body'
end
it 'removes editable elements' do
@sub_page_1_1.editable_elements.destroy_all
@sub_page_1_1.reload
@sub_page_1_1.editable_elements.size.should == 0
end
end
end