Permalink
Browse files

Test for #5549.

Cherry-picked from e96d04a.

Conflicts:

	activerecord/lib/active_record/attribute_methods/read.rb
  • Loading branch information...
1 parent 0d052c0 commit 4c44ca5cb9544b4186a0c9d54a7bfc9d30896f62 @tenderlove tenderlove committed with jonleighton Mar 27, 2012
Showing with 16 additions and 1 deletion.
  1. +15 −1 activerecord/test/cases/base_test.rb
  2. +1 −0 activerecord/test/schema/schema.rb
@@ -61,7 +61,11 @@ class ProtectedTitlePost < Post
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 @@ def test_boolean
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
@@ -90,6 +90,7 @@ def create_table(*args, &block)
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|

0 comments on commit 4c44ca5

Please sign in to comment.