MiniTest中的undefined方法`link_to_remote'用于application_helper测试

时间:2015-01-22 10:38:25

标签: ruby-on-rails ruby-on-rails-3 rails-migrations

将应用程序从 Rails 2.3.17 迁移到 3.2.21。。在使用MiniTest进行测试时,我们遇到了Rails遗留表单助手link_to_remote的问题。

在早期版本的rails中,我们使用了 link_to_remote 表单帮助程序,在Rails 3中删除了。为了提供支持,我们在我们的应用程序中添加了 prototype_legacy_helper插件 UI但测试失败并抛出错误,如下所示:

NoMethodError: undefined method `link_to_remote' for #<ApplicationHelperTest:0xc800dd4>

这是我们在ApplicationHelper

中的代码
def reservation_menu_command_link(command, *args)
  ...
  command_link = link_to_remote(anchor_text,options = {}, {:class => style_class})
  ...
end

这是我们对application_helper测试的测试用例

def test_reservation_menu_command_link
  options = { :lodging_view => lv}
  assert_equal(%q{xyz}, reservation_menu_command_link(:cancel_all_possible, options))
end

所以你可以看到我们有一个方法reservation_menu_command_link,我们在我们的UI中使用它,它工作正常,但测试此定义失败。

任何人都可以帮助我摆脱插件的这种行为吗?

1 个答案:

答案 0 :(得分:1)

link_to_remote在第2和第3栏之间已被弃用,这些天的正确用法是

link_to 'Foo', { action: 'create' }, remote: true。希望这有帮助

相关问题