Improve associating customer specs

This commit is contained in:
Matt-Yorkley
2018-03-03 12:42:42 +00:00
committed by Maikel Linke
parent 5f2e72e3d4
commit 357ff5fb7d
2 changed files with 10 additions and 3 deletions

View File

@@ -469,6 +469,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
let!(:customer) { create(:customer, user: user, enterprise: distributor) }
it "shows just products" do
visit shop_path
shows_products_without_customer_warning
end
end
@@ -477,6 +478,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
let!(:role) { create(:enterprise_role, user: user, enterprise: distributor) }
it "shows just products" do
visit shop_path
shows_products_without_customer_warning
end
end
@@ -488,6 +490,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
end
it "shows just products" do
visit shop_path
shows_products_without_customer_warning
end
end
@@ -501,6 +504,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
end
it "shows the products without customer only message" do
visit shop_path
shows_products_without_customer_warning
end
end
@@ -508,7 +512,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
end
def shows_products_without_customer_warning
visit shop_path
expect(page).to have_no_content "This shop is for customers only."
expect(page).to have_content product.name
end

View File

@@ -80,12 +80,16 @@ describe Spree.user_class do
context "with the the same email as existing customers" do
let(:email) { Faker::Internet.email }
let!(:customer1) { create(:customer, user: nil, email: email) }
let!(:customer2) { create(:customer, user: nil, email: email) }
let(:enterprise1) { create(:enterprise) }
let(:enterprise2) { create(:enterprise) }
let!(:customer1) { create(:customer, user: nil, email: email, enterprise: enterprise1) }
let!(:customer2) { create(:customer, user: nil, email: email, enterprise: enterprise2) }
let!(:user) { create(:user, email: email) }
it "should associate these customers with the created user" do
expect(user.customers.reload).to include customer1, customer2
expect(user.customer_of(enterprise1)).to be_truthy
expect(user.customer_of(enterprise2)).to be_truthy
end
end
end