Reputation: 24094
I have an asynchronous job that sends an email to the user when it completes. I'm testing the send email function with rspec.
In environments/test.rb I have this line
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
In the action mailer view I have this line,
= link_to(@submission.title, @submission, {:only_path => false})
This generates a relative url
<a href="/submissions/1" only_path="false">Test Submission 1</a>
What I need is
<a href="http://localhost:3000/submissions/1">Test Submission 1</a>
Upvotes: 3
Views: 1643
Reputation: 16064
Call the named route directly instead of allowing Rails to generate it for you. So turn your link into this:
= link_to(@submission.title, submission_url(@submission))
Upvotes: 4