Skip to content

Conversation

notapatch
Copy link
Contributor

I got stuck on Chapter 08. On the "Decrementing product quantity" section. I was entering the listing 124

# ...
class Api::V1::OrdersControllerTest < ActionDispatch::IntegrationTest
  setup do
    @order = orders(:one)    # <=== BAD
    @order_params = {
      order: {
        product_ids_and_quantities: [
          { product_id: products(:one).id, quantity: 2 },
          { product_id: products(:two).id, quantity: 3 },
        ]
      }
    }
  end

Which caused the error:

Error:
Api::V1::OrdersControllerTest#test_should_show_order:
NoMethodError: undefined method `products' for #<Product:0x00007facf60cac10>
    test/controllers/api/v1/orders_controller_test.rb:45:in `block in <class:OrdersControllerTest>'

I changed @order = products(:one) to @order = orders(:one) and it all worked again. This PR is the fix.

@notapatch notapatch force-pushed the pr-ch08-undefine-method-products branch from 9b0411b to efb8eca Compare January 23, 2021 16:40
@madeindjs
Copy link
Owner

You're right! This seems to be a mistake. Thank you very much to correct it, I will also update project example.

@madeindjs madeindjs merged commit 919a306 into madeindjs:master Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants