1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

"Use assert_nil if expecting nil. This will fail in minitest 6."

This commit is contained in:
Akira Matsuda 2016-12-25 02:29:52 +09:00
parent 9d9a4bd7cf
commit e8ba0c0f21
69 changed files with 196 additions and 196 deletions

View file

@ -289,7 +289,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
assert_response :success
assert_equal "bar", body
assert_equal nil, headers["Set-Cookie"]
assert_nil headers["Set-Cookie"]
assert_equal({ "foo" => "bar" }, cookies.to_hash)
end
end
@ -308,7 +308,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
assert_response :success
assert_equal "bar", body
assert_equal nil, headers["Set-Cookie"]
assert_nil headers["Set-Cookie"]
assert_equal({ "foo" => "bar" }, cookies.to_hash)
end
end

View file

@ -52,7 +52,7 @@ module BareMetalTest
controller.set_request!(ActionDispatch::Request.empty)
controller.set_response!(BareController.make_response!(controller.request))
controller.index
assert_equal nil, controller.response_body
assert_nil controller.response_body
end
end

View file

@ -101,12 +101,12 @@ module RenderStreaming
assert_body "Hello world, I'm here!"
assert_status 200
assert_equal "22", headers["Content-Length"]
assert_equal nil, headers["Transfer-Encoding"]
assert_nil headers["Transfer-Encoding"]
end
def assert_streaming!(cache = "no-cache")
assert_status 200
assert_equal nil, headers["Content-Length"]
assert_nil headers["Content-Length"]
assert_equal "chunked", headers["Transfer-Encoding"]
assert_equal cache, headers["Cache-Control"]
end

View file

@ -141,7 +141,7 @@ class ParametersPermitTest < ActiveSupport::TestCase
permitted = params.permit(:a, c: [], b: [])
assert_equal 1, permitted[:a]
assert_equal [1, 2, 3], permitted[:b]
assert_equal nil, permitted[:c]
assert_nil permitted[:c]
end
test "key to empty array: arrays of permitted scalars pass" do
@ -216,7 +216,7 @@ class ParametersPermitTest < ActiveSupport::TestCase
test "fetch with a default value of a hash does not mutate the object" do
params = ActionController::Parameters.new({})
params.fetch :foo, {}
assert_equal nil, params[:foo]
assert_nil params[:foo]
end
test "hashes in array values get wrapped" do
@ -254,8 +254,8 @@ class ParametersPermitTest < ActiveSupport::TestCase
end
test "fetch doesnt raise ParameterMissing exception if there is a default that is nil" do
assert_equal nil, @params.fetch(:foo, nil)
assert_equal nil, @params.fetch(:foo) { nil }
assert_nil @params.fetch(:foo, nil)
assert_nil @params.fetch(:foo) { nil }
end
test "KeyError in fetch block should not be covered up" do

View file

@ -8,7 +8,7 @@ class ActionController::TestRequestTest < ActionController::TestCase
def test_mutating_session_options_does_not_affect_default_options
@request.session_options[:myparam] = 123
assert_equal nil, ActionController::TestSession::DEFAULT_OPTIONS[:myparam]
assert_nil ActionController::TestSession::DEFAULT_OPTIONS[:myparam]
end
def test_content_length_has_bytes_count_value

View file

@ -944,8 +944,8 @@ class CookiesTest < ActionController::TestCase
@request.headers["Cookie"] = "user_id=45"
get :get_signed_cookie
assert_equal nil, @controller.send(:cookies).signed[:user_id]
assert_equal nil, @response.cookies["user_id"]
assert_nil @controller.send(:cookies).signed[:user_id]
assert_nil @response.cookies["user_id"]
end
def test_legacy_signed_cookie_is_treated_as_nil_by_encrypted_cookie_jar_if_tampered
@ -955,8 +955,8 @@ class CookiesTest < ActionController::TestCase
@request.headers["Cookie"] = "foo=baz"
get :get_encrypted_cookie
assert_equal nil, @controller.send(:cookies).encrypted[:foo]
assert_equal nil, @response.cookies["foo"]
assert_nil @controller.send(:cookies).encrypted[:foo]
assert_nil @response.cookies["foo"]
end
def test_cookie_with_all_domain_option

View file

@ -129,7 +129,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest
params = parse_multipart("none")
assert_equal %w(submit-name), params.keys.sort
assert_equal "Larry", params["submit-name"]
assert_equal nil, params["files"]
assert_nil params["files"]
end
test "parses empty upload file" do

View file

