From bc769581c20e5634debd18a9f6abfadb778e1ac6 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 9 Jun 2014 08:27:23 -0600 Subject: Remove workaround for non-lazy serialize in tests `serialize` is now lazy, so the workaround is no longer needed. --- .../test/cases/adapters/postgresql/hstore_test.rb | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'activerecord/test/cases/adapters/postgresql') diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb index a6482786c7..fa37f3d7cc 100644 --- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb +++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb @@ -295,24 +295,18 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase assert_equal({ }, hstore.reload.tags) end - # FIXME: remove this lambda once `serialize` no longer issues a db connection. - LAZY_MODELS = lambda do - return if defined?(TagCollection) - - class TagCollection - def initialize(hash); @hash = hash end - def to_hash; @hash end - def self.load(hash); new(hash) end - def self.dump(object); object.to_hash end - end + class TagCollection + def initialize(hash); @hash = hash end + def to_hash; @hash end + def self.load(hash); new(hash) end + def self.dump(object); object.to_hash end + end - class HstoreWithSerialize < Hstore - serialize :tags, TagCollection - end + class HstoreWithSerialize < Hstore + serialize :tags, TagCollection end def test_hstore_with_serialized_attributes - LAZY_MODELS.call HstoreWithSerialize.create! tags: TagCollection.new({"one" => "two"}) record = HstoreWithSerialize.first assert_instance_of TagCollection, record.tags @@ -323,7 +317,6 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase end def test_clone_hstore_with_serialized_attributes - LAZY_MODELS.call HstoreWithSerialize.create! tags: TagCollection.new({"one" => "two"}) record = HstoreWithSerialize.first dupe = record.dup -- cgit v1.2.3