Skip to content

Instantly share code, notes, and snippets.

@md5
Last active March 7, 2017 01:19
Show Gist options
  • Save md5/be5d072bb2c853baf2143dd5faba69cb to your computer and use it in GitHub Desktop.
Save md5/be5d072bb2c853baf2143dd5faba69cb to your computer and use it in GitHub Desktop.
Rails NilClass#to_query(key) test
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