From 707973be1619b70d8986d6d70487ee74a892a315 Mon Sep 17 00:00:00 2001 From: "M. Scott Ford" Date: Thu, 28 Jul 2011 00:22:44 -0400 Subject: [PATCH] Wrote a failing test to demonstrate issue with the way import handles the content_type.name attribute. --- spec/factories.rb | 12 ++++++++++ spec/lib/locomotive/import_spec.rb | 35 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/spec/factories.rb b/spec/factories.rb index e2591fb7..8633cf9e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -18,6 +18,18 @@ Factory.define "another site", :parent => "test site" do |s| s.subdomain "test2" end +Factory.define "existing site", :parent => "site" do |s| + s.name "Locomotive site with existing models" + s.subdomain "models" + s.after_build do |site_with_models| + site_with_models.content_types.build( + :slug => 'projects', + :name => 'Existing name', + :description => 'Existing description', + :order_by => 'created_at') + end +end + # Accounts ## Factory.define :account do |a| diff --git a/spec/lib/locomotive/import_spec.rb b/spec/lib/locomotive/import_spec.rb index 10b29bfa..076b27bb 100644 --- a/spec/lib/locomotive/import_spec.rb +++ b/spec/lib/locomotive/import_spec.rb @@ -24,6 +24,11 @@ describe Locomotive::Import::Job do content_type = @site.content_types.where(:slug => 'projects').first content_type.content_custom_fields.size.should == 9 end + + it 'correctly imports content type names' do + content_type = @site.content_types.where(:slug => 'projects').first + content_type.name.should == 'My projects' + end it 'converts correctly the order_by option for content types' do content_type = @site.content_types.where(:slug => 'messages').first @@ -76,5 +81,35 @@ describe Locomotive::Import::Job do end end + + context 'with an existing site' do + before(:all) do + @site = Factory("existing site") + + job = Locomotive::Import::Job.new(FixturedTheme.duplicate_and_open('default.zip'), @site, { :samples => true, :reset => true }) + job.perform + + job.success nil + end + + context 'updates to content_type attributes' do + before(:all) do + @projects = content_type = @site.content_types.where(:slug => 'projects').first + end + + it 'includes new name' do + @projects.name.should == 'My projects' + end + + it 'includes new description' do + @projects.description.should == 'My portfolio' + end + + it 'includes new order by' do + @projects.order_by.should == '_position_in_list' + end + end + end + end \ No newline at end of file