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

Nis*_*yay 5 ruby-on-rails rails-migrations ruby-on-rails-3

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

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

NoMethodError: undefined method `link_to_remote' for #<ApplicationHelperTest:0xc800dd4>
Run Code Online (Sandbox Code Playgroud)

这是我们在ApplicationHelper中的代码

def reservation_menu_command_link(command, *args)
  ...
  command_link = link_to_remote(anchor_text,options = {}, {:class => style_class})
  ...
end
Run Code Online (Sandbox Code Playgroud)

这是我们对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
Run Code Online (Sandbox Code Playgroud)

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

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

Rya*_*acG 2

link_to_remote在 Rails 2 和 3 之间已被弃用,现在正确的用法是

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