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)
attributes.each_pair do |key, value|
attributes[key] = (case value
when /true|false/ then value == 'true'
when /[0-9]+/ then value.to_i
when /'(\S+)'/ then $1
when /^true|false$/i then value == 'true'
when /^[0-9]+$/ then value.to_i
when /^["|'](.+)["|']$/ then $1.gsub(/^["|']/, '').gsub(/["|']$/, '')
else
context[value]
end)

View File

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