Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
[SD-1404] - Always link to Product pages in Emails (#11219)
Browse files Browse the repository at this point in the history
* Use spree_storefront_resource_url for email links.

* Fix broken tests.

* Revert bad test hack, and apply fix for undefined locale_param

* Update emails/spec/mailers/spree/order_mailer_spec.rb

Co-authored-by: Damian Legawiec <damian@sparksolutions.co>
  • Loading branch information
MatthewKennedy and damianlegawiec authored Aug 8, 2021
1 parent ee6ffaa commit 3d7bf4c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
2 changes: 1 addition & 1 deletion core/app/helpers/spree/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def rails_5?
end

def spree_storefront_resource_url(resource, options = {})
if locale_param
if defined?(locale_param) && locale_param.present?
options.merge!(locale: locale_param)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@
<% @reimbursement.return_items.exchange_requested.each do |return_item| %>
<tr>
<td class="purchase_image">
<% if frontend_available? %>
<%= link_to(image_tag(variant_image_url(return_item.variant)), spree.product_url(return_item.variant.product)) %>
<% else %>
<%= image_tag(variant_image_url(return_item.variant)) %>
<% end %>
<%= link_to(image_tag(variant_image_url(return_item.variant)), spree_storefront_resource_url(return_item.variant.product)) %>
</td>
<td class="purchase_item">
<strong>
<span class="f-fallback">
<% if frontend_available? %>
<%= link_to raw(return_item.variant.name), spree.product_url(return_item.variant.product) %>
<% else %>
<%= raw(return_item.variant.name) %>
<% end %>
<%= link_to raw(return_item.variant.name), spree_storefront_resource_url(return_item.variant.product) %>
</span>
</strong>
<p class="purchase_item--additional">
Expand Down
6 changes: 1 addition & 5 deletions emails/app/views/spree/shared/_mailer_line_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<tr>
<td class="six sub-columns">
<strong>
<% if frontend_available? %>
<%= link_to raw(line_item.variant.product.name), spree.product_url(line_item.variant.product) %>
<% else %>
<%= raw(line_item.variant.product.name) %>
<% end %>
<%= link_to raw(line_item.variant.product.name), spree_storefront_resource_url(line_item.variant.product) %>
</strong>
<%= raw(line_item.variant.options_text) -%>
(<%= line_item.variant.sku %>)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<tr>
<td class="purchase_image">
<% if frontend_available? %>
<%= link_to(image_tag(variant_image_url(line_item.variant)), spree.product_url(line_item.product)) %>
<% else %>
<%= image_tag(variant_image_url(line_item.variant)) %>
<% end %>
<%= link_to(image_tag(variant_image_url(line_item.variant)), spree_storefront_resource_url(line_item.product)) %>
</td>
<td class="purchase_item">
<strong>
<span class="f-fallback">
<% if frontend_available? %>
<%= link_to raw(line_item.name), spree.product_url(line_item.product) %>
<% else %>
<%= raw(line_item.name) %>
<% end %>
<%= link_to raw(line_item.name), spree_storefront_resource_url(line_item.product) %>
</span>
</strong>
<p class="purchase_item--additional"><%= raw(line_item.variant.options_text) -%></p>
Expand Down
4 changes: 3 additions & 1 deletion emails/spec/mailers/spree/shipment_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
let(:shipment) { order.shipments.first }
let(:shipping_method) { shipment.shipping_method }

before { shipping_method.update(tracking_url: 'http://example.com/tracking') }
before do
shipping_method.update(tracking_url: 'http://example.com/tracking')
end

context ':from not set explicitly' do
it 'falls back to spree config' do
Expand Down

0 comments on commit 3d7bf4c

Please sign in to comment.