-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a BCC email field to the spree store edit page. This indicates a BCC email that you want all order confirmation emails to be BCCed to. As indicated in #3615, this is a feature that I think a lot of eCommerce stores are interested in, at the very least to server as a notification of a new order. Also adds the ability to add/update this field through the API
- Loading branch information
Showing
10 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ module Spree | |
"meta_keywords" => nil, | ||
"seo_title" => nil, | ||
"mail_from_address" => "[email protected]", | ||
"bcc_email" => nil, | ||
"default_currency" => nil, | ||
"code" => store.code, | ||
"default" => true, | ||
|
@@ -46,6 +47,7 @@ module Spree | |
"meta_keywords" => nil, | ||
"seo_title" => nil, | ||
"mail_from_address" => "[email protected]", | ||
"bcc_email" => nil, | ||
"default_currency" => nil, | ||
"code" => non_default_store.code, | ||
"default" => false, | ||
|
@@ -64,6 +66,7 @@ module Spree | |
"meta_keywords" => nil, | ||
"seo_title" => nil, | ||
"mail_from_address" => "[email protected]", | ||
"bcc_email" => nil, | ||
"default_currency" => nil, | ||
"code" => store.code, | ||
"default" => true, | ||
|
@@ -85,12 +88,14 @@ module Spree | |
it "can update an existing store" do | ||
store_hash = { | ||
url: "spree123.example.com", | ||
mail_from_address: "[email protected]" | ||
mail_from_address: "[email protected]", | ||
bcc_email: "[email protected]" | ||
} | ||
put spree.api_store_path(store), params: { store: store_hash } | ||
expect(response.status).to eq(200) | ||
expect(store.reload.url).to eql "spree123.example.com" | ||
expect(store.reload.mail_from_address).to eql "[email protected]" | ||
expect(store.reload.bcc_email).to eql "[email protected]" | ||
end | ||
|
||
context "deleting a store" do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
core/db/migrate/20200530111458_add_bcc_email_to_spree_stores.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddBccEmailToSpreeStores < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :spree_stores, :bcc_email, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
product = stub_model(Spree::Product, name: %{The "BEST" product}) | ||
variant = stub_model(Spree::Variant, product: product) | ||
price = stub_model(Spree::Price, variant: variant, amount: 5.00) | ||
store = FactoryBot.build :store, mail_from_address: "[email protected]" | ||
store = FactoryBot.build :store, mail_from_address: "[email protected]", bcc_email: "[email protected]" | ||
line_item = stub_model(Spree::LineItem, variant: variant, order: order, quantity: 1, price: 4.99) | ||
allow(variant).to receive_messages(default_price: price) | ||
allow(order).to receive_messages(line_items: [line_item]) | ||
|
@@ -21,6 +21,11 @@ | |
expect(message.from).to eq ["[email protected]"] | ||
end | ||
|
||
it "uses the order's store for the bcc address" do | ||
message = Spree::OrderMailer.confirm_email(order) | ||
expect(message.bcc).to eq ["[email protected]"] | ||
end | ||
|
||
it "doesn't aggressively escape double quotes in confirmation body" do | ||
confirmation_email = Spree::OrderMailer.confirm_email(order) | ||
expect(confirmation_email.body).not_to include(""") | ||
|