_path helpers are no longer available in mailers

https://github.com/rails/rails/pull/15840
This commit is contained in:
Sean Linsley 2016-07-04 14:48:02 -05:00
parent 1744161075
commit 1e52e791ff
3 changed files with 19 additions and 22 deletions

View File

@ -20,14 +20,16 @@
<dt>Helpers from the controller:</dt>
<dd id="goodnight_moon"><%= post.goodnight_moon %></dd>
<dt>Path with decorator:</dt>
<dd id="path_with_decorator"><%= post_path(post) %></dd>
<% unless defined? mailer %>
<dt>Path with decorator:</dt>
<dd id="path_with_decorator"><%= post_url(post) %></dd>
<dt>Path with model:</dt>
<dd id="path_with_model"><%= post.path_with_model %></dd>
<dt>Path with model:</dt>
<dd id="path_with_model"><%= post.path_with_model %></dd>
<dt>Path with id:</dt>
<dd id="path_with_id"><%= post.path_with_id %></dd>
<dt>Path with id:</dt>
<dd id="path_with_id"><%= post.path_with_id %></dd>
<% end %>
<dt>URL with decorator:</dt>
<dd id="url_with_decorator"><%= post_url(post) %></dd>

View File

@ -10,14 +10,6 @@ describe PostMailer do
expect(email_body).to have_content "Today"
end
it "can use path helpers with a model" do
expect(email_body).to have_css "#path_with_model", text: "/en/posts/#{post.id}"
end
it "can use path helpers with an id" do
expect(email_body).to have_css "#path_with_id", text: "/en/posts/#{post.id}"
end
it "can use url helpers with a model" do
expect(email_body).to have_css "#url_with_model", text: "http://www.example.com:12345/en/posts/#{post.id}"
end

View File

@ -38,16 +38,19 @@ app.start_server do
expect(page).to have_text("Goodnight, moon!").in("#goodnight_moon")
end
it "can be passed to path helpers" do
expect(page).to have_text("/en/posts/1").in("#path_with_decorator")
end
# _path helpers aren't available in mailers
if type == :view
it "can be passed to path helpers" do
expect(page).to have_text("/en/posts/1").in("#path_with_decorator")
end
it "can use path helpers with a model" do
expect(page).to have_text("/en/posts/1").in("#path_with_model")
end
it "can use path helpers with a model" do
expect(page).to have_text("/en/posts/1").in("#path_with_model")
end
it "can use path helpers with an id" do
expect(page).to have_text("/en/posts/1").in("#path_with_id")
it "can use path helpers with an id" do
expect(page).to have_text("/en/posts/1").in("#path_with_id")
end
end
it "can be passed to url helpers" do