Skip to content

Commit

Permalink
Remove order link in non-user order cancellation email
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinalim committed Aug 30, 2018
1 parent 728e98a commit f91f1d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/views/subscription_mailer/confirmation_email.html.haml
Expand Up @@ -3,9 +3,10 @@

%p.callout
= t("email_so_confirmation_explainer_html")
= t("email_so_edit_false_html",
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
order_url: spree.order_url(@order))
- if @order.user.present?
= t("email_so_edit_false_html",
orders_close_at: l(@order.order_cycle.orders_close_at, format: mail_long_datetime_format),
order_url: spree.order_url(@order))
= t("email_so_contact_distributor_html", distributor: @order.distributor.name, email: @order.distributor.contact.email)

%p  
Expand Down
27 changes: 25 additions & 2 deletions spec/mailers/subscription_mailer_spec.rb
Expand Up @@ -93,7 +93,8 @@
end

describe "order confirmation" do
let(:subscription) { create(:subscription, with_items: true) }
let(:customer) { create(:customer) }
let(:subscription) { create(:subscription, customer: customer, with_items: true) }
let(:proxy_order) { create(:proxy_order, subscription: subscription) }
let!(:order) { proxy_order.initialise_order! }

Expand All @@ -106,7 +107,29 @@
it "sends the email" do
body = SubscriptionMailer.deliveries.last.body.encoded
expect(body).to include "This order was automatically placed for you"
expect(body).to include "href=\"#{spree.order_url(order)}\""
end

describe "linking to order page" do
let(:order_link_href) { "href=\"#{spree.order_url(order)}\"" }

let(:email) { SubscriptionMailer.deliveries.last }
let(:body) { email.body.encoded }

context "when the customer has a user account" do
let(:customer) { create(:customer) }

it "provides link to view details" do
expect(body).to match /#{order_link_href}/
end
end

context "when the customer has no user account" do
let(:customer) { create(:customer, user: nil) }

it "does not provide link" do
expect(body).to_not match /#{order_link_href}/
end
end
end
end

Expand Down

0 comments on commit f91f1d4

Please sign in to comment.