Permalink
Browse files

Issue #3 - Implementing spec for serialized columns

  • Loading branch information...
1 parent f94fe82 commit 0aa235970ab4d9a260f2aadd5e4676c12bdb9351 @rocksolidwebdesign rocksolidwebdesign committed Apr 13, 2012
Showing with 8 additions and 16 deletions.
  1. +5 −4 spec/lib/amoeba_spec.rb
  2. +2 −2 spec/support/data.rb
  3. +1 −10 spec/support/models.rb
View
@@ -83,10 +83,11 @@
new_post.widgets.map(&:id).each do |id|
old_post.widgets.map(&:id).include?(id).should_not be true
end
- old_post.custom_things.length.should == 3
- old_post.custom_things.select{ |ct| ct.value == [] }.length.should == 1
- old_post.custom_things.select{ |ct| ct.value == [1,2]}.length.should == 1
- old_post.custom_things.select{ |ct| ct.value == [78]}.length.should == 1
+
+ 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)
View
@@ -81,6 +81,8 @@
s3.superkittens.create(:value => "Dopey")
s3.superkittens.create(:value => "Sneezy")
s3.superkittens.create(:value => "Sleepy")
+
+p1.custom_things.create([{:value => [1,2]}, {:value => []}, {:value => [78]}])
# }}}
# Product {{{
@@ -115,6 +117,4 @@
necklace1.sections << jewelry
necklace1.sections << accessories
necklace1.save
-
-p1.custom_things.create [{:value => [1,2]}, {:value => []},{ :value => [78]}]
# }}}
View
@@ -74,17 +74,8 @@ class Post < ActiveRecord::Base
class CustomThing < ActiveRecord::Base
belongs_to :post
- class ArrayPack
- def load(str)
- str.split(',')
- end
-
- def dump(int_array)
- int_array.join(',')
- end
- end
- serialize :value, ArrayPack.new
+ serialize :value
end
class Account < ActiveRecord::Base

0 comments on commit 0aa2359

Please sign in to comment.