aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-02-19 21:01:10 +0000
committerMichael Koziarski <michael@koziarski.com>2008-02-19 21:01:10 +0000
commite32149ad600796efcf7191eff0946ca9616c4d65 (patch)
tree467bc046511d3f3bd05d5c7d059182f9e60c5719 /activerecord
parentec98a720eced989e7af2848edfd512db53e52f0c (diff)
downloadrails-e32149ad600796efcf7191eff0946ca9616c4d65.tar.gz
rails-e32149ad600796efcf7191eff0946ca9616c4d65.tar.bz2
rails-e32149ad600796efcf7191eff0946ca9616c4d65.zip
Correct typo in before_type_cast code. Closes #11165 [amishyn]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8898 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
-rwxr-xr-xactiverecord/test/cases/base_test.rb18
2 files changed, 18 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index a25d9789d7..4f33b96034 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2223,7 +2223,7 @@ module ActiveRecord #:nodoc:
# Returns a hash of attributes before typecasting and deserialization.
def attributes_before_type_cast
self.attribute_names.inject({}) do |attrs, name|
- attrs[name] = read_attribute_before_typecast(name)
+ attrs[name] = read_attribute_before_type_cast(name)
attrs
end
end
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 4cba4a3ec6..46982712ca 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -125,6 +125,22 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal(%w( one two three ), Topic.find(topic.id).content)
end
+ def test_read_attributes_before_type_cast
+ category = Category.new({:name=>"Test categoty", :type => nil})
+ category_attrs = {"name"=>"Test categoty", "type" => nil}
+ assert_equal category_attrs , category.attributes_before_type_cast
+ end
+
+ def test_read_attributes_before_type_cast_on_boolean
+ bool = Booleantest.create({ "value" => false })
+ assert_equal 0 , bool.attributes_before_type_cast["value"]
+ end
+
+ def test_read_attributes_before_type_cast_on_datetime
+ developer = Developer.find(:first)
+ assert_equal developer.created_at.to_s(:db) , developer.attributes_before_type_cast["created_at"]
+ end
+
def test_hash_content
topic = Topic.new
topic.content = { "one" => 1, "two" => 2 }
@@ -877,7 +893,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_readonly_attributes
- assert_equal Set.new([ 'title', 'comments_count' ]), ReadonlyTitlePost.readonly_attributes
+ assert_equal Set.new([ 'title' , 'comments_count' ]), ReadonlyTitlePost.readonly_attributes
post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable")
post.reload