Undefined `link_to_remote` method in MiniTest for application_helper test

When porting an application from Rails 2.3.17 to 3.2.21. . We encounter a problem with the link_to_remote helper of link_to_remote inherited Rails form during testing with MiniTest.

In the old version of rails, we used the link_to_remote form helper, which was removed in Rails 3. To provide support, we added the prototype_legacy_helper plugin in our application, which works fine in the UI, but the tests fail and cause an error, as shown below:

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

This is our code inside ApplicationHelper

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

This is our test case for the application_helper test.

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

So you can see that we have the reserve_menu_command_link method, and we used it in our user interface, which works fine, but the test for this definition fails.

Can someone help me in this plugin behavior?

+5
source share
1 answer

link_to_remote was obsolete between rails 2 and 3, correct use these days

link_to 'Foo', { action: 'create' }, remote: true . Hope this helps

+1
source

Source: https://habr.com/ru/post/1211693/


All Articles