Skip to content

Commit 276b5e9

Browse files
authored
Merge pull request rails#54615 from yahonda/assert_nil_if_expecting_nil_is_deprecated
Enable `Minitest/AssertNil` cop to address `DEPRECATED: Use assert_nil if expecting nil` warning
2 parents 7c7500f + e53bbb4 commit 276b5e9

File tree

7 files changed

+11
-8
lines changed

7 files changed

+11
-8
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ Performance/RedundantStringChars:
384384
Performance/StringInclude:
385385
Enabled: true
386386

387+
Minitest/AssertNil:
388+
Enabled: true
389+
387390
Minitest/AssertPredicate:
388391
Enabled: true
389392

actionpack/test/controller/integration_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def test_post_then_get_with_parameters_do_not_leak_across_requests
495495
assert_equal "foo=bar", request.env["QUERY_STRING"]
496496
assert_equal "foo=bar", request.query_string
497497
assert_equal "bar", request.parameters["foo"]
498-
assert_predicate request.parameters["leaks"], :nil?
498+
assert_nil request.parameters["leaks"]
499499
end
500500
end
501501

actiontext/test/unit/model_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ActionText::ModelTest < ActiveSupport::TestCase
1818
test "without content" do
1919
assert_difference("ActionText::RichText.count" => 0) do
2020
message = Message.create!(subject: "Greetings")
21-
assert_predicate message.content, :nil?
21+
assert_nil message.content
2222
assert_predicate message.content, :blank?
2323
assert_predicate message.content, :empty?
2424
assert_not message.content?
@@ -146,7 +146,7 @@ class ActionText::ModelTest < ActiveSupport::TestCase
146146
test "with blank content and store_if_blank: false" do
147147
assert_difference("ActionText::RichText.count" => 0) do
148148
message = MessageWithoutBlanks.create!(subject: "Greetings", content: "")
149-
assert_predicate message.content, :nil?
149+
assert_nil message.content
150150
assert_predicate message.content, :blank?
151151
assert_predicate message.content, :empty?
152152
assert_not message.content?

activemodel/test/cases/type/boolean_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module Type
77
class BooleanTest < ActiveModel::TestCase
88
def test_type_cast_boolean
99
type = Type::Boolean.new
10-
assert_predicate type.cast(""), :nil?
11-
assert_predicate type.cast(nil), :nil?
10+
assert_nil type.cast("")
11+
assert_nil type.cast(nil)
1212

1313
assert type.cast(true)
1414
assert type.cast(1)

activemodel/test/cases/validations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def test_validation_with_if_and_on
252252

253253
# If block should not fire
254254
assert_predicate t, :valid?
255-
assert_predicate t.author_name, :nil?
255+
assert_nil t.author_name
256256

257257
# If block should fire
258258
assert t.invalid?(:update)

activerecord/test/cases/associations/has_many_through_associations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ def test_deleting_from_has_many_through_a_belongs_to_should_not_try_to_update_co
12431243

12441244
assert_includes post.author_addresses, address
12451245
post.author_addresses.delete(address)
1246-
assert_predicate post[:author_count], :nil?
1246+
assert_nil post[:author_count]
12471247
end
12481248

12491249
def test_primary_key_option_on_source

railties/test/application/configuration_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4028,7 +4028,7 @@ class Post < ActiveRecord::Base
40284028

40294029
app "development"
40304030

4031-
assert_equal nil, ActiveStorage.variant_processor
4031+
assert_nil ActiveStorage.variant_processor
40324032
end
40334033

40344034
test "ActiveStorage.variant_processor uses vips by default" do

0 commit comments

Comments
 (0)