Exclude Accounts & Billing distributor

This commit is contained in:
Steve Pettitt
2016-04-26 03:14:13 +01:00
parent 0b820361de
commit 7f38f1dd1c
2 changed files with 11 additions and 1 deletions

View File

@@ -56,7 +56,10 @@ Spree.user_class.class_eval do
# Returns Enterprise IDs for distributors that the user has shopped at
def enterprises_ordered_from
orders.where(state: :complete).map(&:distributor_id).uniq
orders.where(state: :complete)
.where('distributor_id != ?', Spree::Config.accounts_distributor_id)
.map(&:distributor_id)
.uniq
end
# Returns orders and their associated payments for all distributors that have been ordered from

View File

@@ -13,6 +13,8 @@ feature %q{
let!(:distributor2) { create(:distributor_enterprise) }
let!(:distributor_credit) { create(:distributor_enterprise) }
let!(:distributor_without_orders) { create(:distributor_enterprise) }
let!(:accounts_distributor) {create :distributor_enterprise}
let!(:order_account_invoice) { create(:order, distributor: accounts_distributor, user: user) }
let!(:d1o1) { create(:completed_order_with_totals, distributor_id: distributor1.id, user_id: user.id, total: 10000)}
let!(:d1o2) { create(:order_without_full_payment, distributor_id: distributor1.id, user_id: user.id, total: 5000)}
let!(:d2o1) { create(:completed_order_with_totals, distributor_id: distributor2.id, user_id: user.id)}
@@ -21,19 +23,24 @@ feature %q{
before do
Spree::Config.accounts_distributor_id = accounts_distributor.id
credit_order.update!
login_as user
visit "/account"
end
it "shows all hubs that have been ordered from with balance or credit" do
# Single test to avoid re-rendering page
expect(page).to have_content distributor1.name
expect(page).to have_content distributor2.name
expect(page).not_to have_content distributor_without_orders.name
# Exclude the special Accounts & Billing distributor
expect(page).not_to have_content accounts_distributor.name
expect(page).to have_content distributor1.name + " " + "Balance due"
expect(page).to have_content distributor_credit.name + " Credit"
end
it "reveals table of orders for distributors when clicked" do
expand_active_table_node distributor1.name
expect(page).to have_link "Order " + d1o1.number, href:"/orders/#{d1o1.number}"