aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG.md2
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb40
2 files changed, 21 insertions, 21 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index a318cd3661..2d260f2bf5 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,6 +1,6 @@
* Fix query attribute method on user-defined attribute to be aware of typecasted value.
- For example the following code no longer return false as casted non-empty string.
+ For example, the following code no longer return false as casted non-empty string:
```
class Post < ActiveRecord::Base
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index b7519bab81..f51c87ef2b 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -439,22 +439,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase
end
end
- test "user defined text attribute predicate" do
- klass = Class.new(ActiveRecord::Base) do
- self.table_name = Topic.table_name
-
- attribute :user_defined_text, :text
- end
-
- topic = klass.new(user_defined_text: "text")
- assert_predicate topic, :user_defined_text?
-
- ActiveModel::Type::Boolean::FALSE_VALUES.each do |value|
- topic = klass.new(user_defined_text: value)
- assert_predicate topic, :user_defined_text?
- end
- end
-
test "number attribute predicate" do
[nil, 0, "0"].each do |value|
assert_equal false, Developer.new(salary: value).salary?
@@ -474,7 +458,23 @@ class AttributeMethodsTest < ActiveRecord::TestCase
end
end
- test "user defined date attribute predicate" do
+ test "user-defined text attribute predicate" do
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = Topic.table_name
+
+ attribute :user_defined_text, :text
+ end
+
+ topic = klass.new(user_defined_text: "text")
+ assert_predicate topic, :user_defined_text?
+
+ ActiveModel::Type::Boolean::FALSE_VALUES.each do |value|
+ topic = klass.new(user_defined_text: value)
+ assert_predicate topic, :user_defined_text?
+ end
+ end
+
+ test "user-defined date attribute predicate" do
klass = Class.new(ActiveRecord::Base) do
self.table_name = Topic.table_name
@@ -485,7 +485,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_predicate topic, :user_defined_date?
end
- test "user defined datetime attribute predicate" do
+ test "user-defined datetime attribute predicate" do
klass = Class.new(ActiveRecord::Base) do
self.table_name = Topic.table_name
@@ -496,7 +496,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_predicate topic, :user_defined_datetime?
end
- test "user defined time attribute predicate" do
+ test "user-defined time attribute predicate" do
klass = Class.new(ActiveRecord::Base) do
self.table_name = Topic.table_name
@@ -507,7 +507,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_predicate topic, :user_defined_time?
end
- test "user defined json attribute predicate" do
+ test "user-defined json attribute predicate" do
klass = Class.new(ActiveRecord::Base) do
self.table_name = Topic.table_name