the extends tag was not looking for the right fullpath (when localization is enabled) + sample in order to modify the tinyMCE settings in the back-office
This commit is contained in:
parent
57b7cc1ef2
commit
ce5576da09
@ -1,7 +1,2 @@
|
||||
#= require ./utils/aloha_settings
|
||||
#= require aloha
|
||||
|
||||
|
||||
# r equire_tree ./../aloha/plugins
|
||||
|
||||
# . /.. / aloha / plugins
|
@ -27,8 +27,10 @@ module Locomotive
|
||||
@context[:parent_page] = @context[:page].parent
|
||||
end
|
||||
else
|
||||
locale = ::Mongoid::Fields::I18n.locale
|
||||
|
||||
@context[:parent_page] = @context[:cached_pages].try(:[], @template_name) ||
|
||||
@context[:site].pages.where(:fullpath => @template_name).first
|
||||
@context[:site].pages.where("fullpath.#{locale}" => @template_name).first
|
||||
end
|
||||
|
||||
raise PageNotFound.new("Page with fullpath '#{@template_name}' was not found") if @context[:parent_page].nil?
|
||||
|
@ -0,0 +1,2 @@
|
||||
# FIXME: just to demonstrate how easy it is to change the tinymce settings for the LocomotiveCMS back-office
|
||||
# window.Locomotive.tinyMCE.defaultSettings.theme_advanced_buttons2 = 'formatselect,fontselect,fontsizeselect'
|
@ -0,0 +1 @@
|
||||
= javascript_include_tag 'locomotive_misc'
|
@ -12,17 +12,29 @@ describe Locomotive::Liquid::Tags::Extends do
|
||||
end
|
||||
|
||||
it 'works' do
|
||||
lambda {
|
||||
page = FactoryGirl.build(:page, :slug => 'sub_page_1', :parent => @home)
|
||||
parse('parent', page)
|
||||
}.should_not raise_error
|
||||
parse('parent', page).render.should == 'Hello world'
|
||||
end
|
||||
|
||||
it 'looks for the index with the right locale' do
|
||||
::Mongoid::Fields::I18n.with_locale 'fr' do
|
||||
@home.raw_template = 'Bonjour le monde'
|
||||
@home.send :serialize_template
|
||||
end
|
||||
|
||||
@site.pages.expects(:where).with('fullpath.fr' => 'index').returns([@home])
|
||||
|
||||
::Mongoid::Fields::I18n.with_locale 'fr' do
|
||||
page = FactoryGirl.build(:page, :slug => 'sub_page_1', :parent => @home)
|
||||
parse('index', page).render.should == 'Bonjour le monde'
|
||||
end
|
||||
end
|
||||
|
||||
context '#errors' do
|
||||
|
||||
it 'raises an error if the source page does not exist' do
|
||||
lambda {
|
||||
@site.pages.expects(:where).with(:fullpath => 'foo').returns([])
|
||||
@site.pages.expects(:where).with('fullpath.en' => 'foo').returns([])
|
||||
parse('foo')
|
||||
}.should raise_error(Locomotive::Liquid::PageNotFound, "Page with fullpath 'foo' was not found")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user