-
-
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 Order#order_email to show the order's email
`spree_orders` table has the column `email` which stores the email of guest orders, this change intends to look first at this property then fallback to user's email.
- Loading branch information
Showing
4 changed files
with
28 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
visit "/admin/orders" | ||
click_on "In Progress" | ||
|
||
expect(page).to have_content("[email protected]") | ||
expect(page).to have_content("R123456789") | ||
expect(page).to have_content("$19.99") | ||
expect(page).to be_axe_clean | ||
|
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 |
---|---|---|
|
@@ -1832,4 +1832,26 @@ def validate(line_item) | |
expect { subject }.to change { Spree::OrderPromotion.count }.from(1).to(0) | ||
end | ||
end | ||
|
||
describe "order_email" do | ||
context "when a new order is created" do | ||
it "returns nil" do | ||
expect(Spree::Order.new.order_email).to eq(nil) | ||
end | ||
end | ||
|
||
context "when a logged in user creates an order" do | ||
it "returns the customer's email" do | ||
order = build(:order, user: build(:user, email: "[email protected]")) | ||
expect(order.order_email).to eq("[email protected]") | ||
end | ||
end | ||
|
||
context "when order email is different than user's email" do | ||
it "gives preference to order's email" do | ||
order = build(:order, email: "[email protected]", user: build(:user, email: "[email protected]")) | ||
expect(order.order_email).to eq("[email protected]") | ||
end | ||
end | ||
end | ||
end |