【发布时间】:2011-08-13 01:59:57
【问题描述】:
我有一个应用程序,它有一个 API,带有 /api/v1/ 命名空间:
namespace :api do
namespace :v1 do
resources :gateways do
resources :mappings do
# maybe more stuff
end
end
end
end
我的应用程序使用 devise 和 cancan。
如果我遗漏 :format=>:yaml (请求 HTML 并获得 406),我在 app/controllers/api/v1/mappings_controller.rb 中的映射控制器可以从 rspec 测试用例正常工作。 如果我要求 :yaml,devise 似乎认为我的测试用户是不允许的。
我的测试用例很简单:
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
我在 devise/warden 中看不到任何特定于格式的内容,但也许我错过了。
【问题讨论】:
标签: ruby-on-rails-3 devise cancan