Ruby on rails 正在运行minitest controller get ActionController::UrlGenerationError:没有路由匹配

Ruby on rails 正在运行minitest controller get ActionController::UrlGenerationError:没有路由匹配,ruby-on-rails,minitest,ruby-on-rails-4.2,Ruby On Rails,Minitest,Ruby On Rails 4.2,我知道,这个话题有更多的问题要问,但我没有找到我需要的 目前,我正在将rails应用程序从3.2.13升级到4.2.0,升级rails后,测试自然会失败。这些测试在3.2.13中通过 所以,我有这个路线: get '/catalogs/:article_id/get_applicability_by_brand/:brand_id', :to => 'catalogs#get_applicability_by_brand', constrains: { format: 'js' }, as

我知道,这个话题有更多的问题要问,但我没有找到我需要的

目前,我正在将rails应用程序从3.2.13升级到4.2.0,升级rails后,测试自然会失败。这些测试在3.2.13中通过

所以,我有这个路线:

get '/catalogs/:article_id/get_applicability_by_brand/:brand_id', :to => 'catalogs#get_applicability_by_brand', constrains: { format: 'js' }, as: :catalog_get_applicability_by_brand
rake路由的结果如下:

  catalog_get_applicability_by_brand GET /catalogs/:article_id/get_applicability_by_brand/:brand_id(.:format)                                                   catalogs#get_applicability_by_brand {:constrains=>{:format=>"js"}}
控制器操作,仅呈现js.erb模板:

  def get_applicability_by_brand
      @applicability = CatalogAccess::TecDoc.get_applicability_by_brand(params[:article_id], params[:brand_id])
  end
小型测试控制器测试:

      def test_get_applicability_by_brand_action
    expected_applicability = [
      { 'model_name' => 'Model 1',
        'name' => 'fake name',
        'year_of_construct_from' => '2000',
        'year_of_construct_to' => '2010',
        'construction_type' => 'fake type' },
      { 'model_name' => 'Model 1',
        'name' => 'fake name 2',
        'year_of_construct_from' => '1991',
        'year_of_construct_to' => '2005',
        'construction_type' => 'fake type' }
    ]
    CatalogAccess::TecDoc.expects(:get_applicability_by_brand).with('12', '23').returns expected_applicability
    xhr :get, :get_applicability_by_brand, :article_id => '12', :brand_id => '23', :format => "js"
    assert_response 200
    assert_template 'get_applicability_by_brand'
    assert_template :partial => '_tecdoc2_applicability'
  end
测试错误消息为:

ActionController::UrlGenerationError:         ActionController::UrlGenerationError: No route matches {:action=>"get_applicability_by_brand", :article_id=>"12", :brand_id=>"23", :controller=>"catalogs", :format=>"js"}
我发现若附加到我的测试选项“use_route”,它将是pass,但得到的警告似乎不是好的解决方案

xhr :get, :get_applicability_by_brand, :article_id => '12', :brand_id => '23', :format => "js", :use_route => 'catalogs'
警告信息:

DEPRECATION WARNING: You are trying to generate the URL for a named route called "catalogs" but no such route was found. In the future, this will result in an `ActionController::UrlGenerationError` exception. (called from test_get_applicability_by_brand_action at /home/sdilshod/webapp/ps_base/apps/www/test/controllers/catalogs_controller_test.rb:627)
DEPRECATION WARNING: Passing the `use_route` option in functional tests are deprecated. Support for this option in the `process` method (and the related `get`, `head`, `post`, `patch`, `put` and `delete` helpers) will be removed in the next version without replacement. Functional tests are essentially unit tests for controllers and they should not require knowledge to how the application's routes are configured. Instead, you should explicitly pass the appropiate params to the `process` method. Previously the engines guide also contained an incorrect example that recommended using this option to test an engine's controllers within the dummy application. That recommendation was incorrect and has since been corrected. Instead, you should override the `@routes` variable in the test case with `Foo::Engine.routes`. See the updated engines guide for details. (called from test_get_applicability_by_brand_action at /home/sdilshod/webapp/ps_base/apps/www/test/controllers/catalogs_controller_test.rb:627)
DEPRECATION WARNING: You are trying to generate the URL for a named route called "catalogs" but no such route was found. In the future, this will result in an `ActionController::UrlGenerationError` exception. (called from test_get_applicability_by_brand_action at /home/sdilshod/webapp/ps_base/apps/www/test/controllers/catalogs_controller_test.rb:627)
请告诉我正确的解决方案

我希望你的帮助,谢谢