2013-03-07 77 views
5

我使用inherited_resources和我有这样一个控制器:命名空间控制器上resource_url测试误差(inherited_resources)

class Admin::PostsController < InheritedResources::Base 
end 

而且在我的控制器测试:

it "redirects to the post" do 
    post = Post.create! valid_attributes 
    put :update, {:id => post.to_param, :post => valid_attributes}, valid_session 
    response.should redirect_to([:admin, post]) 
end 

我收到此错误:

undefined method `posts_url' for #<Admin::PostsController:0xec6fb20> 

奇怪的部分是它只发生在测试中!应用程序运行正常。

我错过了什么?

[编辑]我发现这个问题的报道,但没有答案被关闭https://github.com/josevalim/inherited_resources/issues/193

[编辑]我刚刚发现,为什么它正在发生,并回答上述问题页面

+0

你可以在这里发表答案或关闭这个问题,所以它不会显示为“未答复”? – rafb3 2014-11-22 20:40:02

回答

1

具有u尝试这样的:

response.should redirect_to '/your_url' 

它可能会解决您的问题。