aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-09 13:50:08 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-09 13:50:08 -0800
commite0cba3a0fab28f96dc9b5d3a714886583873a7d3 (patch)
tree8712fd8f0b53b7916ae8549decb86928302f00dc /activerecord/test/cases/base_test.rb
parent6c50c07d8dbb0b014e68608fe72f807cbe7f5c45 (diff)
parente6c98b83cbf4eab8944601754cc8d0e627b55d6f (diff)
downloadrails-e0cba3a0fab28f96dc9b5d3a714886583873a7d3.tar.gz
rails-e0cba3a0fab28f96dc9b5d3a714886583873a7d3.tar.bz2
rails-e0cba3a0fab28f96dc9b5d3a714886583873a7d3.zip
Merge branch 'master' into instance_reader
* master: (30 commits) Bump tzinfo. 0.3.31 was released on November 6, 2011. Fix GH #4909. Dependency on TZInfo move from AR to AS. moving ordered hash to normal hash because ruby 1.9.3 hash defaultly ordered one Refactored the OrderedHash related stuff Replaced OrderedHash usage with Ruby 1.9 Hash Replaced OrderedHash with Hash for ruby 1.9 series removed unnecessary code replacing the orderhash with hash for ruby-1.9 Clean up some wording. Fix typo. test title changed corresponding to the test replaced active support ordered hash to ruby hash on active resource PostgreSQL does not work in the same way of the other adapters AR::Relation#pluck: improve to work with joins Fix match docs Fix attribute_before_type_cast for serialized attributes. Fixes #4837. Fix failing request test Fixes in AMo README Update README to mention lint. Trim down Active Model API by removing valid? and errors.full_messages ...
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rw-r--r--activerecord/test/cases/base_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index acc0f272c1..698c3d0cb1 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1281,6 +1281,21 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal(hash, important_topic.content)
end
+ # This test was added to fix GH #4004. Obviously the value returned
+ # is not really the value 'before type cast' so we should maybe think
+ # about changing that in the future.
+ def test_serialized_attribute_before_type_cast_returns_unserialized_value
+ klass = Class.new(ActiveRecord::Base)
+ klass.table_name = "topics"
+ klass.serialize :content, Hash
+
+ t = klass.new(:content => { :foo => :bar })
+ assert_equal({ :foo => :bar }, t.content_before_type_cast)
+ t.save!
+ t.reload
+ assert_equal({ :foo => :bar }, t.content_before_type_cast)
+ end
+
def test_serialized_attribute_declared_in_subclass
hash = { 'important1' => 'value1', 'important2' => 'value2' }
important_topic = ImportantTopic.create("important" => hash)