[英]undefined method `link_to_remote' in MiniTest for application_helper test
將應用程序從Rails 2.3.17遷移到3.2.21時。 。 在使用MiniTest進行測試時,我們遇到了Rails遺留表單幫助程序link_to_remote
的問題。
在舊版本的rails中,我們使用了在Rails 3中刪除的link_to_remote表單幫助程序。為了提供支持,我們在我們的應用程序中添加了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中使用它,工作正常,但測試此定義失敗。
任何人都可以幫助我擺脫插件的這種行為嗎?
link_to_remote
在rails 2和3之間已被棄用,這些天的正確用法是
link_to 'Foo', { action: 'create' }, remote: true
。 希望這會有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.