This commit is contained in:
Didier Lafforgue 2012-04-20 00:31:48 +02:00
parent 9b4fc56e82
commit 486c6a12a2
4 changed files with 50 additions and 1 deletions

View File

@ -71,6 +71,11 @@ module Locomotive
new_el.copy_attributes_from(el)
else
existing_el.disabled = false
# only the type and hint properties can be modified from the parent element
%w(_type hint).each do |attr|
existing_el.send(:"#{attr}=", el.send(attr.to_sym))
end
end
end
end

View File

@ -5,7 +5,6 @@ describe Locomotive::Liquid::Drops::ContentEntry do
before(:each) do
@list = mock('list')
@list.stubs(:all).returns(true)
# @list.stubs(:to_liquid).returns(true)
@category = Locomotive::Liquid::Drops::ContentEntry.new(mock('category', :projects => @list))
end

View File

@ -0,0 +1,43 @@
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

View File

@ -1,6 +1,7 @@
require 'spec_helper'
describe Locomotive::Extensions::Site::SubdomainDomains do
describe '#subdomain=' do
let(:site) { Locomotive::Site.new }
@ -20,4 +21,5 @@ describe Locomotive::Extensions::Site::SubdomainDomains do
site.domains.should == ['first.com', 'second.com', 'third.com']
end
end
end