@ -94,13 +94,13 @@ class RequestIP < BaseRequestTest
assert_equal "3.4.5.6", request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "unknown,192.168.0.1"
assert_equal nil, request.remote_ip
assert_nil request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "9.9.9.9, 3.4.5.6, 172.31.4.4, 10.0.0.1"
assert_equal "3.4.5.6", request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "not_ip_address"
assert_equal nil, request.remote_ip
assert_nil request.remote_ip
end
test "remote ip spoof detection" do
@ -154,7 +154,7 @@ class RequestIP < BaseRequestTest
assert_equal "fe80:0000:0000:0000:0202:b3ff:fe1e:8329", request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "unknown,::1"
assert_equal nil, request.remote_ip
assert_nil request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "2001:0db8:85a3:0000:0000:8a2e:0370:7334, fe80:0000:0000:0000:0202:b3ff:fe1e:8329, ::1, fc00::, fc01::, fdff"
assert_equal "fe80:0000:0000:0000:0202:b3ff:fe1e:8329", request.remote_ip
@ -163,7 +163,7 @@ class RequestIP < BaseRequestTest
assert_equal "FE00::", request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "not_ip_address"
assert_equal nil, request.remote_ip
assert_nil request.remote_ip
end
test "remote ip v6 spoof detection" do
@ -200,7 +200,7 @@ class RequestIP < BaseRequestTest
assert_equal "3.4.5.6", request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "67.205.106.73,unknown"
assert_equal nil, request.remote_ip
assert_nil request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "9.9.9.9, 3.4.5.6, 10.0.0.1, 67.205.106.73"
assert_equal "3.4.5.6", request.remote_ip
@ -222,7 +222,7 @@ class RequestIP < BaseRequestTest
assert_equal "::1", request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "unknown,fe80:0000:0000:0000:0202:b3ff:fe1e:8329"
assert_equal nil, request.remote_ip
assert_nil request.remote_ip
request = stub_request "HTTP_X_FORWARDED_FOR" => "fe80:0000:0000:0000:0202:b3ff:fe1e:8329,2001:0db8:85a3:0000:0000:8a2e:0370:7334"
assert_equal "2001:0db8:85a3:0000:0000:8a2e:0370:7334", request.remote_ip
@ -345,7 +345,7 @@ class RequestPort < BaseRequestTest
test "optional port" do
request = stub_request "HTTP_HOST" => "www.example.org:80"
assert_equal nil, request.optional_port
assert_nil request.optional_port
request = stub_request "HTTP_HOST" => "www.example.org:8080"
assert_equal 8080, request.optional_port
@ -537,7 +537,7 @@ class RequestCGI < BaseRequestTest
assert_equal "Basic", request.auth_type
assert_equal 0, request.content_length
assert_equal nil, request.content_mime_type
assert_nil request.content_mime_type
assert_equal "CGI/1.1", request.gateway_interface
assert_equal "*/*", request.accept
assert_equal "UTF-8", request.accept_charset
@ -957,7 +957,7 @@ class RequestMimeType < BaseRequestTest
end
test "no content type" do
assert_equal nil, stub_request.content_mime_type
assert_nil stub_request.content_mime_type
end
test "content type is XML" do
@ -978,7 +978,7 @@ class RequestMimeType < BaseRequestTest
"HTTP_X_REQUESTED_WITH" => "XMLHttpRequest"
)
assert_equal nil, request.negotiate_mime([Mime[:xml], Mime[:json]])
assert_nil request.negotiate_mime([Mime[:xml], Mime[:json]])
assert_equal Mime[:html], request.negotiate_mime([Mime[:xml], Mime[:html]])
assert_equal Mime[:html], request.negotiate_mime([Mime[:xml], Mime::ALL])
end
@ -1192,7 +1192,7 @@ class RequestEtag < BaseRequestTest
test "doesn't match absent If-None-Match" do
request = stub_request
assert_equal nil, request.if_none_match
assert_nil request.if_none_match
assert_equal [], request.if_none_match_etags
assert_not request.etag_matches?("foo")

View file

@ -74,7 +74,7 @@ class ResponseTest < ActiveSupport::TestCase
@response.body = "Hello, World!"
# even though there's no explicitly set content-type,
assert_equal nil, @response.content_type
assert_nil @response.content_type
# after the action reads back @response.body,
assert_equal "Hello, World!", @response.body
@ -112,7 +112,7 @@ class ResponseTest < ActiveSupport::TestCase
def test_empty_content_type_returns_nil
@response.headers['Content-Type'] = ""
assert_equal nil, @response.content_type
assert_nil @response.content_type
end
test "simple output" do

View file

@ -4189,7 +4189,7 @@ class TestConstraintsAccessingParameters < ActionDispatch::IntegrationTest
test "parameters are reset between constraint checks" do
get "/bar"
assert_equal nil, @request.params[:foo]
assert_nil @request.params[:foo]
assert_equal "bar", @request.params[:bar]
end
end

View file

@ -142,20 +142,20 @@ class CacheStoreTest < ActionDispatch::IntegrationTest
get "/get_session_value"
assert_response :success
assert_equal nil, headers["Set-Cookie"], "should not resend the cookie again if session_id cookie is already exists"
assert_nil headers["Set-Cookie"], "should not resend the cookie again if session_id cookie is already exists"
end
end
def test_prevents_session_fixation
with_test_route_set do
assert_equal nil, @cache.read("_session_id:0xhax")
assert_nil @cache.read("_session_id:0xhax")
cookies["_session_id"] = "0xhax"
get "/set_session_value"
assert_response :success
assert_not_equal "0xhax", cookies["_session_id"]
assert_equal nil, @cache.read("_session_id:0xhax")
assert_nil @cache.read("_session_id:0xhax")
assert_equal({ "foo" => "bar" }, @cache.read("_session_id:#{cookies['_session_id']}"))
end
end

View file

@ -108,7 +108,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
with_test_route_set(secure: true) do
get "/set_session_value"
assert_response :success
assert_equal nil, headers["Set-Cookie"]
assert_nil headers["Set-Cookie"]
end
end
@ -169,7 +169,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
with_test_route_set do
get "/no_session_access"
assert_response :success
assert_equal nil, headers["Set-Cookie"]
assert_nil headers["Set-Cookie"]
end
end
@ -179,7 +179,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
"fef868465920f415f2c0652d6910d3af288a0367"
get "/no_session_access"
assert_response :success
assert_equal nil, headers["Set-Cookie"]
assert_nil headers["Set-Cookie"]
end
end

View file

@ -157,7 +157,7 @@ class MemCacheStoreTest < ActionDispatch::IntegrationTest
get "/get_session_value"
assert_response :success
assert_equal nil, headers["Set-Cookie"], "should not resend the cookie again if session_id cookie is already exists"
assert_nil headers["Set-Cookie"], "should not resend the cookie again if session_id cookie is already exists"
end
rescue Dalli::RingError => ex
skip ex.message, ex.backtrace

View file

@ -177,9 +177,9 @@ module StaticTests
last_modified = File.mtime(File.join(@root, "#{file_name}.gz"))
response = get(file_name, "HTTP_ACCEPT_ENCODING" => "gzip", "HTTP_IF_MODIFIED_SINCE" => last_modified.httpdate)
assert_equal 304, response.status
assert_equal nil, response.headers["Content-Type"]
assert_equal nil, response.headers["Content-Encoding"]
assert_equal nil, response.headers["Vary"]
assert_nil response.headers["Content-Type"]
assert_nil response.headers["Content-Encoding"]
assert_nil response.headers["Vary"]
end
def test_serves_files_with_headers

View file

@ -30,7 +30,7 @@ class TestRequestTest < ActiveSupport::TestCase
req = ActionDispatch::TestRequest.create({})
assert_equal({}, req.cookies)
assert_equal nil, req.env["HTTP_COOKIE"]
assert_nil req.env["HTTP_COOKIE"]
req.cookie_jar["user_name"] = "david"
assert_cookies({ "user_name" => "david" }, req.cookie_jar)

View file

@ -630,7 +630,7 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase
end
def test_should_return_nothing_if_asset_host_isnt_configured
assert_equal nil, compute_asset_host("foo")
assert_nil compute_asset_host("foo")
end
def test_should_current_request_host_is_always_returned_for_request

View file

