From c7109af0b8a3fcf3706cd047d1dfeafe2cbc6228 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Tue, 17 May 2011 21:42:47 +0800 Subject: [PATCH] Importer now supports date content type fields as strings or date objects. --- lib/locomotive/import/content_types.rb | 2 +- spec/lib/locomotive/import_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/locomotive/import/content_types.rb b/lib/locomotive/import/content_types.rb index f610ec16..0665671e 100644 --- a/lib/locomotive/import/content_types.rb +++ b/lib/locomotive/import/content_types.rb @@ -79,7 +79,7 @@ module Locomotive value = (case field.kind.downcase when 'file' then self.open_sample_asset(value) when 'boolean' then Boolean.set(value) - when 'date' then Date.parse(value) + when 'date' then value.is_a?(Date) ? value : Date.parse(value) when 'category' if field.category_items.detect { |item| item.name == value }.nil? field.category_items.build :name => value diff --git a/spec/lib/locomotive/import_spec.rb b/spec/lib/locomotive/import_spec.rb index 485fc379..5935e0dd 100644 --- a/spec/lib/locomotive/import_spec.rb +++ b/spec/lib/locomotive/import_spec.rb @@ -22,7 +22,7 @@ describe Locomotive::Import::Job do it 'adds content types' do @site.content_types.count.should == 2 content_type = @site.content_types.where(:slug => 'projects').first - content_type.content_custom_fields.size.should == 6 + content_type.content_custom_fields.size.should == 7 end it 'converts correctly the order_by option for content types' do