From 1e52e791ff83337ef61915d351523f164654aa9a Mon Sep 17 00:00:00 2001 From: Sean Linsley Date: Mon, 4 Jul 2016 14:48:02 -0500 Subject: [PATCH] _path helpers are no longer available in mailers https://github.com/rails/rails/pull/15840 --- spec/dummy/app/views/posts/_post.html.erb | 14 ++++++++------ spec/dummy/spec/mailers/post_mailer_spec.rb | 8 -------- spec/integration/integration_spec.rb | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/spec/dummy/app/views/posts/_post.html.erb b/spec/dummy/app/views/posts/_post.html.erb index 22350a4..4225361 100644 --- a/spec/dummy/app/views/posts/_post.html.erb +++ b/spec/dummy/app/views/posts/_post.html.erb @@ -20,14 +20,16 @@
Helpers from the controller:
<%= post.goodnight_moon %>
-
Path with decorator:
-
<%= post_path(post) %>
+ <% unless defined? mailer %> +
Path with decorator:
+
<%= post_url(post) %>
-
Path with model:
-
<%= post.path_with_model %>
+
Path with model:
+
<%= post.path_with_model %>
-
Path with id:
-
<%= post.path_with_id %>
+
Path with id:
+
<%= post.path_with_id %>
+ <% end %>
URL with decorator:
<%= post_url(post) %>
diff --git a/spec/dummy/spec/mailers/post_mailer_spec.rb b/spec/dummy/spec/mailers/post_mailer_spec.rb index 3d6699a..4ab0135 100644 --- a/spec/dummy/spec/mailers/post_mailer_spec.rb +++ b/spec/dummy/spec/mailers/post_mailer_spec.rb @@ -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 diff --git a/spec/integration/integration_spec.rb b/spec/integration/integration_spec.rb index 3175b3c..00ab9d7 100644 --- a/spec/integration/integration_spec.rb +++ b/spec/integration/integration_spec.rb @@ -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