mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Variable naming
This commit is contained in:
@@ -6,32 +6,32 @@ module OpenFoodNetwork
|
||||
|
||||
describe "finding the account balance of a user with a hub" do
|
||||
|
||||
let!(:usr) { create(:user) }
|
||||
let!(:entrprs) { create(:distributor_enterprise) }
|
||||
let!(:user1) { create(:user) }
|
||||
let!(:hub1) { create(:distributor_enterprise) }
|
||||
|
||||
let!(:o1) { create(:order_with_totals_and_distribution, user: usr, distributor: entrprs) } #total=10
|
||||
let!(:o2) { create(:order_with_totals_and_distribution, user: usr, distributor: entrprs) } #total=10
|
||||
let!(:o1) { create(:order_with_totals_and_distribution, user: user1, distributor: hub1) } #total=10
|
||||
let!(:o2) { create(:order_with_totals_and_distribution, user: user1, distributor: hub1) } #total=10
|
||||
let!(:p1) { create(:payment, order: o1, amount: 15.00) }
|
||||
let!(:p2) { create(:payment, order: o2, amount: 10.00) }
|
||||
|
||||
it "finds the user balance for this enterprise" do
|
||||
UserBalanceCalculator.new(usr, entrprs).balance.to_i.should == 5
|
||||
UserBalanceCalculator.new(user1, hub1).balance.to_i.should == 5
|
||||
end
|
||||
|
||||
it "does not find the balance for other enterprises" do
|
||||
entrprs2 = create(:distributor_enterprise)
|
||||
hub2 = create(:distributor_enterprise)
|
||||
o3 = create(:order_with_totals_and_distribution,
|
||||
user: usr, distributor: entrprs2) #total=10
|
||||
user: user1, distributor: hub2) #total=10
|
||||
p3 = create(:payment, order: o3, amount: 10.00)
|
||||
UserBalanceCalculator.new(usr, entrprs2).balance.to_i.should == 0
|
||||
UserBalanceCalculator.new(user1, hub2).balance.to_i.should == 0
|
||||
end
|
||||
|
||||
it "does not find the balance for other users" do
|
||||
usr2 = create(:user)
|
||||
user2 = create(:user)
|
||||
o4 = create(:order_with_totals_and_distribution,
|
||||
user: usr2, distributor: entrprs) #total=10
|
||||
user: user2, distributor: hub1) #total=10
|
||||
p3 = create(:payment, order: o4, amount: 20.00)
|
||||
UserBalanceCalculator.new(usr2, entrprs).balance.to_i.should == 10
|
||||
UserBalanceCalculator.new(user2, hub1).balance.to_i.should == 10
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user