@ -127,18 +127,18 @@ class CaptureHelperTest < ActionView::TestCase
def test_content_for_returns_nil_when_writing
assert ! content_for?(:title)
assert_equal nil, content_for(:title, "foo")
assert_equal nil, content_for(:title) { output_buffer << "bar"; nil }
assert_equal nil, content_for(:title) { output_buffer << " \n "; nil }
assert_nil content_for(:title, "foo")
assert_nil content_for(:title) { output_buffer << "bar"; nil }
assert_nil content_for(:title) { output_buffer << " \n "; nil }
assert_equal "foobar", content_for(:title)
assert_equal nil, content_for(:title, "foo", flush: true)
assert_equal nil, content_for(:title, flush: true) { output_buffer << "bar"; nil }
assert_equal nil, content_for(:title, flush: true) { output_buffer << " \n "; nil }
assert_nil content_for(:title, "foo", flush: true)
assert_nil content_for(:title, flush: true) { output_buffer << "bar"; nil }
assert_nil content_for(:title, flush: true) { output_buffer << " \n "; nil }
assert_equal "bar", content_for(:title)
end
def test_content_for_returns_nil_when_content_missing
assert_equal nil, content_for(:some_missing_key)
assert_nil content_for(:some_missing_key)
end
def test_content_for_question_mark

View file

@ -4,7 +4,7 @@ class NumberHelperTest < ActionView::TestCase
tests ActionView::Helpers::NumberHelper
def test_number_to_phone
assert_equal nil, number_to_phone(nil)
assert_nil number_to_phone(nil)
assert_equal "555-1234", number_to_phone(5551234)
assert_equal "(800) 555-1212 x 123", number_to_phone(8005551212, area_code: true, extension: 123)
assert_equal "+18005551212", number_to_phone(8005551212, country_code: 1, delimiter: "")
@ -13,7 +13,7 @@ class NumberHelperTest < ActionView::TestCase
end
def test_number_to_currency
assert_equal nil, number_to_currency(nil)
assert_nil number_to_currency(nil)
assert_equal "$1,234,567,890.50", number_to_currency(1234567890.50)
assert_equal "$1,234,567,892", number_to_currency(1234567891.50, precision: 0)
assert_equal "1,234,567,890.50 - K&#269;", number_to_currency("-1234567890.50", unit: raw("K&#269;"), format: "%n %u", negative_format: "%n - %u")
@ -25,7 +25,7 @@ class NumberHelperTest < ActionView::TestCase
end
def test_number_to_percentage
assert_equal nil, number_to_percentage(nil)
assert_nil number_to_percentage(nil)
assert_equal "100.000%", number_to_percentage(100)
assert_equal "100.000 %", number_to_percentage(100, format: "%n %")
assert_equal "&lt;b&gt;100.000&lt;/b&gt; %", number_to_percentage(100, format: "<b>%n</b> %")
@ -43,13 +43,13 @@ class NumberHelperTest < ActionView::TestCase
end
def test_number_with_delimiter
assert_equal nil, number_with_delimiter(nil)
assert_nil number_with_delimiter(nil)
assert_equal "12,345,678", number_with_delimiter(12345678)
assert_equal "0", number_with_delimiter(0)
end
def test_number_with_precision
assert_equal nil, number_with_precision(nil)
assert_nil number_with_precision(nil)
assert_equal "-111.235", number_with_precision(-111.2346)
assert_equal "111.00", number_with_precision(111, precision: 2)
assert_equal "0.00100", number_with_precision(0.001, precision: 5)
@ -57,13 +57,13 @@ class NumberHelperTest < ActionView::TestCase
end
def test_number_to_human_size
assert_equal nil, number_to_human_size(nil)
assert_nil number_to_human_size(nil)
assert_equal "3 Bytes", number_to_human_size(3.14159265)
assert_equal "1.2 MB", number_to_human_size(1234567, precision: 2)
end
def test_number_to_human
assert_equal nil, number_to_human(nil)
assert_nil number_to_human(nil)
assert_equal "0", number_to_human(0)
assert_equal "1.23 Thousand", number_to_human(1234)
assert_equal "489.0 Thousand", number_to_human(489000, precision: 4, strip_insignificant_zeros: false)

View file

@ -50,7 +50,7 @@ module ActionView
end
test "retrieve non existing config values" do
assert_equal nil, ActionView::Base.new.config.something_odd
assert_nil ActionView::Base.new.config.something_odd
end
test "works without testing a helper module" do

View file

@ -3,7 +3,7 @@ require "jobs/hello_job"
class QueuePriorityTest < ActiveSupport::TestCase
test "priority unset by default" do
assert_equal nil, HelloJob.priority
assert_nil HelloJob.priority
end
test "uses given priority" do

View file

@ -256,11 +256,11 @@ end
class PerformedJobsTest < ActiveJob::TestCase
def test_performed_enqueue_jobs_with_only_option_doesnt_leak_outside_the_block
assert_equal nil, queue_adapter.filter
assert_nil queue_adapter.filter
perform_enqueued_jobs only: HelloJob do
assert_equal HelloJob, queue_adapter.filter
end
assert_equal nil, queue_adapter.filter
assert_nil queue_adapter.filter
end
def test_assert_performed_jobs

View file

@ -179,7 +179,7 @@ class SecurePasswordTest < ActiveModel::TestCase
test "setting a nil password should clear an existing password" do
@existing_user.password = nil
assert_equal nil, @existing_user.password_digest
assert_nil @existing_user.password_digest
end
test "authenticate" do

View file

@ -6,7 +6,7 @@ module ActiveModel
class BinaryTest < ActiveModel::TestCase
def test_type_cast_binary
type = Type::Binary.new
assert_equal nil, type.cast(nil)
assert_nil type.cast(nil)
assert_equal "1", type.cast("1")
assert_equal 1, type.cast(1)
end

View file

@ -6,10 +6,10 @@ module ActiveModel
class DateTest < ActiveModel::TestCase
def test_type_cast_date
type = Type::Date.new
assert_equal nil, type.cast(nil)
assert_equal nil, type.cast("")
assert_equal nil, type.cast(" ")
assert_equal nil, type.cast("ABC")
assert_nil type.cast(nil)
assert_nil type.cast("")
assert_nil type.cast(" ")
assert_nil type.cast("ABC")
date_string = ::Time.now.utc.strftime("%F")
assert_equal date_string, type.cast(date_string).strftime("%F")

View file

