Skip to content

Commit b78c0d7

Browse files
5062: Fix problem with bank addresses in seed (#5144)
1 parent 9a98627 commit b78c0d7

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

db/seeds.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ def random_record_for_org(org, klass)
2323
# Base Items
2424
# ----------------------------------------------------------------------------
2525

26-
require 'seeds'
26+
require "seeds"
2727
Seeds.seed_base_items
2828

2929
# ----------------------------------------------------------------------------
3030
# NDBN Members
3131
# ----------------------------------------------------------------------------
32-
seed_file = File.open(Rails.root.join("spec", "fixtures", "ndbn-small-import.csv"))
32+
seed_file = Rails.root.join("spec", "fixtures", "ndbn-small-import.csv").open
3333
SyncNDBNMembers.upload(seed_file)
3434

3535
# ----------------------------------------------------------------------------
@@ -40,7 +40,7 @@ def random_record_for_org(org, klass)
4040
organization.name = "Pawnee Diaper Bank"
4141
organization.street = "P.O. Box 22613"
4242
organization.city = "Pawnee"
43-
organization.state = "Indiana"
43+
organization.state = "IN"
4444
organization.zipcode = "12345"
4545
organization.email = "[email protected]"
4646
end
@@ -131,7 +131,7 @@ def seed_random_item_with_name(organization, name)
131131
end
132132

133133
# ----------------------------------------------------------------------------
134-
# Item < - > ItemCategory
134+
# Item <-> ItemCategory
135135
# ----------------------------------------------------------------------------
136136

137137
Organization.all.find_each do |org|
@@ -154,10 +154,8 @@ def seed_random_item_with_name(organization, name)
154154
org.item_categories.sample(total_item_categories_to_add).each do |item_category|
155155
partner_group_one.item_categories << item_category
156156
end
157-
158-
next unless org.name == pdx_org.name
159-
160-
partner_group_two = FactoryBot.create(:partner_group, organization: org)
157+
next unless org.name== pdx_org.name
158+
partner_group_two=FactoryBot.create(:partner_group, organization: org)
161159
org.item_categories.each do |item_category|
162160
partner_group_two.item_categories << item_category
163161
end
@@ -619,7 +617,7 @@ def seed_quantity(item_name, organization, storage_location, quantity)
619617
AdjustmentCreateService.new(adjustment).call
620618
end
621619

622-
JSON.parse(File.read(Rails.root.join("db", "base_items.json"))).each do |_category, entries|
620+
JSON.parse(Rails.root.join("db", "base_items.json").read).each do |_category, entries|
623621
entries.each do |entry|
624622
seed_quantity(entry["name"], pdx_org, inv_arbor, entry["qty"]["arbor"])
625623
seed_quantity(entry["name"], pdx_org, inv_pdxdb, entry["qty"]["pdxdb"])
@@ -828,7 +826,7 @@ def seed_quantity(item_name, organization, storage_location, quantity)
828826
amount_spent_on_other_cents: rand(0..5_000)
829827
)
830828

831-
purchase.amount_spent_in_cents = amount_items.map { |i| purchase.send("amount_spent_on_#{i}_cents") }.sum
829+
purchase.amount_spent_in_cents = amount_items.map { |i| purchase.send(:"amount_spent_on_#{i}_cents") }.sum
832830

833831
rand(1..5).times do
834832
purchase.line_items.push(
@@ -965,7 +963,7 @@ def seed_quantity(item_name, organization, storage_location, quantity)
965963
organization_id: pdx_org.id,
966964
from_id: from_id,
967965
to_id: to_id,
968-
line_items: [ LineItem.new(quantity: quantity, item: item) ]
966+
line_items: [LineItem.new(quantity: quantity, item: item)]
969967
)
970968
TransferCreateService.call(transfer)
971969

0 commit comments

Comments
 (0)