spec/lib/amoeba_spec.rb in amoeba-1.2.1 vs spec/lib/amoeba_spec.rb in amoeba-2.0.0
- old
+ new
@@ -10,11 +10,11 @@
old_post.class.amoeba do
prepend :contents => "Here's a copy: "
end
- new_post = old_post.dup
+ new_post = old_post.amoeba_dup
start_account_count = Account.all.count
start_history_count = History.all.count
start_cat_count = Category.all.count
start_supercat_count = Supercat.all.count
@@ -81,27 +81,36 @@
new_post.comments.select{ |c| c.nerf == 'bonkers' && c.contents.nil? }.length.should == 1
new_post.widgets.map(&:id).each do |id|
old_post.widgets.map(&:id).include?(id).should_not be true
end
+
+ new_post.custom_things.length.should == 3
+ new_post.custom_things.select{ |ct| ct.value == [] }.length.should == 1
+ new_post.custom_things.select{ |ct| ct.value == [1,2]}.length.should == 1
+ new_post.custom_things.select{ |ct| ct.value == [78]}.length.should == 1
# }}}
# Author {{{
old_author = Author.find(1)
- new_author = old_author.dup
+ new_author = old_author.amoeba_dup
new_author.save
new_author.errors.messages.length.should == 0
+ new_author.posts.first.custom_things.length.should == 3
+ new_author.posts.first.custom_things.select{ |ct| ct.value == [] }.length.should == 1
+ new_author.posts.first.custom_things.select{ |ct| ct.value == [1,2]}.length.should == 1
+ new_author.posts.first.custom_things.select{ |ct| ct.value == [78]}.length.should == 1
# }}}
# Products {{{
# Base Class {{{
old_product = Product.find(1)
start_image_count = Image.where(:product_id => old_product.id).count
start_section_count = Section.all.length
rs = ActiveRecord::Base.connection.select_one('SELECT COUNT(*) AS section_count FROM products_sections WHERE product_id = ?', old_product.id)
start_prodsection_count = rs["section_count"]
- new_product = old_product.dup
+ new_product = old_product.amoeba_dup
new_product.save
new_product.errors.messages.length.should == 0
end_image_count = Image.where(:product_id => old_product.id).count
end_newimage_count = Image.where(:product_id => new_product.id).count
@@ -125,11 +134,11 @@
start_image_count = Image.where(:product_id => old_product.id).count
start_section_count = Section.all.length
rs = ActiveRecord::Base.connection.select_one('SELECT COUNT(*) AS section_count FROM products_sections WHERE product_id = ?', old_product.id)
start_prodsection_count = rs["section_count"]
- new_product = old_product.dup
+ new_product = old_product.amoeba_dup
new_product.save
new_product.errors.messages.length.should == 0
end_image_count = Image.where(:product_id => old_product.id).count
end_newimage_count = Image.where(:product_id => new_product.id).count
@@ -152,10 +161,10 @@
start_image_count = Image.where(:product_id => old_product.id).count
start_section_count = Section.all.length
rs = ActiveRecord::Base.connection.select_one('SELECT COUNT(*) AS section_count FROM products_sections WHERE product_id = ?', old_product.id)
start_prodsection_count = rs["section_count"]
- new_product = old_product.dup
+ new_product = old_product.amoeba_dup
new_product.save
new_product.errors.messages.length.should == 0
end_image_count = Image.where(:product_id => old_product.id).count
end_newimage_count = Image.where(:product_id => new_product.id).count