@ -6,10 +6,10 @@ module ActiveModel
class DateTimeTest < ActiveModel::TestCase
def test_type_cast_datetime_and_timestamp
type = Type::DateTime.new
assert_equal nil, type.cast(nil)
assert_equal nil, type.cast("")
assert_equal nil, type.cast(" ")
assert_equal nil, type.cast("ABC")
assert_nil type.cast(nil)
assert_nil type.cast("")
assert_nil type.cast(" ")
assert_nil type.cast("ABC")
datetime_string = ::Time.now.utc.strftime("%FT%T")
assert_equal datetime_string, type.cast(datetime_string).strftime("%FT%T")

View file

@ -6,9 +6,9 @@ module ActiveModel
class TimeTest < ActiveModel::TestCase
def test_type_cast_time
type = Type::Time.new
assert_equal nil, type.cast(nil)
assert_equal nil, type.cast("")
assert_equal nil, type.cast("ABC")
assert_nil type.cast(nil)
assert_nil type.cast("")
assert_nil type.cast("ABC")
time_string = ::Time.now.utc.strftime("%T")
assert_equal time_string, type.cast(time_string).strftime("%T")

View file

@ -96,7 +96,7 @@ class PostgresqlPointTest < ActiveRecord::PostgreSQLTestCase
assert_nothing_raised { PostgresqlPoint.new(x: "") }
p = PostgresqlPoint.new(x: "")
assert_equal nil, p.x
assert_nil p.x
end
def test_array_of_points_round_trip

View file

@ -36,7 +36,7 @@ module ActiveRecord
def test_quote_bit_string
value = "'); SELECT * FROM users; /*\n01\n*/--"
type = OID::Bit.new
assert_equal nil, @conn.quote(type.serialize(value))
assert_nil @conn.quote(type.serialize(value))
end
end
end

View file

@ -56,7 +56,7 @@ class PostgreSQLNameTest < ActiveRecord::PostgreSQLTestCase
test "can be used as hash key" do
hash = { Name.new("schema", "article_seq") => "success" }
assert_equal "success", hash[Name.new("schema", "article_seq")]
assert_equal nil, hash[Name.new("schema", "articles")]
assert_equal nil, hash[Name.new("public", "article_seq")]
assert_nil hash[Name.new("schema", "articles")]
assert_nil hash[Name.new("public", "article_seq")]
end
end

View file

@ -210,7 +210,7 @@ class PostgresqlUUIDGenerationTest < ActiveRecord::PostgreSQLTestCase
def test_pk_and_sequence_for_uuid_primary_key
pk, seq = connection.pk_and_sequence_for("pg_uuids")
assert_equal "id", pk
assert_equal nil, seq
assert_nil seq
end
def test_schema_dumper_for_uuid_primary_key

View file

@ -37,7 +37,7 @@ class SQLite3QuotingTest < ActiveRecord::SQLite3TestCase
end
def test_type_cast_nil
assert_equal nil, @conn.type_cast(nil)
assert_nil @conn.type_cast(nil)
end
def test_type_cast_true

View file

@ -1057,7 +1057,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
comment.parent = nil
comment.save!
assert_equal nil, comment.reload.parent
assert_nil comment.reload.parent
assert_equal 0, comments(:greetings).reload.children_count
end

View file

@ -241,7 +241,7 @@ class EagerAssociationTest < ActiveRecord::TestCase
post = assert_queries(1) { Post.all.merge!(includes: { author_with_address: :author_address }).find(post.id) }
# find the post, then find the author which is null so no query for the author or address
assert_no_queries do
assert_equal nil, post.author_with_address
assert_nil post.author_with_address
end
end
@ -250,7 +250,7 @@ class EagerAssociationTest < ActiveRecord::TestCase
sponsor.update!(sponsorable: nil)
sponsor = assert_queries(1) { Sponsor.all.merge!(includes: :sponsorable).find(sponsor.id) }
assert_no_queries do
assert_equal nil, sponsor.sponsorable
assert_nil sponsor.sponsorable
end
end
@ -261,7 +261,7 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_nothing_raised { Sponsor.all.merge!(includes: :sponsorable).find(sponsor.id) }
end
assert_no_queries do
assert_equal nil, sponsor.sponsorable
assert_nil sponsor.sponsorable
end
end

View file

@ -187,7 +187,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
ship.parts.clear
part.reload
assert_equal nil, part.ship
assert_nil part.ship
assert !part.updated_at_changed?
end

View file

@ -402,7 +402,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
end
assert_equal nil, reference.reload.job_id
assert_nil reference.reload.job_id
ensure
Reference.make_comments = false
end
@ -423,7 +423,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
# Check that the destroy callback on Reference did not run
assert_equal nil, person.reload.comments
assert_nil person.reload.comments
ensure
Reference.make_comments = false
end
@ -485,7 +485,7 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
end
references.each do |reference|
assert_equal nil, reference.reload.job_id
assert_nil reference.reload.job_id
end
end

View file

@ -82,7 +82,7 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
def test_set_record_to_nil_should_delete_association
@member.club = nil
@member.reload
assert_equal nil, @member.current_membership
assert_nil @member.current_membership
assert_nil @member.club
end
@ -110,12 +110,12 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
# conditions on the through table
assert_equal clubs(:moustache_club), Member.all.merge!(includes: :favourite_club).find(@member.id).favourite_club
memberships(:membership_of_favourite_club).update_columns(favourite: false)
assert_equal nil, Member.all.merge!(includes: :favourite_club).find(@member.id).reload.favourite_club
assert_nil Member.all.merge!(includes: :favourite_club).find(@member.id).reload.favourite_club
# conditions on the source table
assert_equal clubs(:moustache_club), Member.all.merge!(includes: :hairy_club).find(@member.id).hairy_club
clubs(:moustache_club).update_columns(name: "Association of Clean-Shaven Persons")
assert_equal nil, Member.all.merge!(includes: :hairy_club).find(@member.id).reload.hairy_club
assert_nil Member.all.merge!(includes: :hairy_club).find(@member.id).reload.hairy_club
end
def test_has_one_through_polymorphic_with_source_type

View file

