Ruby on rails 4 如何在Rails 4中从RequestHelpers发出的post请求中定义头
我想测试我的rails Webhook,但我无法让post()发送正确的头,我要做的是: 我的标题中有这样一个字段:Ruby on rails 4 如何在Rails 4中从RequestHelpers发出的post请求中定义头,ruby-on-rails-4,Ruby On Rails 4,我想测试我的rails Webhook,但我无法让post()发送正确的头,我要做的是: 我的标题中有这样一个字段: [“查询字符串”,“内容类型=应用程序%2Fx www form urlencoded”] 注意:当我使用相同定义的标题字段发送post请求时,它工作正常,我得到了如下字段 [“内容类型”,“应用程序/x-www-form-urlencoded”] 我使用post方法错误吗? 多谢各位 require 'test_helper' module Hooks class H
[“查询字符串”,“内容类型=应用程序%2Fx www form urlencoded”]
注意:当我使用相同定义的标题字段发送post请求时,它工作正常,我得到了如下字段
[“内容类型”,“应用程序/x-www-form-urlencoded”]
我使用post方法错误吗?
多谢各位
require 'test_helper'
module Hooks
class HooksControllerTest < ActionController::TestCase
test 'non-json request fails 406' do
post :update, headers: {'Content-Type' => 'application/x-www-form-urlencoded'}
assert_response 406
end
#...
module Hooks
class HooksController < ApplicationController
skip_before_filter :verify_authenticity_token
def update
byebug
#...
request.headers['Content-Type'] # nil