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:
Maikel Linke
2022-09-14 15:44:45 +10:00
committed by Konrad
parent cf634d8d9b
commit 9dbba35019
3 changed files with 4 additions and 5 deletions

View File

@@ -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