@ -92,7 +92,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
test "attribute keys on a new instance" do
t = Topic.new
assert_equal nil, t.title, "The topics table has a title column, so it should be nil"
assert_nil t.title, "The topics table has a title column, so it should be nil"
assert_raise(NoMethodError) { t.title2 }
end
@ -156,7 +156,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
keyboard = Keyboard.create
keyboard.key_number = "10"
assert_equal "10", keyboard.id_before_type_cast
assert_equal nil, keyboard.read_attribute_before_type_cast("id")
assert_nil keyboard.read_attribute_before_type_cast("id")
assert_equal "10", keyboard.read_attribute_before_type_cast("key_number")
assert_equal "10", keyboard.read_attribute_before_type_cast(:key_number)
end
@ -213,7 +213,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
record.written_on = "345643456"
assert_equal "345643456", record.written_on_before_type_cast
assert_equal nil, record.written_on
assert_nil record.written_on
record.written_on = "2009-10-11 12:13:14"
assert_equal "2009-10-11 12:13:14", record.written_on_before_type_cast
@ -754,7 +754,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
test "time zone-aware attributes do not recurse infinitely on invalid values" do
in_time_zone "Pacific Time (US & Canada)" do
record = @target.new(bonus_time: [])
assert_equal nil, record.bonus_time
assert_nil record.bonus_time
end
end

View file

@ -25,7 +25,7 @@ module ActiveRecord
attributes = builder.build_from_database(foo: "3.3")
assert_equal "3.3", attributes[:foo].value_before_type_cast
assert_equal nil, attributes[:bar].value_before_type_cast
assert_nil attributes[:bar].value_before_type_cast
assert_equal :bar, attributes[:bar].name
end

View file

@ -622,7 +622,7 @@ class BasicsTest < ActiveRecord::TestCase
Topic.find(topic.id).destroy
end
assert_equal nil, Topic.find_by_id(topic.id)
assert_nil Topic.find_by_id(topic.id)
end
def test_comparison_with_different_objects

View file

@ -142,13 +142,13 @@ module ActiveRecord
"database" => "foo",
"host" => "localhost" }
assert_equal expected, actual["default_env"]
assert_equal nil, actual["production"]
assert_equal nil, actual["development"]
assert_equal nil, actual["test"]
assert_equal nil, actual[:default_env]
assert_equal nil, actual[:production]
assert_equal nil, actual[:development]
assert_equal nil, actual[:test]
assert_nil actual["production"]
assert_nil actual["development"]
assert_nil actual["test"]
assert_nil actual[:default_env]
assert_nil actual[:production]
assert_nil actual[:development]
assert_nil actual[:test]
end
def test_blank_with_database_url_with_rails_env
@ -162,15 +162,15 @@ module ActiveRecord
"host" => "localhost" }
assert_equal expected, actual["not_production"]
assert_equal nil, actual["production"]
assert_equal nil, actual["default_env"]
assert_equal nil, actual["development"]
assert_equal nil, actual["test"]
assert_equal nil, actual[:default_env]
assert_equal nil, actual[:not_production]
assert_equal nil, actual[:production]
assert_equal nil, actual[:development]
assert_equal nil, actual[:test]
assert_nil actual["production"]
assert_nil actual["default_env"]
assert_nil actual["development"]
assert_nil actual["test"]
assert_nil actual[:default_env]
assert_nil actual[:not_production]
assert_nil actual[:production]
assert_nil actual[:development]
assert_nil actual[:test]
end
def test_blank_with_database_url_with_rack_env
@ -184,15 +184,15 @@ module ActiveRecord
"host" => "localhost" }
assert_equal expected, actual["not_production"]
assert_equal nil, actual["production"]
assert_equal nil, actual["default_env"]
assert_equal nil, actual["development"]
assert_equal nil, actual["test"]
assert_equal nil, actual[:default_env]
assert_equal nil, actual[:not_production]
assert_equal nil, actual[:production]
assert_equal nil, actual[:development]
assert_equal nil, actual[:test]
assert_nil actual["production"]
assert_nil actual["default_env"]
assert_nil actual["development"]
assert_nil actual["test"]
assert_nil actual[:default_env]
assert_nil actual[:not_production]
assert_nil actual[:production]
assert_nil actual[:development]
assert_nil actual[:test]
end
def test_database_url_with_ipv6_host_and_port

View file

@ -488,12 +488,12 @@ class FinderTest < ActiveRecord::TestCase
assert_equal topics(:fourth), Topic.offset(1).second_to_last
assert_equal topics(:fourth), Topic.offset(2).second_to_last
assert_equal topics(:fourth), Topic.offset(3).second_to_last
assert_equal nil, Topic.offset(4).second_to_last
assert_equal nil, Topic.offset(5).second_to_last
assert_nil Topic.offset(4).second_to_last
assert_nil Topic.offset(5).second_to_last
#test with limit
# assert_equal nil, Topic.limit(1).second # TODO: currently failing
assert_equal nil, Topic.limit(1).second_to_last
# assert_nil Topic.limit(1).second # TODO: currently failing
assert_nil Topic.limit(1).second_to_last
end
def test_second_to_last_have_primary_key_order_by_default
@ -516,15 +516,15 @@ class FinderTest < ActiveRecord::TestCase
# test with offset
assert_equal topics(:third), Topic.offset(1).third_to_last
assert_equal topics(:third), Topic.offset(2).third_to_last
assert_equal nil, Topic.offset(3).third_to_last
assert_equal nil, Topic.offset(4).third_to_last
assert_equal nil, Topic.offset(5).third_to_last
assert_nil Topic.offset(3).third_to_last
assert_nil Topic.offset(4).third_to_last
assert_nil Topic.offset(5).third_to_last
# test with limit
# assert_equal nil, Topic.limit(1).third # TODO: currently failing
assert_equal nil, Topic.limit(1).third_to_last
# assert_equal nil, Topic.limit(2).third # TODO: currently failing
assert_equal nil, Topic.limit(2).third_to_last
# assert_nil Topic.limit(1).third # TODO: currently failing
assert_nil Topic.limit(1).third_to_last
# assert_nil Topic.limit(2).third # TODO: currently failing
assert_nil Topic.limit(2).third_to_last
end
def test_third_to_last_have_primary_key_order_by_default
@ -1166,7 +1166,7 @@ class FinderTest < ActiveRecord::TestCase
end
test "find_by returns nil if the record is missing" do
assert_equal nil, Post.find_by("1 = 0")
assert_nil Post.find_by("1 = 0")
end
test "find_by with associations" do

View file

@ -15,7 +15,7 @@ class IntegrationTest < ActiveRecord::TestCase
def test_to_param_returns_nil_if_not_persisted
client = Client.new
assert_equal nil, client.to_param
assert_nil client.to_param
end
def test_to_param_returns_id_if_not_persisted_but_id_is_set
@ -89,7 +89,7 @@ class IntegrationTest < ActiveRecord::TestCase
def test_to_param_class_method_uses_default_if_not_persisted
firm = Firm.new(name: "Fancy Shirts")
assert_equal nil, firm.to_param
assert_nil firm.to_param
end
def test_to_param_with_no_arguments

