Skip to content

Parameter name is not equal the model name when executing scaffold_controller with namespace #2532

@kenzo-tanaka

Description

@kenzo-tanaka

Hi👋
First of all thank you for the very helpful gem!

What Ruby, Rails and RSpec versions are you using?

Ruby version: 2.6.3p62
Rails version: 6.1.4.1
RSpec core version: 3.10.1
RSpec rails version: 5.0.2

Observed behaviour

When the request spec is created by executing the scaffold_controller command with namespace, the parameter name is not equal the model name.

Here is a pull request that reproduces the behaviour
kenzo-tanaka/rails_sandbox#14

$ rails g model Product name:string price:integer
$ rails db:migrate
$ rails g scaffold_controller admin/products --model-name=product --no-helper --no-assets --no-controller-specs --no-routing-specs --no-view-specs
describe "POST /create" do
  context "with valid parameters" do
    it "creates a new Product" do
      expect {
        # Here, I expected `{ product: valid_attributes }` like the test of update action
        post admin_products_url, params: { admin_product: valid_attributes } 
      }.to change(Product, :count).by(1)
    end
    # ...
end

Expected behaviour

I expected that the autogenerated code is like this:

describe "POST /create" do
  context "with valid parameters" do
    it "creates a new Product" do
      expect {
        post admin_products_url, params: { product: valid_attributes } 
      }.to change(Product, :count).by(1)
    end
    # ...
end

Can you provide an example app?

https://github.com/kenzo-tanaka/rails_sandbox/pull/14/files


I'm sorry if I misunderstood something about this behaviour🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions