Open
Description
Steps to reproduce
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
end
require "action_controller/railtie"
class TestApp < Rails::Application
config.hosts << "www.example.com"
routes.draw do
resources :characters
end
config.root = __dir__
config.logger = Logger.new($stdout)
Rails.logger = config.logger
end
class CharactersController < ActionController::Base
def create
render head: :no_content
end
end
require "minitest/autorun"
require "rack/test"
class BugTest < ActionDispatch::IntegrationTest
def test_params_without_content_type
post "/characters", params: { name: "Muad'Dib" }
end
def test_params_with_htm_content_type
post "/characters", as: :html, params: { name: "Muad'Dib" }
end
private
def app
Rails.application
end
end
Expected behavior
In Rails 7.0, the second test works.
Actual behavior
In Rails 7.1, the second test will raise an error :
BugTest#test_params_with_htm_content_type:
NoMethodError: undefined method `to_html' for {:name=>"Muad'Dib"}:Hash
.../actionpack/lib/action_dispatch/testing/request_encoder.rb:39:in `encode_params'
.../actionpack/lib/action_dispatch/testing/integration.rb:251:in `process'
.../actionpack/lib/action_dispatch/testing/integration.rb:22:in `post'
.../actionpack/lib/action_dispatch/testing/integration.rb:379:in `post'
issue_bug.rb:39:in `test_params_with_htm_content_type'
System configuration
Rails version:
Rails 7.1.2 & main
Ruby version:
Ruby 3.2.2