Skip to content

Commit

Permalink
FIX typos
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyli97 committed Oct 17, 2024
1 parent 94c1d91 commit 9472525
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/controllers/admin/base_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def show

def destroy
@base_item = BaseItem.includes(:items).find(params[:id])
if (@base_item.id = KitCreateService.find_or_create_kit_base_item!.id)
if @base_item.id == KitCreateService.find_or_create_kit_base_item!.id
redirect_to admin_base_items_path, alert: "You cannot delete the Kits base item. This is reserved for all Kits."
elsif @base_item.items.any? && @base_item.destroy
elsif @base_item.items.empty? && @base_item.destroy
redirect_to admin_base_items_path, notice: "Base Item deleted!"
else
redirect_to admin_base_items_path, alert: "Failed to delete Base Item. Are there still items attached?"
Expand Down
10 changes: 5 additions & 5 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def random_record_for_org(org, klass)
# Base Items
# ----------------------------------------------------------------------------

require 'seed_base_items'
seed_base_items
require 'seeds'
Seeds.seed_base_items

# ----------------------------------------------------------------------------
# NDBN Members
Expand Down Expand Up @@ -856,12 +856,12 @@ def seed_quantity(item_name, organization, storage_location, quantity)
# Users invitation status
# ----------------------------------------------------------------------------
# Mark users `invitation_status` as `accepted`
#
#
# Addresses and resolves issue #4689, which can be found in:
# https://github.com/rubyforgood/human-essentials/issues/4689
User.where(invitation_token: nil).each do |user|
User.where(invitation_token: nil).each do |user|
user.update!(
invitation_sent_at: Time.current,
invitation_accepted_at: Time.current
)
end
end
19 changes: 0 additions & 19 deletions lib/seed_base_items.rb

This file was deleted.

21 changes: 21 additions & 0 deletions lib/seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Seeds
def seed_base_items
# Initial starting qty for our test organizations
base_items = File.read(Rails.root.join("db", "base_items.json"))
items_by_category = JSON.parse(base_items)

items_by_category.each do |category, entries|
entries.each do |entry|
BaseItem.find_or_create_by!(
name: entry["name"],
category: category,
partner_key: entry["key"],
updated_at: Time.zone.now,
created_at: Time.zone.now
)
end
end
# Create global 'Kit' base item
KitCreateService.find_or_create_kit_base_item!
end
end
4 changes: 2 additions & 2 deletions spec/factories/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# account_request_id :integer
# ndbn_member_id :bigint
#
require 'seed_base_items'
require 'seeds'

FactoryBot.define do
factory :organization do
Expand Down Expand Up @@ -62,7 +62,7 @@

trait :with_items do
after(:create) do |instance, evaluator|
seed_base_items if BaseItem.count.zero? # seeds 45 base items if none exist
Seeds.seed_base_items if BaseItem.count.zero? # seeds 45 base items if none exist
Organization.seed_items(instance) # creates 1 item for each base item
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
create_list(:line_item, 5, :distribution, quantity: 200, item: disposable_item, itemizable: dist)
create_list(:line_item, 5, :distribution, quantity: 300, item: non_disposable_item, itemizable: dist)
end
# within_time total distributed i

infant_distribution = create(:distribution, organization: organization, issued_at: within_time)
toddler_distribution = create(:distribution, organization: organization, issued_at: within_time)
Expand Down

0 comments on commit 9472525

Please sign in to comment.