0

I have my brands controller in app/controllers/merchant/brands_controller.rb

I'm trying to write a functional test for it. I've defined test class as

require 'test_helper'

class Merchant::BrandsControllerTest < ActionController::TestCase
include Devise::TestHelpers

setup do
    @user = users(:one)
    sign_in @user
    @brand= brands(:one)
end

test "should get index" do
    get :index
    assert_response :success
end
end

but the tests throw an error saying

ActionController::RoutingError: No route matches {:controller=>"merchant/brands", :action=>"new"}

Why is it using 'merchant/brands' as controller name? Or can I specify custom route to make a request to 'new' method?

My routes look like this

namespace :merchant do
  resources :accounts do
    resources :brands
  end
end  

I

VivekVarade123
  • 3,564
  • 4
  • 24
  • 31

1 Answers1

0

It seems you forgot the accounts part of your route.

Try with

class Merchant::Accounts::BrandsControllerTest
Intrepidd
  • 19,772
  • 6
  • 55
  • 63