We are migrating 2.3.18 application to 3.2.x. We are facing an issue while running a test where it is not able to find routes using route helpers
Here is the assertion where we are facing issue
#test/unit/application_helper_test.rb
def test_calendar_link_to_with_named_route
. . .
calendar_link_to(31, date, {:named_route => 'edit_detailed_reservation_path', :method => :post})
. . .
end
Here is how the method is defined in ApplicationHelper
def calendar_link_to(anchor_text, date, *args)
options = args.first.is_a?(Hash) ? args.pop : {}
method = options[:method]
named_route = options[:named_route]
url_hash = { :day => date.day, :month => date.month, :year => date.year }
url = named_route ? self.send(named_route, url_hash) : url_hash
link_options = { :id => "date-#{date.year}-#{date.month}-#{date.day}" }
if date > Parameter.event_horizon
link_options[:title] = 'This date is beyond the event horizon.'
end
link_options[:method] = method if method
link_to(anchor_text, url, link_options)
end
While running the test we get following error
NoMethodError: undefined method `edit_detailed_reservation_path'
To resolve this error I have also tried to put the below line inside application_helper.rb
include Rails.application.routes.url_helpers
We use below command to run the test
rake test TEST=test/unit/application_helper_test.rb
In Rails 2, edit_detailed_reservation_path gives absolute URL while inspecting it in a pry session but same doesn't work in Rails 3.
Would anybody please guide us what could be the issue and how to fix it?