Last active
March 7, 2017 01:19
-
-
Save md5/be5d072bb2c853baf2143dd5faba69cb to your computer and use it in GitHub Desktop.
Rails NilClass#to_query(key) test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails", github: "rails/rails" | |
end | |
require "active_support" | |
require "active_support/core_ext/object/blank" | |
require "minitest/autorun" | |
class BugTest < Minitest::Test | |
def test_nil_to_query | |
assert_equal "key", nil.to_query('key') | |
end | |
def test_nil_to_query_hash_value | |
assert_equal "key", { key: nil }.to_query | |
end | |
def test_nil_hash_value_round_trip | |
hash = { 'key' => nil } | |
assert_equal hash, Rack::Utils.parse_nested_query(hash.to_query) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment