spec/spree_loader_spec.rb in datashift-0.4.0 vs spec/spree_loader_spec.rb in datashift-0.4.2
- old
+ new
@@ -112,18 +112,17 @@
p.price.should == 345.78
p.name.should == "Simple Product for AR Loader"
p.description.should == "blah blah"
p.cost_price.should == 320.00
p.option_types.should have_exactly(1).items
+ p.option_types.should have_exactly(1).items
p.count_on_hand.should == 12
-
- @klass.last.option_types.should have_exactly(2).items
@klass.last.count_on_hand.should == 23
end
- it "should support default values for Spree Products loader", :fail => true do
+ it "should support default values for Spree Products loader" do
@expected_time = Time.now.to_s(:db)
@product_loader.set_default_value('available_on', @expected_time)
@product_loader.set_default_value('cost_price', 1.0 )
@@ -135,11 +134,11 @@
test_default_values
end
- it "should support default values from config for Spree Products loader", :fail => true do
+ it "should support default values from config for Spree Products loader" do
@product_loader.configure_from( SpecHelper::spree_fixture('SpreeProductsDefaults.yml') )
@product_loader.set_prefix('sku', 'SPEC_')
@@ -169,16 +168,16 @@
end
# Operation and results should be identical when loading multiple associations
# if using either single column embedded syntax, or one column per entry.
- it "should load Products and create Variants from single column", :fail => true do
+ it "should load Products and create Variants from single column" do
test_variants_creation('SpreeProducts.xls')
end
- it "should load Products and create Variants from multiple column" do
+ it "should load Products and create Variants from multiple column", :fail => true do
test_variants_creation('SpreeProductsMultiColumn.xls')
end
def test_variants_creation( source )
@klass.count.should == 0
@@ -205,23 +204,48 @@
p.description.should == "blah blah"
p.cost_price.should == 320.00
@klass.all.select {|m| m.is_master.should == true }
- p.variants.should have_exactly(3).items # count => 12|6|7
-
+
+ # mime_type:jpeg mime_type:PDF mime_type:PNG
+
+ p.variants.should have_exactly(3).items
+
+ p.option_types.should have_exactly(1).items # mime_type
+
+ p.option_types[0].name.should == "mime_type"
+ p.option_types[0].presentation.should == "Mime type"
+
@Variant_klass.all[1].sku.should == "DEMO_001_0"
@Variant_klass.all[1].price.should == 399.99
- v = p.variants[0]
+ # V1
+ v1 = p.variants[0]
- v.sku.should == "DEMO_001_0"
- v.price.should == 399.99
- v.count_on_hand.should == 12
+ v1.sku.should == "DEMO_001_0"
+ v1.price.should == 399.99
+ v1.count_on_hand.should == 12
- p.variants[1].count_on_hand.should == 6
- p.variants[2].count_on_hand.should == 7
+
+ v1.option_values.should have_exactly(1).items # mime_type: jpeg
+ v1.option_values[0].name.should == "jpeg"
+
+ v2 = p.variants[1]
+ v2.count_on_hand.should == 6
+ v2.option_values.should have_exactly(1).items # mime_type: jpeg
+ v2.option_values[0].name.should == "PDF"
+
+ v2.option_values[0].option_type.should_not be_nil
+ v2.option_values[0].option_type.position.should == 0
+
+
+ v3 = p.variants[2]
+ v3.count_on_hand.should == 7
+ v3.option_values.should have_exactly(1).items # mime_type: jpeg
+ v3.option_values[0].name.should == "PNG"
+
@Variant_klass.last.price.should == 50.34
@Variant_klass.last.count_on_hand.should == 18
@product_loader.failed_objects.size.should == 0
end
\ No newline at end of file