mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Find customers by user id as well as email
Also fixing up a spec which became brittle due to too much mocking.
This commit is contained in:
@@ -718,7 +718,8 @@ module Spree
|
||||
end
|
||||
|
||||
def find_customer
|
||||
Customer.of(distributor).find_by(email: email_for_customer)
|
||||
user&.customers&.of(distributor)&.first ||
|
||||
Customer.of(distributor).find_by(email: email_for_customer)
|
||||
end
|
||||
|
||||
def create_customer
|
||||
|
||||
@@ -21,10 +21,10 @@ describe Spree::Order do
|
||||
|
||||
context "#save" do
|
||||
context "when associated with a registered user" do
|
||||
let(:user) { double(:user, email: "test@example.com") }
|
||||
let(:user) { Spree::User.new(email: "test@example.com") }
|
||||
|
||||
before do
|
||||
allow(order).to receive_messages user: user
|
||||
order.user = user
|
||||
end
|
||||
|
||||
it "should assign the email address of the user" do
|
||||
|
||||
@@ -975,8 +975,6 @@ describe Spree::Order do
|
||||
end
|
||||
|
||||
it "recognises users with changed email address" do
|
||||
pending "#9002"
|
||||
|
||||
order.update!(state: "complete")
|
||||
|
||||
# Change email instantly without confirmation via Devise:
|
||||
|
||||
Reference in New Issue
Block a user