aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-03-27 11:27:51 -0700
committerJon Leighton <j@jonathanleighton.com>2012-03-28 15:31:32 +0100
commit4c44ca5cb9544b4186a0c9d54a7bfc9d30896f62 (patch)
tree96603224f0e6089df233bb7da55d44a556e4006a /activerecord/test
parent0d052c0e399c179cd918c9fbad512775387e20c7 (diff)
downloadrails-4c44ca5cb9544b4186a0c9d54a7bfc9d30896f62.tar.gz
rails-4c44ca5cb9544b4186a0c9d54a7bfc9d30896f62.tar.bz2
rails-4c44ca5cb9544b4186a0c9d54a7bfc9d30896f62.zip
Test for #5549.
Cherry-picked from e96d04a2e4e244ea5053cb4e8ab97db604d0c796. Conflicts: activerecord/lib/active_record/attribute_methods/read.rb
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/base_test.rb16
-rw-r--r--activerecord/test/schema/schema.rb1
2 files changed, 16 insertions, 1 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index aeb44da2b2..300a3636e3 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -61,7 +61,11 @@ end
class Weird < ActiveRecord::Base; end
-class Boolean < ActiveRecord::Base; end
+class Boolean < ActiveRecord::Base
+ def has_fun
+ super
+ end
+end
class LintTest < ActiveRecord::TestCase
include ActiveModel::Lint::Tests
@@ -930,6 +934,16 @@ class BasicsTest < ActiveRecord::TestCase
assert b_true.value?
end
+ def test_boolean_without_questionmark
+ b_true = Boolean.create({ "value" => true })
+ true_id = b_true.id
+
+ subclass = Class.new(Boolean).find true_id
+ superclass = Boolean.find true_id
+
+ assert_equal superclass.read_attribute(:has_fun), subclass.read_attribute(:has_fun)
+ end
+
def test_boolean_cast_from_string
b_blank = Boolean.create({ "value" => "" })
blank_id = b_blank.id
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index fb4ea4223d..7028b7fd1b 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -90,6 +90,7 @@ ActiveRecord::Schema.define do
create_table :booleans, :force => true do |t|
t.boolean :value
+ t.boolean :has_fun, :null => false, :default => false
end
create_table :bulbs, :force => true do |t|