Ruby on rails 3 rails3路由和基于yaml的API,使用Desive和cancan

Ruby on rails 3 rails3路由和基于yaml的API,使用Desive和cancan,ruby-on-rails-3,devise,cancan,Ruby On Rails 3,Devise,Cancan,我有一个应用程序将有一个API,带有/API/v1/名称空间: namespace :api do namespace :v1 do resources :gateways do resources :mappings do # maybe more stuff end end end end 我的应用程序使用Desive和cancan 在app/controllers/api/v1/mappings\u controller.r

我有一个应用程序将有一个API,带有/API/v1/名称空间:

namespace :api do
  namespace :v1 do
    resources :gateways do
      resources :mappings do
        # maybe more stuff
      end
    end
  end
end
我的应用程序使用Desive和cancan

在app/controllers/api/v1/mappings\u controller.rb中我的mappings控制器在rspec测试用例中正常工作,如果我省略:format=>:yaml(请求HTML,并获得406)。 如果我问:yaml,designe似乎认为我的测试用户是不允许的

我的测试用例很简单:

  describe "Agent access to mappings" do
    it "gets a list of mappings that includes test_user mapping" do
      @test_agent = users(:firewallagent)
      sign_in(@test_agent)    
      get :show, {:gateway_id => 1, :id => 2} #, :format => :yaml
      assert_response 200
    end
  end

我在Devage/warden中看不到任何特定于格式的内容,但可能我错过了它。

错误在于:format=>:yaml需要进入第一个哈希,而不是get的第二个哈希。因此:

get :show, {:gateway_id => 1, :id => 2, :format => :yaml}