-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get transforms to post if params given #2502
Comments
|
Hello Did you tried with the parameter as a hash? # frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
gem "rails", "6.1.0"
gem "rspec-rails"
end
require "rspec-rails"
require "action_controller/railtie"
class TestApp < Rails::Application
config.root = __dir__
config.hosts << "example.org"
config.session_store :cookie_store, key: "cookie_store_key"
secrets.secret_key_base = "secret_key_base"
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
get "/" => "test#index"
end
end
class TestController < ActionController::Base
include Rails.application.routes.url_helpers
def index
render plain: "Param : #{params["test"]}"
end
end
require 'rspec/autorun'
RSpec.describe 'additions', type: :request do
include Rack::Test::Methods
let(:valid_headers) { { "Authorization" => "foo" } }
it do
get "/",
{ "test" => "Foo" },
headers: valid_headers,
as: :json
expect(last_response.body).to include("Param : Foo")
end
private
def app
Rails.application
end
end |
I was able to reproduce the issue with an identical code. What @pirj was saying is defined in here. I tried @benoittgt's script and it worked. However, I couldn't get my test passing. After checking line by line, I finally found it. Somehow this line
EDIT: I thought everything was passing but now I'm running rspec main:
Here's my locked version:
|
I don't think it's a bug anymore. The explanation is here: rails/rails@af1680f. I think it could be more visible somehow. Anyways, after deleting the explicit |
Closing as this seems the intended behaviour on Rails end. |
What Ruby, Rails and RSpec versions are you using?
Ruby version:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
Rails version:
Rails 6.1.3.1
RSpec version:
Observed behaviour
routes.rb
get '/users/:id/billing_addresses', to: "billing_addresses#index"
my spec.rb
Started POST "/users/2/billing_addresses"
If I remove
params: { some_param: some_param }
like so:it keeps a get request
Started GET "/users/2/billing_addresses"
Expected behaviour
should trigger
Started GET "/users/2/billing_addresses"
The text was updated successfully, but these errors were encountered: