【问题标题】:Namespaced controller testing error on resource_url (inherited_resources)resource_url (inherited_resources) 上的命名空间控制器测试错误
【发布时间】:2013-02-23 07:20:15
【问题描述】:

我正在使用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

[编辑] 我刚刚找到了它发生的原因并在上面的问题页面上做出了回应

【问题讨论】:

  • 您可以在此处发布答案或关闭问题以使其不显示为“未回答”吗?

标签: ruby-on-rails ruby rspec namespaces


【解决方案1】:

你试过这个吗:

response.should redirect_to '/your_url'

它可能会解决你的问题。

【讨论】:

    猜你喜欢
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-07
    • 1970-01-01
    • 2012-05-14
    • 1970-01-01
    • 2014-05-19
    相关资源
    最近更新 更多