From 82a61b1d2dcff645b053f7e8d3dab0b82c78d23d Mon Sep 17 00:00:00 2001 From: Robsteranium Date: Thu, 15 Dec 2011 03:16:11 +0000 Subject: [PATCH] spec added to confirm content_type Date problem & patch. Also 1.8.7 compatibility with syck init. --- config/boot.rb | 2 +- spec/models/content_type_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/config/boot.rb b/config/boot.rb index c3c5221e..bbd37771 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -2,7 +2,7 @@ require 'rubygems' # Need to explicitly use syck for yaml require 'yaml' -YAML::ENGINE.yamler = 'syck' +YAML::ENGINE.yamler = 'syck' if defined?(YAML::ENGINE) # Set up gems listed in the Gemfile. if File.exist?(File.expand_path('../../Gemfile', __FILE__)) diff --git a/spec/models/content_type_spec.rb b/spec/models/content_type_spec.rb index 73f72679..0d487711 100644 --- a/spec/models/content_type_spec.rb +++ b/spec/models/content_type_spec.rb @@ -89,6 +89,20 @@ describe ContentType do @content_type.order_direction = 'desc' @content_type.ordered_contents.collect(&:name).should == %w(Sacha Did) end + + it 'returns a list of contents ordered by a Date column when first instance is missing the value' do + @content_type = FactoryGirl.build(:content_type, :order_by => 'created_at') + @content_type.content_custom_fields.build :label => 'Active at', :name => 'active_at', :kind => 'Date' + e = Date.parse('01/01/2001') + l = Date.parse('02/02/2002') + [nil,e,l].each { |d| @content_type.contents << @content_type.content_klass.new(:active_at => d) } + @content_type.order_by = 'active_at' + @content_type.order_direction = 'asc' + lambda { @content_type.ordered_contents }.should_not raise_error(ArgumentError) + @content_type.ordered_contents.map(&:active_at).should == [nil,e,l] + @content_type.order_direction = 'desc' + @content_type.ordered_contents.map(&:active_at).should == [l,e,nil] + end end