diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-12-29 16:15:45 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-12-29 16:15:45 +0000 |
commit | fd1cf13f743ac7ba71f19dff6d8e22f5ac7bc603 (patch) | |
tree | 472197685764aa5bdcaa935495915619452729d1 /activerecord/test | |
parent | 83e1938916d1d6bc63d3c8031da29d973ec6f41e (diff) | |
download | rails-fd1cf13f743ac7ba71f19dff6d8e22f5ac7bc603.tar.gz rails-fd1cf13f743ac7ba71f19dff6d8e22f5ac7bc603.tar.bz2 rails-fd1cf13f743ac7ba71f19dff6d8e22f5ac7bc603.zip |
Make serialized fixtures work again
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/fixtures_test.rb | 7 | ||||
-rw-r--r-- | activerecord/test/cases/quoting_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/fixtures/traffic_lights.yml | 6 | ||||
-rw-r--r-- | activerecord/test/models/traffic_light.rb | 3 |
5 files changed, 18 insertions, 4 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 09ef04a656..594f3b80c6 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -703,7 +703,7 @@ class BasicsTest < ActiveRecord::TestCase duped_topic.reload # FIXME: I think this is poor behavior, and will fix it with #5686 - assert_equal({'a' => 'c'}.to_s, duped_topic.title) + assert_equal({'a' => 'c'}.to_yaml, duped_topic.title) end def test_dup_with_aggregate_of_same_name_as_attribute diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 9ce163a00f..864a7a2acc 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -13,6 +13,7 @@ require 'models/category' require 'models/parrot' require 'models/pirate' require 'models/treasure' +require 'models/traffic_light' require 'models/matey' require 'models/ship' require 'models/book' @@ -24,7 +25,7 @@ class FixturesTest < ActiveRecord::TestCase self.use_instantiated_fixtures = true self.use_transactional_fixtures = false - fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries + fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries, :traffic_lights FIXTURES = %w( accounts binaries companies customers developers developers_projects entrants @@ -204,6 +205,10 @@ class FixturesTest < ActiveRecord::TestCase data.freeze assert_equal data, @flowers.data end + + def test_serialized_fixtures + assert_equal ["Green", "Red", "Orange"], traffic_lights(:uk).state + end end if Account.connection.respond_to?(:reset_pk_sequence!) diff --git a/activerecord/test/cases/quoting_test.rb b/activerecord/test/cases/quoting_test.rb index 2ef5b5a800..b87fb51d97 100644 --- a/activerecord/test/cases/quoting_test.rb +++ b/activerecord/test/cases/quoting_test.rb @@ -154,13 +154,13 @@ module ActiveRecord end def test_crazy_object - crazy = Class.new { def to_s; 'lol' end }.new + crazy = Class.new { def to_yaml; 'lol' end }.new assert_equal "'lol'", @quoter.quote(crazy, nil) assert_equal "'lol'", @quoter.quote(crazy, Object.new) end def test_crazy_object_calls_quote_string - crazy = Class.new { def to_s; 'lo\l' end }.new + crazy = Class.new { def to_yaml; 'lo\l' end }.new assert_equal "'lo\\\\l'", @quoter.quote(crazy, nil) assert_equal "'lo\\\\l'", @quoter.quote(crazy, Object.new) end diff --git a/activerecord/test/fixtures/traffic_lights.yml b/activerecord/test/fixtures/traffic_lights.yml new file mode 100644 index 0000000000..6dabd53474 --- /dev/null +++ b/activerecord/test/fixtures/traffic_lights.yml @@ -0,0 +1,6 @@ +uk: + location: UK + state: + - Green + - Red + - Orange diff --git a/activerecord/test/models/traffic_light.rb b/activerecord/test/models/traffic_light.rb new file mode 100644 index 0000000000..228f3f7bd4 --- /dev/null +++ b/activerecord/test/models/traffic_light.rb @@ -0,0 +1,3 @@ +class TrafficLight < ActiveRecord::Base + serialize :state, Array +end |