View file

@ -101,7 +101,7 @@ if ActiveRecord::Base.connection.supports_foreign_keys?
fk = foreign_keys.first
if current_adapter?(:Mysql2Adapter)
# ON DELETE RESTRICT is the default on MySQL
assert_equal nil, fk.on_delete
assert_nil fk.on_delete
else
assert_equal :restrict, fk.on_delete
end

View file

@ -86,8 +86,8 @@ class ReflectionTest < ActiveRecord::TestCase
column = @first.column_for_attribute("attribute_that_doesnt_exist")
assert_instance_of ActiveRecord::ConnectionAdapters::NullColumn, column
assert_equal "attribute_that_doesnt_exist", column.name
assert_equal nil, column.sql_type
assert_equal nil, column.type
assert_nil column.sql_type
assert_nil column.type
end
def test_non_existent_types_are_identity_types

View file

@ -442,7 +442,7 @@ class RelationTest < ActiveRecord::TestCase
assert_no_queries(ignore_none: false) do
assert_equal 0, Developer.none.count
assert_equal 0, Developer.none.calculate(:count, nil)
assert_equal nil, Developer.none.calculate(:average, "salary")
assert_nil Developer.none.calculate(:average, "salary")
end
end
@ -485,28 +485,28 @@ class RelationTest < ActiveRecord::TestCase
def test_null_relation_average
ac = Aircraft.new
assert_equal Hash.new, ac.engines.group(:car_id).average(:id)
assert_equal nil, ac.engines.average(:id)
assert_nil ac.engines.average(:id)
ac.save
assert_equal Hash.new, ac.engines.group(:car_id).average(:id)
assert_equal nil, ac.engines.average(:id)
assert_nil ac.engines.average(:id)
end
def test_null_relation_minimum
ac = Aircraft.new
assert_equal Hash.new, ac.engines.group(:car_id).minimum(:id)
assert_equal nil, ac.engines.minimum(:id)
assert_nil ac.engines.minimum(:id)
ac.save
assert_equal Hash.new, ac.engines.group(:car_id).minimum(:id)
assert_equal nil, ac.engines.minimum(:id)
assert_nil ac.engines.minimum(:id)
end
def test_null_relation_maximum
ac = Aircraft.new
assert_equal Hash.new, ac.engines.group(:car_id).maximum(:id)
assert_equal nil, ac.engines.maximum(:id)
assert_nil ac.engines.maximum(:id)
ac.save
assert_equal Hash.new, ac.engines.group(:car_id).maximum(:id)
assert_equal nil, ac.engines.maximum(:id)
assert_nil ac.engines.maximum(:id)
end
def test_null_relation_in_where_condition
@ -1814,7 +1814,7 @@ class RelationTest < ActiveRecord::TestCase
end
test "find_by returns nil if the record is missing" do
assert_equal nil, Post.all.find_by("1 = 0")
assert_nil Post.all.find_by("1 = 0")
end
test "find_by doesn't have implicit ordering" do

View file

@ -50,7 +50,7 @@ class DefaultScopingTest < ActiveRecord::TestCase
def test_default_scope_with_conditions_string
assert_equal Developer.where(name: "David").map(&:id).sort, DeveloperCalledDavid.all.map(&:id).sort
assert_equal nil, DeveloperCalledDavid.create!.name
assert_nil DeveloperCalledDavid.create!.name
end
def test_default_scope_with_conditions_hash
@ -314,7 +314,7 @@ class DefaultScopingTest < ActiveRecord::TestCase
end
def test_create_attribute_overwrites_default_values
assert_equal nil, PoorDeveloperCalledJamis.create!(salary: nil).salary
assert_nil PoorDeveloperCalledJamis.create!(salary: nil).salary
assert_equal 50000, PoorDeveloperCalledJamis.create!(name: "David").salary
end

View file

@ -277,7 +277,7 @@ class NestedRelationScopingTest < ActiveRecord::TestCase
assert_equal "David", Developer.first.name
Developer.unscoped.where("name = 'Maiha'") do
assert_equal nil, Developer.first
assert_nil Developer.first
end
# ensure that scoping is restored

View file

@ -95,7 +95,7 @@ class YamlSerializationTest < ActiveRecord::TestCase
topic = YAML.load(yaml_fixture("rails_4_1"))
assert topic.new_record?
assert_equal nil, topic.id
assert_nil topic.id
assert_equal "The First Topic", topic.title
assert_equal({ omg: :lol }, topic.content)
end

View file

@ -316,7 +316,7 @@ module CacheStoreBehavior
def test_should_read_and_write_nil
assert @cache.write("foo", nil)
assert_equal nil, @cache.read("foo")
assert_nil @cache.read("foo")
end
def test_should_read_and_write_false
@ -464,7 +464,7 @@ module CacheStoreBehavior
Time.stub(:now, Time.at(time)) do
result = @cache.fetch("foo") do
assert_equal nil, @cache.read("foo")
assert_nil @cache.read("foo")
"baz"
end
assert_equal "baz", result
@ -476,7 +476,7 @@ module CacheStoreBehavior
@cache.write("foo", "bar", expires_in: 60)
Time.stub(:now, time + 71) do
result = @cache.fetch("foo", race_condition_ttl: 10) do
assert_equal nil, @cache.read("foo")
assert_nil @cache.read("foo")
"baz"
end
assert_equal "baz", result
@ -675,9 +675,9 @@ module LocalCacheBehavior
def test_local_cache_of_read_nil
@cache.with_local_cache do
assert_equal nil, @cache.read("foo")
assert_nil @cache.read("foo")
@cache.send(:bypass_local_cache) { @cache.write "foo", "bar" }
assert_equal nil, @cache.read("foo")
assert_nil @cache.read("foo")
end
end

View file

