improve the with_scope tag based on the work on the editor

This commit is contained in:
did 2011-09-27 00:25:47 +02:00
parent ce24270948
commit 718b3c67bb
2 changed files with 8 additions and 9 deletions

View File

@ -23,9 +23,9 @@ module Locomotive
def decode(attributes, context) def decode(attributes, context)
attributes.each_pair do |key, value| attributes.each_pair do |key, value|
attributes[key] = (case value attributes[key] = (case value
when /true|false/ then value == 'true' when /^true|false$/i then value == 'true'
when /[0-9]+/ then value.to_i when /^[0-9]+$/ then value.to_i
when /'(\S+)'/ then $1 when /^["|'](.+)["|']$/ then $1.gsub(/^["|']/, '').gsub(/["|']$/, '')
else else
context[value] context[value]
end) end)

View File

@ -41,7 +41,7 @@ describe ContentInstance do
end end
end end
describe "#navigation" do describe "#navigation" do
before(:each) do before(:each) do
%w(first second third).each_with_index do |item,index| %w(first second third).each_with_index do |item,index|
@ -50,22 +50,21 @@ describe ContentInstance do
instance_variable_set "@#{item}", content instance_variable_set "@#{item}", content
end end
end end
it 'should find previous item when available' do it 'should find previous item when available' do
puts @second.previous
@second.previous.custom_field_1.should == "first" @second.previous.custom_field_1.should == "first"
@second.previous._position_in_list.should == 0 @second.previous._position_in_list.should == 0
end end
it 'should find next item when available' do it 'should find next item when available' do
@second.next.custom_field_1.should == "third" @second.next.custom_field_1.should == "third"
@second.next._position_in_list.should == 2 @second.next._position_in_list.should == 2
end end
it 'should return nil when fetching previous item on first in list' do it 'should return nil when fetching previous item on first in list' do
@first.previous.should == nil @first.previous.should == nil
end end
it 'should return nil when fetching next item on last in list' do it 'should return nil when fetching next item on last in list' do
@third.next.should == nil @third.next.should == nil
end end