Closed ruta0 closed 6 years ago
I am getting a routing problem with this destroy action from productsController, here is my routes:
routes
namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api' }, path: '/' do scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do # list of resources here devise_for :users resources :users, only: [:show, :create, :update, :destroy] do resources :products, only: [:create, :update, :destroy] end resources :sessions, only: [:create, :destroy] resources :products, only: [:show, :index] end end
and this is my action from my ProductsController.rb:
def destroy product = current_user.products.find(params[:id]) product.destroy head 204 end
and this is my test case:
describe 'DELETE #destroy' do before(:each) do @user = FactoryBot.create :user @product = FactoryBot.create :product, user: @user api_authorization_header(@user.auth_token) delete :destroy, params: { userd_id: @user.id, id: @product.id } end it { should respond_with 204 } end
Any ideas why this happened?
You have an typo error on the test:
delete :destroy, params: { userd_id: @user.id, id: @product.id }
Specifically the userd_id param name, which should be user_id, without the d
userd_id
user_id
d
Please let me know!
I am getting a routing problem with this destroy action from productsController, here is my
routes
:and this is my action from my ProductsController.rb:
and this is my test case:
Any ideas why this happened?