@ -887,7 +887,7 @@ module CallbacksTest
def test_returning_false_does_not_halt_callback_if_config_variable_is_not_set
obj = CallbackFalseTerminator.new
obj.save
assert_equal nil, obj.halted
assert_nil obj.halted
assert obj.saved
end
end
@ -900,7 +900,7 @@ module CallbacksTest
def test_returning_false_does_not_halt_callback_if_config_variable_is_true
obj = CallbackFalseTerminator.new
obj.save
assert_equal nil, obj.halted
assert_nil obj.halted
assert obj.saved
end
end
@ -913,7 +913,7 @@ module CallbacksTest
def test_returning_false_does_not_halt_callback_if_config_variable_is_false
obj = CallbackFalseTerminator.new
obj.save
assert_equal nil, obj.halted
assert_nil obj.halted
assert obj.saved
end
end

View file

@ -61,7 +61,7 @@ module ActiveSupport
def test_safe_get_constantizes_doesnt_fail_on_invalid_names
assert @cache.empty?
assert_equal nil, @cache.safe_get("OmgTotallyInvalidConstantName")
assert_nil @cache.safe_get("OmgTotallyInvalidConstantName")
end
def test_new_rejects_strings

View file

@ -376,7 +376,7 @@ class DateTimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal 1, DateTime.civil(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59).to_s
assert_equal 0, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0).to_s
assert_equal(-1, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 1).to_s)
assert_equal nil, DateTime.civil(2000) <=> "Invalid as Time"
assert_nil DateTime.civil(2000) <=> "Invalid as Time"
end
def test_compare_with_integer

View file

@ -172,7 +172,7 @@ class EnumerableTests < ActiveSupport::TestCase
payments.index_by(&:price))
assert_equal Enumerator, payments.index_by.class
if Enumerator.method_defined? :size
assert_equal nil, payments.index_by.size
assert_nil payments.index_by.size
assert_equal 42, (1..42).index_by.size
end
assert_equal({ 5 => Payment.new(5), 15 => Payment.new(15), 10 => Payment.new(10) },

View file

@ -390,8 +390,8 @@ class HashExtTest < ActiveSupport::TestCase
assert_equal 1, hash[:a]
assert_equal true, hash[:b]
assert_equal false, hash[:c]
assert_equal nil, hash[:d]
assert_equal nil, hash[:e]
assert_nil hash[:d]
assert_nil hash[:e]
end
def test_indifferent_reading_with_nonnil_default
@ -404,7 +404,7 @@ class HashExtTest < ActiveSupport::TestCase
assert_equal 1, hash[:a]
assert_equal true, hash[:b]
assert_equal false, hash[:c]
assert_equal nil, hash[:d]
assert_nil hash[:d]
assert_equal 1, hash[:e]
end
@ -933,8 +933,8 @@ class HashExtTest < ActiveSupport::TestCase
extracted = original.extract!(:a, :x)
assert_equal expected, extracted
assert_equal nil, extracted[:a]
assert_equal nil, extracted[:x]
assert_nil extracted[:a]
assert_nil extracted[:x]
end
def test_indifferent_extract
@ -1595,7 +1595,7 @@ class HashToXmlTest < ActiveSupport::TestCase
def test_should_return_nil_if_no_key_is_supplied
hash_wia = HashWithIndifferentAccess.new { 1 + 2 }
assert_equal nil, hash_wia.default
assert_nil hash_wia.default
end
def test_should_use_default_value_for_unknown_key

View file

@ -28,7 +28,7 @@ class BlankTest < ActiveSupport::TestCase
end
def test_presence
BLANK.each { |v| assert_equal nil, v.presence, "#{v.inspect}.presence should return nil" }
BLANK.each { |v| assert_nil v.presence, "#{v.inspect}.presence should return nil" }
NOT.each { |v| assert_equal v, v.presence, "#{v.inspect}.presence should return self" }
end
end

View file

@ -6,7 +6,7 @@ class DeepDupTest < ActiveSupport::TestCase
array = [1, [2, 3]]
dup = array.deep_dup
dup[1][2] = 4
assert_equal nil, array[1][2]
assert_nil array[1][2]
assert_equal 4, dup[1][2]
end
@ -14,7 +14,7 @@ class DeepDupTest < ActiveSupport::TestCase
hash = { a: { b: "b" } }
dup = hash.deep_dup
dup[:a][:c] = "c"
assert_equal nil, hash[:a][:c]
assert_nil hash[:a][:c]
assert_equal "c", dup[:a][:c]
end
@ -22,7 +22,7 @@ class DeepDupTest < ActiveSupport::TestCase
array = [1, { a: 2, b: 3 } ]
dup = array.deep_dup
dup[1][:c] = 4
assert_equal nil, array[1][:c]
assert_nil array[1][:c]
assert_equal 4, dup[1][:c]
end
@ -30,7 +30,7 @@ class DeepDupTest < ActiveSupport::TestCase
hash = { a: [1, 2] }
dup = hash.deep_dup
dup[:a][2] = "c"
assert_equal nil, hash[:a][2]
assert_nil hash[:a][2]
assert_equal "c", dup[:a][2]
end

View file

@ -339,7 +339,7 @@ class StringAccessTest < ActiveSupport::TestCase
test "#at with Regex, returns the matching portion of the string" do
assert_equal "lo", "hello".at(/lo/)
assert_equal nil, "hello".at(/nonexisting/)
assert_nil "hello".at(/nonexisting/)
end
test "#from with positive Integer, returns substring from the given position to the end" do

View file

@ -771,7 +771,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal 1, Time.utc(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59, 999).to_s
assert_equal 0, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0).to_s
assert_equal(-1, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 1, 0).to_s)
assert_equal nil, Time.utc(2000) <=> "Invalid as Time"
assert_nil Time.utc(2000) <=> "Invalid as Time"
end
def test_at_with_datetime

View file

@ -1057,7 +1057,7 @@ class TimeWithZoneMethodsForTimeAndDateTimeTest < ActiveSupport::TestCase
Time.zone = -9.hours
assert_equal ActiveSupport::TimeZone["Alaska"], Time.zone
Time.zone = nil
assert_equal nil, Time.zone
assert_nil Time.zone
end
def test_time_zone_getter_and_setter_with_zone_default_set

View file

@ -121,7 +121,7 @@ class DependenciesTest < ActiveSupport::TestCase
silence_warnings { require_dependency filename }
assert_equal 2, $check_warnings_load_count
assert_equal nil, $checked_verbose, "After first load warnings should be left alone."
assert_nil $checked_verbose, "After first load warnings should be left alone."
assert_includes ActiveSupport::Dependencies.loaded, expanded
ActiveSupport::Dependencies.clear
@ -526,8 +526,8 @@ class DependenciesTest < ActiveSupport::TestCase
def test_file_search
with_loading "dependencies" do
root = ActiveSupport::Dependencies.autoload_paths.first
assert_equal nil, ActiveSupport::Dependencies.search_for_file("service_three")
assert_equal nil, ActiveSupport::Dependencies.search_for_file("service_three.rb")
assert_nil ActiveSupport::Dependencies.search_for_file("service_three")
assert_nil ActiveSupport::Dependencies.search_for_file("service_three.rb")
assert_equal root + "/service_one.rb", ActiveSupport::Dependencies.search_for_file("service_one")
assert_equal root + "/service_one.rb", ActiveSupport::Dependencies.search_for_file("service_one.rb")
end

View file

@ -105,7 +105,7 @@ class ExecutorTest < ActiveSupport::TestCase
executor.wrap {}
assert_equal nil, supplied_state
assert_nil supplied_state
end
def test_exception_skips_uninvoked_hook

View file

@ -329,7 +329,7 @@ class TestJSONEncoding < ActiveSupport::TestCase
end
def test_nil_true_and_false_represented_as_themselves
assert_equal nil, nil.as_json
assert_nil nil.as_json
assert_equal true, true.as_json
assert_equal false, false.as_json
end

View file

@ -231,7 +231,7 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase
assert_equal 0, @chars.index("こに")
assert_equal 2, @chars.index("")
assert_equal 2, @chars.index("", -2)
assert_equal nil, @chars.index("", -1)
assert_nil @chars.index("", -1)
assert_equal 3, @chars.index("")
assert_equal 5, "ééxééx".mb_chars.index("x", 4)
end
@ -390,11 +390,11 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase
end
def test_slice_should_take_character_offsets
assert_equal nil, "".mb_chars.slice(0)
assert_nil "".mb_chars.slice(0)
assert_equal "", @chars.slice(0)
assert_equal "", @chars.slice(3)
assert_equal nil, "".mb_chars.slice(-1..1)
assert_equal nil, "".mb_chars.slice(-1, 1)
assert_nil "".mb_chars.slice(-1..1)
assert_nil "".mb_chars.slice(-1, 1)
assert_equal "", "".mb_chars.slice(0..10)
assert_equal "にちわ", @chars.slice(1..3)
assert_equal "にちわ", @chars.slice(1, 3)
@ -403,10 +403,10 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase
assert_equal "", @chars.slice(4..10)
assert_equal "", @chars.slice(//u)
assert_equal "にち", @chars.slice(/に./u)
assert_equal nil, @chars.slice(/unknown/u)
assert_nil @chars.slice(/unknown/u)
assert_equal "にち", @chars.slice(/(にち)/u, 1)
assert_equal nil, @chars.slice(/(にち)/u, 2)
assert_equal nil, @chars.slice(7..6)
assert_nil @chars.slice(/(にち)/u, 2)
assert_nil @chars.slice(7..6)
end
def test_slice_bang_returns_sliced_out_substring
@ -414,7 +414,7 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase
end
def test_slice_bang_returns_nil_on_out_of_bound_arguments
assert_equal nil, @chars.mb_chars.slice!(9..10)
assert_nil @chars.mb_chars.slice!(9..10)
end
def test_slice_bang_removes_the_slice_from_the_receiver

View file

@ -416,7 +416,7 @@ class TimeZoneTest < ActiveSupport::TestCase
def test_utc_offset_lazy_loaded_from_tzinfo_when_not_passed_in_to_initialize
tzinfo = TZInfo::Timezone.get("America/New_York")
zone = ActiveSupport::TimeZone.create(tzinfo.name, nil, tzinfo)
assert_equal nil, zone.instance_variable_get("@utc_offset")
assert_nil zone.instance_variable_get("@utc_offset")
assert_equal(-18_000, zone.utc_offset)
end

View file

@ -384,7 +384,7 @@ module ApplicationTests
get "/assets/demo.js"
assert_match "alert()", last_response.body
assert_equal nil, last_response.headers["Set-Cookie"]
assert_nil last_response.headers["Set-Cookie"]
end
test "files in any assets/ directories are not added to Sprockets" do

View file

@ -28,7 +28,7 @@ module ApplicationTests
assert_equal 3, x.payment_processing.retries
assert_equal true, x.super_debugger
assert_equal false, x.hyper_debugger
assert_equal nil, x.nil_debugger
assert_nil x.nil_debugger
assert_nil x.i_do_not_exist.zomg
end

View file

@ -614,7 +614,7 @@ module ApplicationTests
app "development"
assert_equal "b3c631c314c0bbca50c1b2843150fe33", app.config.secret_token
assert_equal nil, app.secrets.secret_key_base
assert_nil app.secrets.secret_key_base
assert_equal app.key_generator.class, ActiveSupport::LegacyKeyGenerator
end
@ -630,7 +630,7 @@ module ApplicationTests
app "development"
assert_equal "", app.config.secret_token
assert_equal nil, app.secrets.secret_key_base
assert_nil app.secrets.secret_key_base
assert_raise ArgumentError, /\AA secret is required/ do
app.key_generator
end
@ -1204,7 +1204,7 @@ module ApplicationTests
application.config.session_store :disabled
end
assert_equal nil, app.config.session_store
assert_nil app.config.session_store
end
test "default session store initializer sets session store to cookie store" do

View file

@ -246,7 +246,7 @@ module ApplicationTests
get "/", {}, "HTTP_IF_NONE_MATCH" => etag
assert_equal 304, last_response.status
assert_equal "", last_response.body
assert_equal nil, last_response.headers["Content-Type"]
assert_nil last_response.headers["Content-Type"]
assert_equal "max-age=0, private, must-revalidate", last_response.headers["Cache-Control"]
assert_equal etag, last_response.headers["Etag"]
@ -255,7 +255,7 @@ module ApplicationTests
assert_equal "", last_response.body
assert_equal "text/plain; charset=utf-8", last_response.headers["Content-Type"]
assert_equal "no-cache", last_response.headers["Cache-Control"]
assert_equal nil, last_response.headers["Etag"]
assert_nil last_response.headers["Etag"]
end
test "ORIGINAL_FULLPATH is passed to env" do

View file

@ -63,7 +63,7 @@ class Rails::ServerTest < ActiveSupport::TestCase
args = []
options = Rails::Server::Options.new.parse!(args)
merged_options = Rails::Server.new.default_options.merge(options)
assert_equal nil, merged_options[:caching]
assert_nil merged_options[:caching]
end
def test_caching_with_option