aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-03-30 05:07:07 +0900
committerGitHub <noreply@github.com>2019-03-30 05:07:07 +0900
commit406d3a926cfcd3724f8002f70346aad95eed4a8c (patch)
tree904c27fe5180b587847ebbe1832d1e165202ef4f /activerecord
parent7f11fe4570679375c4a4e3c1d712589928440d10 (diff)
parent2d12f800f1c6b0a2018346e0139301070273e46f (diff)
downloadrails-406d3a926cfcd3724f8002f70346aad95eed4a8c.tar.gz
rails-406d3a926cfcd3724f8002f70346aad95eed4a8c.tar.bz2
rails-406d3a926cfcd3724f8002f70346aad95eed4a8c.zip
Merge pull request #35794 from kamipo/type_cast_symbol_false
Type cast falsy boolean symbols on boolean attribute as false
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/boolean_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/boolean_test.rb b/activerecord/test/cases/boolean_test.rb
index ab9f974e2c..18824004d2 100644
--- a/activerecord/test/cases/boolean_test.rb
+++ b/activerecord/test/cases/boolean_test.rb
@@ -40,4 +40,13 @@ class BooleanTest < ActiveRecord::TestCase
assert_equal b_false, Boolean.find_by(value: "false")
assert_equal b_true, Boolean.find_by(value: "true")
end
+
+ def test_find_by_falsy_boolean_symbol
+ ActiveModel::Type::Boolean::FALSE_VALUES.each do |value|
+ b_false = Boolean.create!(value: value)
+
+ assert_not_predicate b_false, :value?
+ assert_equal b_false, Boolean.find_by(id: b_false.id, value: value.to_s.to_sym)
+ end
+ end
end