From 2b12f2c78a93f225ff4650805f664365282c5967 Mon Sep 17 00:00:00 2001 From: PeterNotFound114 <98713019+PeterNotFound114@users.noreply.github.com> Date: Fri, 7 Mar 2025 21:05:00 +0000 Subject: [PATCH 1/6] added context files and refactored factories --- test/contexts.rb | 0 test/factories/certification_types.rb | 0 test/factories/certifications.rb | 0 test/factories/charge_types.rb | 0 test/factories/faq.rb | 0 test/factories/memberships.rb | 0 test/factories/notes.rb | 0 test/factories/organization_build_statuses.rb | 0 test/factories/organization_build_steps.rb | 0 test/factories/organization_categories.rb | 0 test/factories/organization_timeline_entries.rb | 0 test/factories/organizations.rb | 0 test/factories/participants.rb | 0 test/factories/scissor_lift_checkouts.rb | 0 test/factories/scissor_lifts.rb | 0 test/factories/store_items.rb | 0 test/factories/tool_inventories.rb | 0 test/factories/tool_inventory_tools.rb | 0 test/factories/tool_types.rb | 0 test/factories/tools.rb | 0 test/sets/certification_types.rb | 0 test/sets/certifications.rb | 0 test/sets/charge_types.rb | 0 test/sets/faq.rb | 0 test/sets/memberships.rb | 0 test/sets/notes.rb | 0 test/sets/organization_build_statuses.rb | 0 test/sets/organization_build_steps.rb | 0 test/sets/organization_categories.rb | 0 test/sets/organization_timeline_entries.rb | 0 test/sets/organizations.rb | 0 test/sets/participants.rb | 0 test/sets/scissor_lift_checkouts.rb | 0 test/sets/scissor_lifts.rb | 0 test/sets/store_items.rb | 0 test/sets/tool_inventories.rb | 0 test/sets/tool_inventory_tools.rb | 0 test/sets/tool_types.rb | 0 test/sets/tools.rb | 0 39 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/contexts.rb create mode 100644 test/factories/certification_types.rb create mode 100644 test/factories/certifications.rb create mode 100644 test/factories/charge_types.rb create mode 100644 test/factories/faq.rb create mode 100644 test/factories/memberships.rb create mode 100644 test/factories/notes.rb create mode 100644 test/factories/organization_build_statuses.rb create mode 100644 test/factories/organization_build_steps.rb create mode 100644 test/factories/organization_categories.rb create mode 100644 test/factories/organization_timeline_entries.rb create mode 100644 test/factories/organizations.rb create mode 100644 test/factories/participants.rb create mode 100644 test/factories/scissor_lift_checkouts.rb create mode 100644 test/factories/scissor_lifts.rb create mode 100644 test/factories/store_items.rb create mode 100644 test/factories/tool_inventories.rb create mode 100644 test/factories/tool_inventory_tools.rb create mode 100644 test/factories/tool_types.rb create mode 100644 test/factories/tools.rb create mode 100644 test/sets/certification_types.rb create mode 100644 test/sets/certifications.rb create mode 100644 test/sets/charge_types.rb create mode 100644 test/sets/faq.rb create mode 100644 test/sets/memberships.rb create mode 100644 test/sets/notes.rb create mode 100644 test/sets/organization_build_statuses.rb create mode 100644 test/sets/organization_build_steps.rb create mode 100644 test/sets/organization_categories.rb create mode 100644 test/sets/organization_timeline_entries.rb create mode 100644 test/sets/organizations.rb create mode 100644 test/sets/participants.rb create mode 100644 test/sets/scissor_lift_checkouts.rb create mode 100644 test/sets/scissor_lifts.rb create mode 100644 test/sets/store_items.rb create mode 100644 test/sets/tool_inventories.rb create mode 100644 test/sets/tool_inventory_tools.rb create mode 100644 test/sets/tool_types.rb create mode 100644 test/sets/tools.rb diff --git a/test/contexts.rb b/test/contexts.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/certification_types.rb b/test/factories/certification_types.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/certifications.rb b/test/factories/certifications.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/charge_types.rb b/test/factories/charge_types.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/faq.rb b/test/factories/faq.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/memberships.rb b/test/factories/memberships.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/notes.rb b/test/factories/notes.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/organization_build_statuses.rb b/test/factories/organization_build_statuses.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/organization_build_steps.rb b/test/factories/organization_build_steps.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/organization_categories.rb b/test/factories/organization_categories.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/organization_timeline_entries.rb b/test/factories/organization_timeline_entries.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/organizations.rb b/test/factories/organizations.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/participants.rb b/test/factories/participants.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/scissor_lift_checkouts.rb b/test/factories/scissor_lift_checkouts.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/scissor_lifts.rb b/test/factories/scissor_lifts.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/store_items.rb b/test/factories/store_items.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/tool_inventories.rb b/test/factories/tool_inventories.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/tool_inventory_tools.rb b/test/factories/tool_inventory_tools.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/tool_types.rb b/test/factories/tool_types.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factories/tools.rb b/test/factories/tools.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/certification_types.rb b/test/sets/certification_types.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/certifications.rb b/test/sets/certifications.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/charge_types.rb b/test/sets/charge_types.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/faq.rb b/test/sets/faq.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/memberships.rb b/test/sets/memberships.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/notes.rb b/test/sets/notes.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/organization_build_statuses.rb b/test/sets/organization_build_statuses.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/organization_build_steps.rb b/test/sets/organization_build_steps.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/organization_categories.rb b/test/sets/organization_categories.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/organization_timeline_entries.rb b/test/sets/organization_timeline_entries.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/organizations.rb b/test/sets/organizations.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/participants.rb b/test/sets/participants.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/scissor_lift_checkouts.rb b/test/sets/scissor_lift_checkouts.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/scissor_lifts.rb b/test/sets/scissor_lifts.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/store_items.rb b/test/sets/store_items.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/tool_inventories.rb b/test/sets/tool_inventories.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/tool_inventory_tools.rb b/test/sets/tool_inventory_tools.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/tool_types.rb b/test/sets/tool_types.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/sets/tools.rb b/test/sets/tools.rb new file mode 100644 index 00000000..e69de29b From 1642f68ab053db9514cc7ab2cce192160d4bf713 Mon Sep 17 00:00:00 2001 From: PeterNotFound114 <98713019+PeterNotFound114@users.noreply.github.com> Date: Fri, 7 Mar 2025 22:00:10 +0000 Subject: [PATCH 2/6] file modules created along with script used to make it happen --- test/contexts.rb | 19 +++++++++++++++++++ test/make_sets.sh | 22 ++++++++++++++++++++++ test/sets/certification_types.rb | 12 ++++++++++++ test/sets/certifications.rb | 12 ++++++++++++ test/sets/charge_types.rb | 12 ++++++++++++ test/sets/faq.rb | 12 ++++++++++++ test/sets/memberships.rb | 12 ++++++++++++ test/sets/notes.rb | 12 ++++++++++++ test/sets/organization_build_statuses.rb | 12 ++++++++++++ test/sets/organization_build_steps.rb | 12 ++++++++++++ test/sets/organization_categories.rb | 12 ++++++++++++ test/sets/organization_timeline_entries.rb | 12 ++++++++++++ test/sets/organizations.rb | 12 ++++++++++++ test/sets/participants.rb | 12 ++++++++++++ test/sets/scissor_lift_checkouts.rb | 12 ++++++++++++ test/sets/scissor_lifts.rb | 12 ++++++++++++ test/sets/store_items.rb | 12 ++++++++++++ test/sets/tool_inventories.rb | 12 ++++++++++++ test/sets/tool_inventory_tools.rb | 12 ++++++++++++ test/sets/tool_types.rb | 12 ++++++++++++ test/sets/tools.rb | 12 ++++++++++++ test/test.sh | 3 +++ 22 files changed, 272 insertions(+) create mode 100755 test/make_sets.sh create mode 100755 test/test.sh diff --git a/test/contexts.rb b/test/contexts.rb index e69de29b..87b0f033 100644 --- a/test/contexts.rb +++ b/test/contexts.rb @@ -0,0 +1,19 @@ +require "test/sets/certification_types" +require "test/sets/certifications" +require "test/sets/charge_types" +require "test/sets/faq" +require "test/sets/memberships" +require "test/sets/notes" +require "test/sets/organization_build_statuses" +require "test/sets/organization_build_steps" +require "test/sets/organization_categories" +require "test/sets/organization_timeline_entries" +require "test/sets/organizations" +require "test/sets/participants" +require "test/sets/scissor_lift_checkouts" +require "test/sets/scissor_lifts" +require "test/sets/store_items" +require "test/sets/tool_inventories" +require "test/sets/tool_inventory_tools" +require "test/sets/tool_types" +require "test/sets/tools" diff --git a/test/make_sets.sh b/test/make_sets.sh new file mode 100755 index 00000000..0465fd2c --- /dev/null +++ b/test/make_sets.sh @@ -0,0 +1,22 @@ +for file in $(ls ./fixtures); do + name=$(cut -d "." -f 1 <<< $file) + module_name="" + num_words=$(tr -dc '_' <<< $name | wc -c) + for n in $(seq 1 $((num_words+1))); do + w=$(cut -d "_" -f $n <<< $name) + module_name+=${w^} + done + echo "module Contexts + module ${module_name} + def create_${name} + + end + + def destroy_${name} + + end + end + end + " >> ./sets/${name}.rb + echo "require \"test/sets/${name}\"" >> ./contexts.rb +done \ No newline at end of file diff --git a/test/sets/certification_types.rb b/test/sets/certification_types.rb index e69de29b..682c7702 100644 --- a/test/sets/certification_types.rb +++ b/test/sets/certification_types.rb @@ -0,0 +1,12 @@ +module Contexts + module CertificationTypes + def create_certification_types + + end + + def destroy_certification_types + + end + end + end + diff --git a/test/sets/certifications.rb b/test/sets/certifications.rb index e69de29b..834d4847 100644 --- a/test/sets/certifications.rb +++ b/test/sets/certifications.rb @@ -0,0 +1,12 @@ +module Contexts + module Certifications + def create_certifications + + end + + def destroy_certifications + + end + end + end + diff --git a/test/sets/charge_types.rb b/test/sets/charge_types.rb index e69de29b..550448c3 100644 --- a/test/sets/charge_types.rb +++ b/test/sets/charge_types.rb @@ -0,0 +1,12 @@ +module Contexts + module ChargeTypes + def create_charge_types + + end + + def destroy_charge_types + + end + end + end + diff --git a/test/sets/faq.rb b/test/sets/faq.rb index e69de29b..202f2b61 100644 --- a/test/sets/faq.rb +++ b/test/sets/faq.rb @@ -0,0 +1,12 @@ +module Contexts + module FAQ + def create_faq + + end + + def destroy_faq + + end + end + end + diff --git a/test/sets/memberships.rb b/test/sets/memberships.rb index e69de29b..13ee1bbe 100644 --- a/test/sets/memberships.rb +++ b/test/sets/memberships.rb @@ -0,0 +1,12 @@ +module Contexts + module Memberships + def create_memberships + + end + + def destroy_memberships + + end + end + end + diff --git a/test/sets/notes.rb b/test/sets/notes.rb index e69de29b..8e9f4776 100644 --- a/test/sets/notes.rb +++ b/test/sets/notes.rb @@ -0,0 +1,12 @@ +module Contexts + module Notes + def create_notes + + end + + def destroy_notes + + end + end + end + diff --git a/test/sets/organization_build_statuses.rb b/test/sets/organization_build_statuses.rb index e69de29b..db04b069 100644 --- a/test/sets/organization_build_statuses.rb +++ b/test/sets/organization_build_statuses.rb @@ -0,0 +1,12 @@ +module Contexts + module OrganizationBuildStatuses + def create_organization_build_statuses + + end + + def destroy_organization_build_statuses + + end + end + end + diff --git a/test/sets/organization_build_steps.rb b/test/sets/organization_build_steps.rb index e69de29b..3b465a51 100644 --- a/test/sets/organization_build_steps.rb +++ b/test/sets/organization_build_steps.rb @@ -0,0 +1,12 @@ +module Contexts + module OrganizationBuildSteps + def create_organization_build_steps + + end + + def destroy_organization_build_steps + + end + end + end + diff --git a/test/sets/organization_categories.rb b/test/sets/organization_categories.rb index e69de29b..f7de9848 100644 --- a/test/sets/organization_categories.rb +++ b/test/sets/organization_categories.rb @@ -0,0 +1,12 @@ +module Contexts + module OrganizationCategories + def create_organization_categories + + end + + def destroy_organization_categories + + end + end + end + diff --git a/test/sets/organization_timeline_entries.rb b/test/sets/organization_timeline_entries.rb index e69de29b..b1597159 100644 --- a/test/sets/organization_timeline_entries.rb +++ b/test/sets/organization_timeline_entries.rb @@ -0,0 +1,12 @@ +module Contexts + module OrganizationTimelineEntries + def create_organization_timeline_entries + + end + + def destroy_organization_timeline_entries + + end + end + end + diff --git a/test/sets/organizations.rb b/test/sets/organizations.rb index e69de29b..da74e02d 100644 --- a/test/sets/organizations.rb +++ b/test/sets/organizations.rb @@ -0,0 +1,12 @@ +module Contexts + module Organizations + def create_organizations + + end + + def destroy_organizations + + end + end + end + diff --git a/test/sets/participants.rb b/test/sets/participants.rb index e69de29b..0331ed73 100644 --- a/test/sets/participants.rb +++ b/test/sets/participants.rb @@ -0,0 +1,12 @@ +module Contexts + module Participants + def create_participants + + end + + def destroy_participants + + end + end + end + diff --git a/test/sets/scissor_lift_checkouts.rb b/test/sets/scissor_lift_checkouts.rb index e69de29b..12173927 100644 --- a/test/sets/scissor_lift_checkouts.rb +++ b/test/sets/scissor_lift_checkouts.rb @@ -0,0 +1,12 @@ +module Contexts + module ScissorLiftCheckouts + def create_scissor_lift_checkouts + + end + + def destroy_scissor_lift_checkouts + + end + end + end + diff --git a/test/sets/scissor_lifts.rb b/test/sets/scissor_lifts.rb index e69de29b..e0f3ea65 100644 --- a/test/sets/scissor_lifts.rb +++ b/test/sets/scissor_lifts.rb @@ -0,0 +1,12 @@ +module Contexts + module ScissorLifts + def create_scissor_lifts + + end + + def destroy_scissor_lifts + + end + end + end + diff --git a/test/sets/store_items.rb b/test/sets/store_items.rb index e69de29b..02edde45 100644 --- a/test/sets/store_items.rb +++ b/test/sets/store_items.rb @@ -0,0 +1,12 @@ +module Contexts + module StoreItems + def create_store_items + + end + + def destroy_store_items + + end + end + end + diff --git a/test/sets/tool_inventories.rb b/test/sets/tool_inventories.rb index e69de29b..62cf4bd0 100644 --- a/test/sets/tool_inventories.rb +++ b/test/sets/tool_inventories.rb @@ -0,0 +1,12 @@ +module Contexts + module ToolInventories + def create_tool_inventories + + end + + def destroy_tool_inventories + + end + end + end + diff --git a/test/sets/tool_inventory_tools.rb b/test/sets/tool_inventory_tools.rb index e69de29b..ae61a602 100644 --- a/test/sets/tool_inventory_tools.rb +++ b/test/sets/tool_inventory_tools.rb @@ -0,0 +1,12 @@ +module Contexts + module ToolInventoryTools + def create_tool_inventory_tools + + end + + def destroy_tool_inventory_tools + + end + end + end + diff --git a/test/sets/tool_types.rb b/test/sets/tool_types.rb index e69de29b..453645ae 100644 --- a/test/sets/tool_types.rb +++ b/test/sets/tool_types.rb @@ -0,0 +1,12 @@ +module Contexts + module ToolTypes + def create_tool_types + + end + + def destroy_tool_types + + end + end + end + diff --git a/test/sets/tools.rb b/test/sets/tools.rb index e69de29b..0174876d 100644 --- a/test/sets/tools.rb +++ b/test/sets/tools.rb @@ -0,0 +1,12 @@ +module Contexts + module Tools + def create_tools + + end + + def destroy_tools + + end + end + end + diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 00000000..3273069c --- /dev/null +++ b/test/test.sh @@ -0,0 +1,3 @@ +testing="" +tr -dc '.' <<< $TESTVARIABLE | wc -c +echo $testing \ No newline at end of file From bb1f569146ba11b15ecb0998eb6311ffa46b0341 Mon Sep 17 00:00:00 2001 From: PeterNotFound114 <98713019+PeterNotFound114@users.noreply.github.com> Date: Fri, 7 Mar 2025 23:43:36 +0000 Subject: [PATCH 3/6] setting up contexts from db schema instead of deprecated fixtures --- test/contexts.rb | 122 ++++++++++++++++++ test/factories/certification_types.rb | 5 + test/factories/certifications.rb | 4 + test/factories/charge_types.rb | 4 + test/factories/charges.rb | 4 + test/factories/checkouts.rb | 4 + test/factories/delayed_jobs.rb | 4 + test/factories/event_types.rb | 4 + test/factories/events.rb | 4 + test/factories/faq.rb | 4 + test/factories/memberships.rb | 4 + test/factories/notes.rb | 4 + test/factories/organization_aliases.rb | 4 + test/factories/organization_build_statuses.rb | 4 + test/factories/organization_build_steps.rb | 4 + test/factories/organization_categories.rb | 4 + test/factories/organization_status_types.rb | 4 + .../organization_timeline_entries.rb | 4 + .../organization_timeline_entry_types.rb | 4 + test/factories/organizations.rb | 4 + test/factories/participants.rb | 4 + test/factories/scissor_lift_checkouts.rb | 4 + test/factories/scissor_lifts.rb | 4 + test/factories/shift_participants.rb | 4 + test/factories/shift_types.rb | 4 + test/factories/shifts.rb | 4 + test/factories/store_items.rb | 4 + test/factories/store_purchases.rb | 4 + test/factories/tasks.rb | 4 + test/factories/tool_inventories.rb | 4 + test/factories/tool_inventory_tools.rb | 4 + test/factories/tool_type_certifications.rb | 4 + test/factories/tool_types.rb | 4 + test/factories/tools.rb | 4 + test/make_sets.sh | 4 +- test/sets/certification_types.rb | 48 +++++++ test/sets/certifications.rb | 48 +++++++ test/sets/charge_types.rb | 48 +++++++ test/sets/charges.rb | 60 +++++++++ test/sets/checkouts.rb | 60 +++++++++ test/sets/delayed_jobs.rb | 60 +++++++++ test/sets/event_types.rb | 60 +++++++++ test/sets/events.rb | 60 +++++++++ test/sets/faq.rb | 50 ++++++- test/sets/memberships.rb | 48 +++++++ test/sets/notes.rb | 48 +++++++ test/sets/organization_aliases.rb | 60 +++++++++ test/sets/organization_build_statuses.rb | 48 +++++++ test/sets/organization_build_steps.rb | 48 +++++++ test/sets/organization_categories.rb | 48 +++++++ test/sets/organization_status_types.rb | 60 +++++++++ test/sets/organization_timeline_entries.rb | 48 +++++++ .../sets/organization_timeline_entry_types.rb | 60 +++++++++ test/sets/organizations.rb | 48 +++++++ test/sets/participants.rb | 48 +++++++ test/sets/scissor_lift_checkouts.rb | 48 +++++++ test/sets/scissor_lifts.rb | 48 +++++++ test/sets/shift_participants.rb | 60 +++++++++ test/sets/shift_types.rb | 60 +++++++++ test/sets/shifts.rb | 60 +++++++++ test/sets/store_items.rb | 48 +++++++ test/sets/store_purchases.rb | 60 +++++++++ test/sets/tasks.rb | 60 +++++++++ test/sets/tool_inventories.rb | 48 +++++++ test/sets/tool_inventory_tools.rb | 48 +++++++ test/sets/tool_type_certifications.rb | 60 +++++++++ test/sets/tool_types.rb | 48 +++++++ test/sets/tools.rb | 48 +++++++ test/test.sh | 3 - 69 files changed, 2010 insertions(+), 6 deletions(-) create mode 100644 test/factories/charges.rb create mode 100644 test/factories/checkouts.rb create mode 100644 test/factories/delayed_jobs.rb create mode 100644 test/factories/event_types.rb create mode 100644 test/factories/events.rb create mode 100644 test/factories/organization_aliases.rb create mode 100644 test/factories/organization_status_types.rb create mode 100644 test/factories/organization_timeline_entry_types.rb create mode 100644 test/factories/shift_participants.rb create mode 100644 test/factories/shift_types.rb create mode 100644 test/factories/shifts.rb create mode 100644 test/factories/store_purchases.rb create mode 100644 test/factories/tasks.rb create mode 100644 test/factories/tool_type_certifications.rb create mode 100644 test/sets/charges.rb create mode 100644 test/sets/checkouts.rb create mode 100644 test/sets/delayed_jobs.rb create mode 100644 test/sets/event_types.rb create mode 100644 test/sets/events.rb create mode 100644 test/sets/organization_aliases.rb create mode 100644 test/sets/organization_status_types.rb create mode 100644 test/sets/organization_timeline_entry_types.rb create mode 100644 test/sets/shift_participants.rb create mode 100644 test/sets/shift_types.rb create mode 100644 test/sets/shifts.rb create mode 100644 test/sets/store_purchases.rb create mode 100644 test/sets/tasks.rb create mode 100644 test/sets/tool_type_certifications.rb delete mode 100755 test/test.sh diff --git a/test/contexts.rb b/test/contexts.rb index 87b0f033..c824dbf1 100644 --- a/test/contexts.rb +++ b/test/contexts.rb @@ -1,19 +1,141 @@ require "test/sets/certification_types" require "test/sets/certifications" require "test/sets/charge_types" +require "test/sets/charges" +require "test/sets/checkouts" +require "test/sets/delayed_jobs" +require "test/sets/event_types" +require "test/sets/events" require "test/sets/faq" require "test/sets/memberships" require "test/sets/notes" +require "test/sets/organization_aliases" require "test/sets/organization_build_statuses" require "test/sets/organization_build_steps" require "test/sets/organization_categories" +require "test/sets/organization_status_types" require "test/sets/organization_timeline_entries" +require "test/sets/organization_timeline_entry_types" require "test/sets/organizations" require "test/sets/participants" require "test/sets/scissor_lift_checkouts" require "test/sets/scissor_lifts" +require "test/sets/shift_participants" +require "test/sets/shift_types" +require "test/sets/shifts" require "test/sets/store_items" +require "test/sets/store_purchases" +require "test/sets/tasks" require "test/sets/tool_inventories" require "test/sets/tool_inventory_tools" +require "test/sets/tool_type_certifications" require "test/sets/tool_types" require "test/sets/tools" + +module Contexts + include Contexts::CertificationTypes + include Contexts::Certifications + include Contexts::ChargeTypes + include Contexts::Charges + include Contexts::Checkouts + include Contexts::DelayedJobs + include Contexts::EventTypes + include Contexts::Events + include Contexts::Faq + include Contexts::Memberships + include Contexts::Notes + include Contexts::OrganizationAliases + include Contexts::OrganizationBuildStatuses + include Contexts::OrganizationBuildSteps + include Contexts::OrganizationCategories + include Contexts::OrganizationStatusTypes + include Contexts::OrganizationTimelineEntries + include Contexts::OrganizationTimelineEntryTypes + include Contexts::Organizations + include Contexts::Participants + include Contexts::ScissorLiftCheckouts + include Contexts::ScissorLifts + include Contexts::ShiftParticipants + include Contexts::ShiftTypes + include Contexts::Shifts + include Contexts::StoreItems + include Contexts::StorePurchases + include Contexts::Tasks + include Contexts::ToolInventories + include Contexts::ToolInventoryTools + include Contexts::ToolTypeCertifications + include Contexts::ToolTypes + include Contexts::Tools + + def create_all + create_certification_types + create_certifications + create_charge_types + create_charges + create_checkouts + create_delayed_jobs + create_event_types + create_events + create_faq + create_memberships + create_notes + create_organization_aliases + create_organization_build_statuses + create_organization_build_steps + create_organization_categories + create_organization_status_types + create_organization_timeline_entries + create_organization_timeline_entry_types + create_organizations + create_participants + create_scissor_lift_checkouts + create_scissor_lifts + create_shift_participants + create_shift_types + create_shifts + create_store_items + create_store_purchases + create_tasks + create_tool_inventories + create_tool_inventory_tools + create_tool_type_certifications + create_tool_types + create_tools + end + + def destroy_all + destroy_certification_types + destroy_certifications + destroy_charge_types + destroy_charges + destroy_checkouts + destroy_delayed_jobs + destroy_event_types + destroy_events + destroy_faq + destroy_memberships + destroy_notes + destroy_organization_aliases + destroy_organization_build_statuses + destroy_organization_build_steps + destroy_organization_categories + destroy_organization_status_types + destroy_organization_timeline_entries + destroy_organization_timeline_entry_types + destroy_organizations + destroy_participants + destroy_scissor_lift_checkouts + destroy_scissor_lifts + destroy_shift_participants + destroy_shift_types + destroy_shifts + destroy_store_items + destroy_store_purchases + destroy_tasks + destroy_tool_inventories + destroy_tool_inventory_tools + destroy_tool_type_certifications + destroy_tool_types + destroy_tools + end +end diff --git a/test/factories/certification_types.rb b/test/factories/certification_types.rb index e69de29b..3e133c11 100644 --- a/test/factories/certification_types.rb +++ b/test/factories/certification_types.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :certification_types do + + end +end diff --git a/test/factories/certifications.rb b/test/factories/certifications.rb index e69de29b..7d3f1697 100644 --- a/test/factories/certifications.rb +++ b/test/factories/certifications.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :certifications do + end +end diff --git a/test/factories/charge_types.rb b/test/factories/charge_types.rb index e69de29b..43001eef 100644 --- a/test/factories/charge_types.rb +++ b/test/factories/charge_types.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :charge_types do + end +end diff --git a/test/factories/charges.rb b/test/factories/charges.rb new file mode 100644 index 00000000..822d35eb --- /dev/null +++ b/test/factories/charges.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :charges do + end +end diff --git a/test/factories/checkouts.rb b/test/factories/checkouts.rb new file mode 100644 index 00000000..1ff6ee1e --- /dev/null +++ b/test/factories/checkouts.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :checkouts do + end +end diff --git a/test/factories/delayed_jobs.rb b/test/factories/delayed_jobs.rb new file mode 100644 index 00000000..2134d196 --- /dev/null +++ b/test/factories/delayed_jobs.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :delayed_jobs do + end +end diff --git a/test/factories/event_types.rb b/test/factories/event_types.rb new file mode 100644 index 00000000..344b216b --- /dev/null +++ b/test/factories/event_types.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :event_types do + end +end diff --git a/test/factories/events.rb b/test/factories/events.rb new file mode 100644 index 00000000..1e95360c --- /dev/null +++ b/test/factories/events.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :events do + end +end diff --git a/test/factories/faq.rb b/test/factories/faq.rb index e69de29b..effa54ae 100644 --- a/test/factories/faq.rb +++ b/test/factories/faq.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :faq do + end +end diff --git a/test/factories/memberships.rb b/test/factories/memberships.rb index e69de29b..569140a6 100644 --- a/test/factories/memberships.rb +++ b/test/factories/memberships.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :memberships do + end +end diff --git a/test/factories/notes.rb b/test/factories/notes.rb index e69de29b..e83b668f 100644 --- a/test/factories/notes.rb +++ b/test/factories/notes.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :notes do + end +end diff --git a/test/factories/organization_aliases.rb b/test/factories/organization_aliases.rb new file mode 100644 index 00000000..0d03dd3b --- /dev/null +++ b/test/factories/organization_aliases.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organization_aliases do + end +end diff --git a/test/factories/organization_build_statuses.rb b/test/factories/organization_build_statuses.rb index e69de29b..3f4f04f2 100644 --- a/test/factories/organization_build_statuses.rb +++ b/test/factories/organization_build_statuses.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organization_build_statuses do + end +end diff --git a/test/factories/organization_build_steps.rb b/test/factories/organization_build_steps.rb index e69de29b..cd2c3d98 100644 --- a/test/factories/organization_build_steps.rb +++ b/test/factories/organization_build_steps.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organization_build_steps do + end +end diff --git a/test/factories/organization_categories.rb b/test/factories/organization_categories.rb index e69de29b..1aef2a17 100644 --- a/test/factories/organization_categories.rb +++ b/test/factories/organization_categories.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organization_categories do + end +end diff --git a/test/factories/organization_status_types.rb b/test/factories/organization_status_types.rb new file mode 100644 index 00000000..c0d5d099 --- /dev/null +++ b/test/factories/organization_status_types.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organization_status_types do + end +end diff --git a/test/factories/organization_timeline_entries.rb b/test/factories/organization_timeline_entries.rb index e69de29b..2a6dec83 100644 --- a/test/factories/organization_timeline_entries.rb +++ b/test/factories/organization_timeline_entries.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organization_timeline_entries do + end +end diff --git a/test/factories/organization_timeline_entry_types.rb b/test/factories/organization_timeline_entry_types.rb new file mode 100644 index 00000000..28a4b8d1 --- /dev/null +++ b/test/factories/organization_timeline_entry_types.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organization_timeline_entry_types do + end +end diff --git a/test/factories/organizations.rb b/test/factories/organizations.rb index e69de29b..bf2fb29e 100644 --- a/test/factories/organizations.rb +++ b/test/factories/organizations.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :organizations do + end +end diff --git a/test/factories/participants.rb b/test/factories/participants.rb index e69de29b..2e029bad 100644 --- a/test/factories/participants.rb +++ b/test/factories/participants.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :participants do + end +end diff --git a/test/factories/scissor_lift_checkouts.rb b/test/factories/scissor_lift_checkouts.rb index e69de29b..aa9091c9 100644 --- a/test/factories/scissor_lift_checkouts.rb +++ b/test/factories/scissor_lift_checkouts.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :scissor_lift_checkouts do + end +end diff --git a/test/factories/scissor_lifts.rb b/test/factories/scissor_lifts.rb index e69de29b..62f3c726 100644 --- a/test/factories/scissor_lifts.rb +++ b/test/factories/scissor_lifts.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :scissor_lifts do + end +end diff --git a/test/factories/shift_participants.rb b/test/factories/shift_participants.rb new file mode 100644 index 00000000..b306bbf9 --- /dev/null +++ b/test/factories/shift_participants.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :shift_participants do + end +end diff --git a/test/factories/shift_types.rb b/test/factories/shift_types.rb new file mode 100644 index 00000000..3a9a9d1c --- /dev/null +++ b/test/factories/shift_types.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :shift_types do + end +end diff --git a/test/factories/shifts.rb b/test/factories/shifts.rb new file mode 100644 index 00000000..0e34c97e --- /dev/null +++ b/test/factories/shifts.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :shifts do + end +end diff --git a/test/factories/store_items.rb b/test/factories/store_items.rb index e69de29b..9a3e0e2a 100644 --- a/test/factories/store_items.rb +++ b/test/factories/store_items.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :store_items do + end +end diff --git a/test/factories/store_purchases.rb b/test/factories/store_purchases.rb new file mode 100644 index 00000000..05618148 --- /dev/null +++ b/test/factories/store_purchases.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :store_purchases do + end +end diff --git a/test/factories/tasks.rb b/test/factories/tasks.rb new file mode 100644 index 00000000..d6a48c0a --- /dev/null +++ b/test/factories/tasks.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :tasks do + end +end diff --git a/test/factories/tool_inventories.rb b/test/factories/tool_inventories.rb index e69de29b..a0c5b4ec 100644 --- a/test/factories/tool_inventories.rb +++ b/test/factories/tool_inventories.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :tool_inventories do + end +end diff --git a/test/factories/tool_inventory_tools.rb b/test/factories/tool_inventory_tools.rb index e69de29b..0d6ae2bd 100644 --- a/test/factories/tool_inventory_tools.rb +++ b/test/factories/tool_inventory_tools.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :tool_inventory_tools do + end +end diff --git a/test/factories/tool_type_certifications.rb b/test/factories/tool_type_certifications.rb new file mode 100644 index 00000000..0cf2c787 --- /dev/null +++ b/test/factories/tool_type_certifications.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :tool_type_certifications do + end +end diff --git a/test/factories/tool_types.rb b/test/factories/tool_types.rb index e69de29b..8190e387 100644 --- a/test/factories/tool_types.rb +++ b/test/factories/tool_types.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :tool_types do + end +end diff --git a/test/factories/tools.rb b/test/factories/tools.rb index e69de29b..96c69697 100644 --- a/test/factories/tools.rb +++ b/test/factories/tools.rb @@ -0,0 +1,4 @@ +FactoryBot.define do + factory :tools do + end +end diff --git a/test/make_sets.sh b/test/make_sets.sh index 0465fd2c..8031083c 100755 --- a/test/make_sets.sh +++ b/test/make_sets.sh @@ -1,4 +1,4 @@ -for file in $(ls ./fixtures); do +for file in $(ls ./factories); do name=$(cut -d "." -f 1 <<< $file) module_name="" num_words=$(tr -dc '_' <<< $name | wc -c) @@ -18,5 +18,5 @@ for file in $(ls ./fixtures); do end end " >> ./sets/${name}.rb - echo "require \"test/sets/${name}\"" >> ./contexts.rb + echo "destroy_${name}" >> ./contexts.rb done \ No newline at end of file diff --git a/test/sets/certification_types.rb b/test/sets/certification_types.rb index 682c7702..826a4d7d 100644 --- a/test/sets/certification_types.rb +++ b/test/sets/certification_types.rb @@ -10,3 +10,51 @@ def destroy_certification_types end end +module Contexts + module CertificationTypes + def create_certification_types + + end + + def destroy_certification_types + + end + end + end + +module Contexts + module CertificationTypes + def create_certification_types + + end + + def destroy_certification_types + + end + end + end + +module Contexts + module CertificationTypes + def create_certification_types + + end + + def destroy_certification_types + + end + end + end + +module Contexts + module CertificationTypes + def create_certification_types + + end + + def destroy_certification_types + + end + end + end + diff --git a/test/sets/certifications.rb b/test/sets/certifications.rb index 834d4847..d65c7739 100644 --- a/test/sets/certifications.rb +++ b/test/sets/certifications.rb @@ -10,3 +10,51 @@ def destroy_certifications end end +module Contexts + module Certifications + def create_certifications + + end + + def destroy_certifications + + end + end + end + +module Contexts + module Certifications + def create_certifications + + end + + def destroy_certifications + + end + end + end + +module Contexts + module Certifications + def create_certifications + + end + + def destroy_certifications + + end + end + end + +module Contexts + module Certifications + def create_certifications + + end + + def destroy_certifications + + end + end + end + diff --git a/test/sets/charge_types.rb b/test/sets/charge_types.rb index 550448c3..8dd8c29c 100644 --- a/test/sets/charge_types.rb +++ b/test/sets/charge_types.rb @@ -10,3 +10,51 @@ def destroy_charge_types end end +module Contexts + module ChargeTypes + def create_charge_types + + end + + def destroy_charge_types + + end + end + end + +module Contexts + module ChargeTypes + def create_charge_types + + end + + def destroy_charge_types + + end + end + end + +module Contexts + module ChargeTypes + def create_charge_types + + end + + def destroy_charge_types + + end + end + end + +module Contexts + module ChargeTypes + def create_charge_types + + end + + def destroy_charge_types + + end + end + end + diff --git a/test/sets/charges.rb b/test/sets/charges.rb new file mode 100644 index 00000000..8c72c908 --- /dev/null +++ b/test/sets/charges.rb @@ -0,0 +1,60 @@ +module Contexts + module Charges + def create_charges + + end + + def destroy_charges + + end + end + end + +module Contexts + module Charges + def create_charges + + end + + def destroy_charges + + end + end + end + +module Contexts + module Charges + def create_charges + + end + + def destroy_charges + + end + end + end + +module Contexts + module Charges + def create_charges + + end + + def destroy_charges + + end + end + end + +module Contexts + module Charges + def create_charges + + end + + def destroy_charges + + end + end + end + diff --git a/test/sets/checkouts.rb b/test/sets/checkouts.rb new file mode 100644 index 00000000..e72a2568 --- /dev/null +++ b/test/sets/checkouts.rb @@ -0,0 +1,60 @@ +module Contexts + module Checkouts + def create_checkouts + + end + + def destroy_checkouts + + end + end + end + +module Contexts + module Checkouts + def create_checkouts + + end + + def destroy_checkouts + + end + end + end + +module Contexts + module Checkouts + def create_checkouts + + end + + def destroy_checkouts + + end + end + end + +module Contexts + module Checkouts + def create_checkouts + + end + + def destroy_checkouts + + end + end + end + +module Contexts + module Checkouts + def create_checkouts + + end + + def destroy_checkouts + + end + end + end + diff --git a/test/sets/delayed_jobs.rb b/test/sets/delayed_jobs.rb new file mode 100644 index 00000000..9dc3d5e4 --- /dev/null +++ b/test/sets/delayed_jobs.rb @@ -0,0 +1,60 @@ +module Contexts + module DelayedJobs + def create_delayed_jobs + + end + + def destroy_delayed_jobs + + end + end + end + +module Contexts + module DelayedJobs + def create_delayed_jobs + + end + + def destroy_delayed_jobs + + end + end + end + +module Contexts + module DelayedJobs + def create_delayed_jobs + + end + + def destroy_delayed_jobs + + end + end + end + +module Contexts + module DelayedJobs + def create_delayed_jobs + + end + + def destroy_delayed_jobs + + end + end + end + +module Contexts + module DelayedJobs + def create_delayed_jobs + + end + + def destroy_delayed_jobs + + end + end + end + diff --git a/test/sets/event_types.rb b/test/sets/event_types.rb new file mode 100644 index 00000000..e8b989c3 --- /dev/null +++ b/test/sets/event_types.rb @@ -0,0 +1,60 @@ +module Contexts + module EventTypes + def create_event_types + + end + + def destroy_event_types + + end + end + end + +module Contexts + module EventTypes + def create_event_types + + end + + def destroy_event_types + + end + end + end + +module Contexts + module EventTypes + def create_event_types + + end + + def destroy_event_types + + end + end + end + +module Contexts + module EventTypes + def create_event_types + + end + + def destroy_event_types + + end + end + end + +module Contexts + module EventTypes + def create_event_types + + end + + def destroy_event_types + + end + end + end + diff --git a/test/sets/events.rb b/test/sets/events.rb new file mode 100644 index 00000000..c5b17335 --- /dev/null +++ b/test/sets/events.rb @@ -0,0 +1,60 @@ +module Contexts + module Events + def create_events + + end + + def destroy_events + + end + end + end + +module Contexts + module Events + def create_events + + end + + def destroy_events + + end + end + end + +module Contexts + module Events + def create_events + + end + + def destroy_events + + end + end + end + +module Contexts + module Events + def create_events + + end + + def destroy_events + + end + end + end + +module Contexts + module Events + def create_events + + end + + def destroy_events + + end + end + end + diff --git a/test/sets/faq.rb b/test/sets/faq.rb index 202f2b61..b7887add 100644 --- a/test/sets/faq.rb +++ b/test/sets/faq.rb @@ -1,5 +1,53 @@ module Contexts - module FAQ + module Faq + def create_faq + + end + + def destroy_faq + + end + end + end + +module Contexts + module Faq + def create_faq + + end + + def destroy_faq + + end + end + end + +module Contexts + module Faq + def create_faq + + end + + def destroy_faq + + end + end + end + +module Contexts + module Faq + def create_faq + + end + + def destroy_faq + + end + end + end + +module Contexts + module Faq def create_faq end diff --git a/test/sets/memberships.rb b/test/sets/memberships.rb index 13ee1bbe..81f4f564 100644 --- a/test/sets/memberships.rb +++ b/test/sets/memberships.rb @@ -10,3 +10,51 @@ def destroy_memberships end end +module Contexts + module Memberships + def create_memberships + + end + + def destroy_memberships + + end + end + end + +module Contexts + module Memberships + def create_memberships + + end + + def destroy_memberships + + end + end + end + +module Contexts + module Memberships + def create_memberships + + end + + def destroy_memberships + + end + end + end + +module Contexts + module Memberships + def create_memberships + + end + + def destroy_memberships + + end + end + end + diff --git a/test/sets/notes.rb b/test/sets/notes.rb index 8e9f4776..ffaa0ef2 100644 --- a/test/sets/notes.rb +++ b/test/sets/notes.rb @@ -10,3 +10,51 @@ def destroy_notes end end +module Contexts + module Notes + def create_notes + + end + + def destroy_notes + + end + end + end + +module Contexts + module Notes + def create_notes + + end + + def destroy_notes + + end + end + end + +module Contexts + module Notes + def create_notes + + end + + def destroy_notes + + end + end + end + +module Contexts + module Notes + def create_notes + + end + + def destroy_notes + + end + end + end + diff --git a/test/sets/organization_aliases.rb b/test/sets/organization_aliases.rb new file mode 100644 index 00000000..df26c207 --- /dev/null +++ b/test/sets/organization_aliases.rb @@ -0,0 +1,60 @@ +module Contexts + module OrganizationAliases + def create_organization_aliases + + end + + def destroy_organization_aliases + + end + end + end + +module Contexts + module OrganizationAliases + def create_organization_aliases + + end + + def destroy_organization_aliases + + end + end + end + +module Contexts + module OrganizationAliases + def create_organization_aliases + + end + + def destroy_organization_aliases + + end + end + end + +module Contexts + module OrganizationAliases + def create_organization_aliases + + end + + def destroy_organization_aliases + + end + end + end + +module Contexts + module OrganizationAliases + def create_organization_aliases + + end + + def destroy_organization_aliases + + end + end + end + diff --git a/test/sets/organization_build_statuses.rb b/test/sets/organization_build_statuses.rb index db04b069..be70a06d 100644 --- a/test/sets/organization_build_statuses.rb +++ b/test/sets/organization_build_statuses.rb @@ -10,3 +10,51 @@ def destroy_organization_build_statuses end end +module Contexts + module OrganizationBuildStatuses + def create_organization_build_statuses + + end + + def destroy_organization_build_statuses + + end + end + end + +module Contexts + module OrganizationBuildStatuses + def create_organization_build_statuses + + end + + def destroy_organization_build_statuses + + end + end + end + +module Contexts + module OrganizationBuildStatuses + def create_organization_build_statuses + + end + + def destroy_organization_build_statuses + + end + end + end + +module Contexts + module OrganizationBuildStatuses + def create_organization_build_statuses + + end + + def destroy_organization_build_statuses + + end + end + end + diff --git a/test/sets/organization_build_steps.rb b/test/sets/organization_build_steps.rb index 3b465a51..d9e9f34f 100644 --- a/test/sets/organization_build_steps.rb +++ b/test/sets/organization_build_steps.rb @@ -10,3 +10,51 @@ def destroy_organization_build_steps end end +module Contexts + module OrganizationBuildSteps + def create_organization_build_steps + + end + + def destroy_organization_build_steps + + end + end + end + +module Contexts + module OrganizationBuildSteps + def create_organization_build_steps + + end + + def destroy_organization_build_steps + + end + end + end + +module Contexts + module OrganizationBuildSteps + def create_organization_build_steps + + end + + def destroy_organization_build_steps + + end + end + end + +module Contexts + module OrganizationBuildSteps + def create_organization_build_steps + + end + + def destroy_organization_build_steps + + end + end + end + diff --git a/test/sets/organization_categories.rb b/test/sets/organization_categories.rb index f7de9848..18abe414 100644 --- a/test/sets/organization_categories.rb +++ b/test/sets/organization_categories.rb @@ -10,3 +10,51 @@ def destroy_organization_categories end end +module Contexts + module OrganizationCategories + def create_organization_categories + + end + + def destroy_organization_categories + + end + end + end + +module Contexts + module OrganizationCategories + def create_organization_categories + + end + + def destroy_organization_categories + + end + end + end + +module Contexts + module OrganizationCategories + def create_organization_categories + + end + + def destroy_organization_categories + + end + end + end + +module Contexts + module OrganizationCategories + def create_organization_categories + + end + + def destroy_organization_categories + + end + end + end + diff --git a/test/sets/organization_status_types.rb b/test/sets/organization_status_types.rb new file mode 100644 index 00000000..96842d2b --- /dev/null +++ b/test/sets/organization_status_types.rb @@ -0,0 +1,60 @@ +module Contexts + module OrganizationStatusTypes + def create_organization_status_types + + end + + def destroy_organization_status_types + + end + end + end + +module Contexts + module OrganizationStatusTypes + def create_organization_status_types + + end + + def destroy_organization_status_types + + end + end + end + +module Contexts + module OrganizationStatusTypes + def create_organization_status_types + + end + + def destroy_organization_status_types + + end + end + end + +module Contexts + module OrganizationStatusTypes + def create_organization_status_types + + end + + def destroy_organization_status_types + + end + end + end + +module Contexts + module OrganizationStatusTypes + def create_organization_status_types + + end + + def destroy_organization_status_types + + end + end + end + diff --git a/test/sets/organization_timeline_entries.rb b/test/sets/organization_timeline_entries.rb index b1597159..bfc88a66 100644 --- a/test/sets/organization_timeline_entries.rb +++ b/test/sets/organization_timeline_entries.rb @@ -10,3 +10,51 @@ def destroy_organization_timeline_entries end end +module Contexts + module OrganizationTimelineEntries + def create_organization_timeline_entries + + end + + def destroy_organization_timeline_entries + + end + end + end + +module Contexts + module OrganizationTimelineEntries + def create_organization_timeline_entries + + end + + def destroy_organization_timeline_entries + + end + end + end + +module Contexts + module OrganizationTimelineEntries + def create_organization_timeline_entries + + end + + def destroy_organization_timeline_entries + + end + end + end + +module Contexts + module OrganizationTimelineEntries + def create_organization_timeline_entries + + end + + def destroy_organization_timeline_entries + + end + end + end + diff --git a/test/sets/organization_timeline_entry_types.rb b/test/sets/organization_timeline_entry_types.rb new file mode 100644 index 00000000..5c590a63 --- /dev/null +++ b/test/sets/organization_timeline_entry_types.rb @@ -0,0 +1,60 @@ +module Contexts + module OrganizationTimelineEntryTypes + def create_organization_timeline_entry_types + + end + + def destroy_organization_timeline_entry_types + + end + end + end + +module Contexts + module OrganizationTimelineEntryTypes + def create_organization_timeline_entry_types + + end + + def destroy_organization_timeline_entry_types + + end + end + end + +module Contexts + module OrganizationTimelineEntryTypes + def create_organization_timeline_entry_types + + end + + def destroy_organization_timeline_entry_types + + end + end + end + +module Contexts + module OrganizationTimelineEntryTypes + def create_organization_timeline_entry_types + + end + + def destroy_organization_timeline_entry_types + + end + end + end + +module Contexts + module OrganizationTimelineEntryTypes + def create_organization_timeline_entry_types + + end + + def destroy_organization_timeline_entry_types + + end + end + end + diff --git a/test/sets/organizations.rb b/test/sets/organizations.rb index da74e02d..caca50a8 100644 --- a/test/sets/organizations.rb +++ b/test/sets/organizations.rb @@ -10,3 +10,51 @@ def destroy_organizations end end +module Contexts + module Organizations + def create_organizations + + end + + def destroy_organizations + + end + end + end + +module Contexts + module Organizations + def create_organizations + + end + + def destroy_organizations + + end + end + end + +module Contexts + module Organizations + def create_organizations + + end + + def destroy_organizations + + end + end + end + +module Contexts + module Organizations + def create_organizations + + end + + def destroy_organizations + + end + end + end + diff --git a/test/sets/participants.rb b/test/sets/participants.rb index 0331ed73..f72468d8 100644 --- a/test/sets/participants.rb +++ b/test/sets/participants.rb @@ -10,3 +10,51 @@ def destroy_participants end end +module Contexts + module Participants + def create_participants + + end + + def destroy_participants + + end + end + end + +module Contexts + module Participants + def create_participants + + end + + def destroy_participants + + end + end + end + +module Contexts + module Participants + def create_participants + + end + + def destroy_participants + + end + end + end + +module Contexts + module Participants + def create_participants + + end + + def destroy_participants + + end + end + end + diff --git a/test/sets/scissor_lift_checkouts.rb b/test/sets/scissor_lift_checkouts.rb index 12173927..2b358fd9 100644 --- a/test/sets/scissor_lift_checkouts.rb +++ b/test/sets/scissor_lift_checkouts.rb @@ -10,3 +10,51 @@ def destroy_scissor_lift_checkouts end end +module Contexts + module ScissorLiftCheckouts + def create_scissor_lift_checkouts + + end + + def destroy_scissor_lift_checkouts + + end + end + end + +module Contexts + module ScissorLiftCheckouts + def create_scissor_lift_checkouts + + end + + def destroy_scissor_lift_checkouts + + end + end + end + +module Contexts + module ScissorLiftCheckouts + def create_scissor_lift_checkouts + + end + + def destroy_scissor_lift_checkouts + + end + end + end + +module Contexts + module ScissorLiftCheckouts + def create_scissor_lift_checkouts + + end + + def destroy_scissor_lift_checkouts + + end + end + end + diff --git a/test/sets/scissor_lifts.rb b/test/sets/scissor_lifts.rb index e0f3ea65..3f55fdd2 100644 --- a/test/sets/scissor_lifts.rb +++ b/test/sets/scissor_lifts.rb @@ -10,3 +10,51 @@ def destroy_scissor_lifts end end +module Contexts + module ScissorLifts + def create_scissor_lifts + + end + + def destroy_scissor_lifts + + end + end + end + +module Contexts + module ScissorLifts + def create_scissor_lifts + + end + + def destroy_scissor_lifts + + end + end + end + +module Contexts + module ScissorLifts + def create_scissor_lifts + + end + + def destroy_scissor_lifts + + end + end + end + +module Contexts + module ScissorLifts + def create_scissor_lifts + + end + + def destroy_scissor_lifts + + end + end + end + diff --git a/test/sets/shift_participants.rb b/test/sets/shift_participants.rb new file mode 100644 index 00000000..a09d47f2 --- /dev/null +++ b/test/sets/shift_participants.rb @@ -0,0 +1,60 @@ +module Contexts + module ShiftParticipants + def create_shift_participants + + end + + def destroy_shift_participants + + end + end + end + +module Contexts + module ShiftParticipants + def create_shift_participants + + end + + def destroy_shift_participants + + end + end + end + +module Contexts + module ShiftParticipants + def create_shift_participants + + end + + def destroy_shift_participants + + end + end + end + +module Contexts + module ShiftParticipants + def create_shift_participants + + end + + def destroy_shift_participants + + end + end + end + +module Contexts + module ShiftParticipants + def create_shift_participants + + end + + def destroy_shift_participants + + end + end + end + diff --git a/test/sets/shift_types.rb b/test/sets/shift_types.rb new file mode 100644 index 00000000..df8f6578 --- /dev/null +++ b/test/sets/shift_types.rb @@ -0,0 +1,60 @@ +module Contexts + module ShiftTypes + def create_shift_types + + end + + def destroy_shift_types + + end + end + end + +module Contexts + module ShiftTypes + def create_shift_types + + end + + def destroy_shift_types + + end + end + end + +module Contexts + module ShiftTypes + def create_shift_types + + end + + def destroy_shift_types + + end + end + end + +module Contexts + module ShiftTypes + def create_shift_types + + end + + def destroy_shift_types + + end + end + end + +module Contexts + module ShiftTypes + def create_shift_types + + end + + def destroy_shift_types + + end + end + end + diff --git a/test/sets/shifts.rb b/test/sets/shifts.rb new file mode 100644 index 00000000..b025bec2 --- /dev/null +++ b/test/sets/shifts.rb @@ -0,0 +1,60 @@ +module Contexts + module Shifts + def create_shifts + + end + + def destroy_shifts + + end + end + end + +module Contexts + module Shifts + def create_shifts + + end + + def destroy_shifts + + end + end + end + +module Contexts + module Shifts + def create_shifts + + end + + def destroy_shifts + + end + end + end + +module Contexts + module Shifts + def create_shifts + + end + + def destroy_shifts + + end + end + end + +module Contexts + module Shifts + def create_shifts + + end + + def destroy_shifts + + end + end + end + diff --git a/test/sets/store_items.rb b/test/sets/store_items.rb index 02edde45..d4de95b8 100644 --- a/test/sets/store_items.rb +++ b/test/sets/store_items.rb @@ -10,3 +10,51 @@ def destroy_store_items end end +module Contexts + module StoreItems + def create_store_items + + end + + def destroy_store_items + + end + end + end + +module Contexts + module StoreItems + def create_store_items + + end + + def destroy_store_items + + end + end + end + +module Contexts + module StoreItems + def create_store_items + + end + + def destroy_store_items + + end + end + end + +module Contexts + module StoreItems + def create_store_items + + end + + def destroy_store_items + + end + end + end + diff --git a/test/sets/store_purchases.rb b/test/sets/store_purchases.rb new file mode 100644 index 00000000..31b9f843 --- /dev/null +++ b/test/sets/store_purchases.rb @@ -0,0 +1,60 @@ +module Contexts + module StorePurchases + def create_store_purchases + + end + + def destroy_store_purchases + + end + end + end + +module Contexts + module StorePurchases + def create_store_purchases + + end + + def destroy_store_purchases + + end + end + end + +module Contexts + module StorePurchases + def create_store_purchases + + end + + def destroy_store_purchases + + end + end + end + +module Contexts + module StorePurchases + def create_store_purchases + + end + + def destroy_store_purchases + + end + end + end + +module Contexts + module StorePurchases + def create_store_purchases + + end + + def destroy_store_purchases + + end + end + end + diff --git a/test/sets/tasks.rb b/test/sets/tasks.rb new file mode 100644 index 00000000..547e95fd --- /dev/null +++ b/test/sets/tasks.rb @@ -0,0 +1,60 @@ +module Contexts + module Tasks + def create_tasks + + end + + def destroy_tasks + + end + end + end + +module Contexts + module Tasks + def create_tasks + + end + + def destroy_tasks + + end + end + end + +module Contexts + module Tasks + def create_tasks + + end + + def destroy_tasks + + end + end + end + +module Contexts + module Tasks + def create_tasks + + end + + def destroy_tasks + + end + end + end + +module Contexts + module Tasks + def create_tasks + + end + + def destroy_tasks + + end + end + end + diff --git a/test/sets/tool_inventories.rb b/test/sets/tool_inventories.rb index 62cf4bd0..61e1d15b 100644 --- a/test/sets/tool_inventories.rb +++ b/test/sets/tool_inventories.rb @@ -10,3 +10,51 @@ def destroy_tool_inventories end end +module Contexts + module ToolInventories + def create_tool_inventories + + end + + def destroy_tool_inventories + + end + end + end + +module Contexts + module ToolInventories + def create_tool_inventories + + end + + def destroy_tool_inventories + + end + end + end + +module Contexts + module ToolInventories + def create_tool_inventories + + end + + def destroy_tool_inventories + + end + end + end + +module Contexts + module ToolInventories + def create_tool_inventories + + end + + def destroy_tool_inventories + + end + end + end + diff --git a/test/sets/tool_inventory_tools.rb b/test/sets/tool_inventory_tools.rb index ae61a602..381f437d 100644 --- a/test/sets/tool_inventory_tools.rb +++ b/test/sets/tool_inventory_tools.rb @@ -10,3 +10,51 @@ def destroy_tool_inventory_tools end end +module Contexts + module ToolInventoryTools + def create_tool_inventory_tools + + end + + def destroy_tool_inventory_tools + + end + end + end + +module Contexts + module ToolInventoryTools + def create_tool_inventory_tools + + end + + def destroy_tool_inventory_tools + + end + end + end + +module Contexts + module ToolInventoryTools + def create_tool_inventory_tools + + end + + def destroy_tool_inventory_tools + + end + end + end + +module Contexts + module ToolInventoryTools + def create_tool_inventory_tools + + end + + def destroy_tool_inventory_tools + + end + end + end + diff --git a/test/sets/tool_type_certifications.rb b/test/sets/tool_type_certifications.rb new file mode 100644 index 00000000..945e48ed --- /dev/null +++ b/test/sets/tool_type_certifications.rb @@ -0,0 +1,60 @@ +module Contexts + module ToolTypeCertifications + def create_tool_type_certifications + + end + + def destroy_tool_type_certifications + + end + end + end + +module Contexts + module ToolTypeCertifications + def create_tool_type_certifications + + end + + def destroy_tool_type_certifications + + end + end + end + +module Contexts + module ToolTypeCertifications + def create_tool_type_certifications + + end + + def destroy_tool_type_certifications + + end + end + end + +module Contexts + module ToolTypeCertifications + def create_tool_type_certifications + + end + + def destroy_tool_type_certifications + + end + end + end + +module Contexts + module ToolTypeCertifications + def create_tool_type_certifications + + end + + def destroy_tool_type_certifications + + end + end + end + diff --git a/test/sets/tool_types.rb b/test/sets/tool_types.rb index 453645ae..b4385bfb 100644 --- a/test/sets/tool_types.rb +++ b/test/sets/tool_types.rb @@ -10,3 +10,51 @@ def destroy_tool_types end end +module Contexts + module ToolTypes + def create_tool_types + + end + + def destroy_tool_types + + end + end + end + +module Contexts + module ToolTypes + def create_tool_types + + end + + def destroy_tool_types + + end + end + end + +module Contexts + module ToolTypes + def create_tool_types + + end + + def destroy_tool_types + + end + end + end + +module Contexts + module ToolTypes + def create_tool_types + + end + + def destroy_tool_types + + end + end + end + diff --git a/test/sets/tools.rb b/test/sets/tools.rb index 0174876d..174bbb12 100644 --- a/test/sets/tools.rb +++ b/test/sets/tools.rb @@ -10,3 +10,51 @@ def destroy_tools end end +module Contexts + module Tools + def create_tools + + end + + def destroy_tools + + end + end + end + +module Contexts + module Tools + def create_tools + + end + + def destroy_tools + + end + end + end + +module Contexts + module Tools + def create_tools + + end + + def destroy_tools + + end + end + end + +module Contexts + module Tools + def create_tools + + end + + def destroy_tools + + end + end + end + diff --git a/test/test.sh b/test/test.sh deleted file mode 100755 index 3273069c..00000000 --- a/test/test.sh +++ /dev/null @@ -1,3 +0,0 @@ -testing="" -tr -dc '.' <<< $TESTVARIABLE | wc -c -echo $testing \ No newline at end of file From 56c0878567717127116bc9816969a09845010b89 Mon Sep 17 00:00:00 2001 From: PeterNotFound114 <98713019+PeterNotFound114@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:43:09 +0000 Subject: [PATCH 4/6] erd migration scripts correctly captures table, with potential race conditions when parsing columns --- lib/erd/main | 73 +++++++++++++++++++++++++++ test/factories/certification_types.rb | 1 - 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100755 lib/erd/main diff --git a/lib/erd/main b/lib/erd/main new file mode 100755 index 00000000..0ac6167a --- /dev/null +++ b/lib/erd/main @@ -0,0 +1,73 @@ +#!/bin/bash +# This script scans the db/schema file and updates all factories with default values whenever the schema.rb file changes +# Find schema file and factories +SCHEMA_FILE="db/schema.rb" +FACTORY_DIR="test/factories" + +# Use awk to extract full table definitions +awk '/create_table/,/end/' "$SCHEMA_FILE" | awk '{print} /end/ {print "---"}' > temp_blocks.txt + +while IFS= read -r block; do + # Skip separators + [[ "$block" == "---" ]] && continue + + echo "$block" + + # Extract table name + table_name=$(echo "$block" | grep -oP 'create_table\s+"\K[^"]+') + + # Skip if table name is empty + if [[ -z "$table_name" ]]; then + continue + fi + + # Define the factory file path + FILE_PATH="$FACTORY_DIR/${table_name}.rb" + + # Start building the factory definition + factory_content="FactoryBot.define do + factory :${table_name} do" + + # Extract column definitions directly without using a temp file + field_definitions="" + + while IFS= read -r column; do + # Ensure the column is valid (contains "t." and a column name in quotes) + echo "The column being scanned is ${column}" + if [[ "$column" =~ t\.[a-z]+\s+\"[^\"]+\" ]]; then + # Extract column type and name + column_type=$(echo "$column" | awk '{print $1}' | cut -d'.' -f2) + column_name=$(echo "$column" | awk -F'"' '{print $2}') + + # Skip timestamps + if [[ "$column_name" == "created_at" || "$column_name" == "updated_at" ]]; then + continue + fi + + # Assign factory defaults based on type + case "$column_type" in + string|text) field_definitions+="\n ${column_name} { \"MyString\" }" ;; + integer|bigint|float|decimal) field_definitions+="\n ${column_name} { 1 }" ;; + boolean) field_definitions+="\n ${column_name} { false }" ;; + datetime|timestamp) field_definitions+="\n ${column_name} { Time.now }" ;; + date) field_definitions+="\n ${column_name} { Date.today }" ;; + *) field_definitions+="\n # ${column_name} { \"TODO: Define a value\" }" ;; + esac + fi + done < <(echo -e "$block") + + # Append fields and close the factory definition + factory_content+="$field_definitions + end +end" + + # Write to the file + echo -e "$factory_content" > "$FILE_PATH" + + echo "Factory file created: $FILE_PATH" +done < temp_blocks.txt + +# Clean up temporary file +rm temp_blocks.txt + +echo "FactoryBot setup complete." diff --git a/test/factories/certification_types.rb b/test/factories/certification_types.rb index 3e133c11..35254dc1 100644 --- a/test/factories/certification_types.rb +++ b/test/factories/certification_types.rb @@ -1,5 +1,4 @@ FactoryBot.define do factory :certification_types do - end end From d992e8c0d8b23158112ce242a95c10f25f0fd1b8 Mon Sep 17 00:00:00 2001 From: PeterNotFound114 <98713019+PeterNotFound114@users.noreply.github.com> Date: Mon, 10 Mar 2025 17:41:43 +0000 Subject: [PATCH 5/6] normal columns parsed, references IP --- lib/erd/factory_helper.rb | 102 ++++++++++++++++++++++++++++++++++++++ lib/erd/main | 73 --------------------------- lib/erd/make_factory.rb | 25 ++++++++++ 3 files changed, 127 insertions(+), 73 deletions(-) create mode 100644 lib/erd/factory_helper.rb delete mode 100755 lib/erd/main create mode 100644 lib/erd/make_factory.rb diff --git a/lib/erd/factory_helper.rb b/lib/erd/factory_helper.rb new file mode 100644 index 00000000..0ad8d88b --- /dev/null +++ b/lib/erd/factory_helper.rb @@ -0,0 +1,102 @@ +class FactoryHelper + # { referencing => referenced } + attr_accessor :associations + # [str] + attr_accessor :schema_content + + # corresponding initial values (checked & grouped by regex) in factory file, using lambda to take in + # column name and returns the string with the right type of initial value + DEFAULT_VALUES = { + /string|text/ => lambda { |n| "#{n} { \"MyString\" }" }, + /integer|bigint|float|decimal/ => lambda { |n| "#{n} { 1 }" }, + /boolean/ => lambda { |n| "#{n} { true }" }, + /datetime|timestamp/ => lambda { |n| "#{n} { Time.now }" }, + /date/ => lambda { |n| "#{n} { Date.today }" } + } + + # Adapter Pattern + # Formats input string from schema.rb specifying foreign keys into a hash table for parsing indexes + def format_associations(str) + # input line format: /^add_foreign_key "", ""$/ + assocs = {} + str.split("\n", -1).each { |ac| + # prunes "add_foreign_key" word + line = ac.scan(/\".*\"/).first + # Sanity check to deal with trailing chars + if !line.nil? + referencing = line.split(", ").first + referenced = line.split(", ").last + assocs[referencing] = referenced + end + } + assocs + end + + # Adapter Pattern + # Formats column contents from schema into array + def format_content(str) + str.split("create_table") + end + + def create_factories + schema_content.each { |block| + # Create factory file if block is not empty + create_factory_file(block) if !block.strip.empty? + } + end + + private + def create_factory_file(block) + # Prunes all leading and trailing spaces + cols = block.split("\n", -1) + + file_content = "" + # Parses the table name of the first column + factory_name = parse_table_name(cols[0]).strip + file_content += "FactoryBot.define do\n\tfactory :#{factory_name} do\n\t\t" + + # Parses all lines matching the template of schema columns, excluding trailing (end) + cols = cols.filter!{ |col| col.match?(/^\s*t\./) } + if !cols.nil? + parsed_columns = cols.map { |col| parse_line(col) } + file_content += parsed_columns.filter{ |pc| !pc.empty? }.join("\n\t\t") + end + + file_content += "\n\tend\nend" + puts file_content + puts "----------" + # Writes to the corresponding factory file + end + + def parse_table_name(create_table_line) + # Extracts table name that is followed, pruning surrounding quotes + create_table_line.split(",", 2).first.gsub("\"", "") + end + + def parse_line(column_line) + column_type = column_line.scan(/\..*\s/).first + return parse_references(column_line) if column_type == "index" + + # Column name enclosed around the quotation marks + column_name = column_line.scan(/\".*\"/).first + parse_column(column_name, column_type) + end + + def parse_column(column_name, type) + # Ignores "created_at" and "updated_at" + return "" if column_name.match?(/^\"(created_at|updated_at)\"$/) + # Ignores FK fields that ends with "_id" + return "" if column_name.match?(/_id\"$/) + + # value_type is of type [string -> string] + value_type = DEFAULT_VALUES.find { |pattern, _| type.match?(pattern) } + if !value_type.nil? + return DEFAULT_VALUES[value_type.first].call(column_name.gsub(/\"/, "")) + end + "" + end + + def parse_references(reference_line) + # Find foreign key in add_references + end +end \ No newline at end of file diff --git a/lib/erd/main b/lib/erd/main deleted file mode 100755 index 0ac6167a..00000000 --- a/lib/erd/main +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# This script scans the db/schema file and updates all factories with default values whenever the schema.rb file changes -# Find schema file and factories -SCHEMA_FILE="db/schema.rb" -FACTORY_DIR="test/factories" - -# Use awk to extract full table definitions -awk '/create_table/,/end/' "$SCHEMA_FILE" | awk '{print} /end/ {print "---"}' > temp_blocks.txt - -while IFS= read -r block; do - # Skip separators - [[ "$block" == "---" ]] && continue - - echo "$block" - - # Extract table name - table_name=$(echo "$block" | grep -oP 'create_table\s+"\K[^"]+') - - # Skip if table name is empty - if [[ -z "$table_name" ]]; then - continue - fi - - # Define the factory file path - FILE_PATH="$FACTORY_DIR/${table_name}.rb" - - # Start building the factory definition - factory_content="FactoryBot.define do - factory :${table_name} do" - - # Extract column definitions directly without using a temp file - field_definitions="" - - while IFS= read -r column; do - # Ensure the column is valid (contains "t." and a column name in quotes) - echo "The column being scanned is ${column}" - if [[ "$column" =~ t\.[a-z]+\s+\"[^\"]+\" ]]; then - # Extract column type and name - column_type=$(echo "$column" | awk '{print $1}' | cut -d'.' -f2) - column_name=$(echo "$column" | awk -F'"' '{print $2}') - - # Skip timestamps - if [[ "$column_name" == "created_at" || "$column_name" == "updated_at" ]]; then - continue - fi - - # Assign factory defaults based on type - case "$column_type" in - string|text) field_definitions+="\n ${column_name} { \"MyString\" }" ;; - integer|bigint|float|decimal) field_definitions+="\n ${column_name} { 1 }" ;; - boolean) field_definitions+="\n ${column_name} { false }" ;; - datetime|timestamp) field_definitions+="\n ${column_name} { Time.now }" ;; - date) field_definitions+="\n ${column_name} { Date.today }" ;; - *) field_definitions+="\n # ${column_name} { \"TODO: Define a value\" }" ;; - esac - fi - done < <(echo -e "$block") - - # Append fields and close the factory definition - factory_content+="$field_definitions - end -end" - - # Write to the file - echo -e "$factory_content" > "$FILE_PATH" - - echo "Factory file created: $FILE_PATH" -done < temp_blocks.txt - -# Clean up temporary file -rm temp_blocks.txt - -echo "FactoryBot setup complete." diff --git a/lib/erd/make_factory.rb b/lib/erd/make_factory.rb new file mode 100644 index 00000000..27ed5d14 --- /dev/null +++ b/lib/erd/make_factory.rb @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +require 'open3' +require './lib/erd/factory_helper' + +def main() + # Removes previous factory files + # Sanity check first + # Open3.popen2e(ls test/factories"){ |i, oe, t| puts oe.read() } + # Open3.popen2e("rm -rf test/factories"){ |i, oe, t| } + helper = FactoryHelper.new() + + # Reads all table names and columns in the db/schema file + Open3.popen2e("awk '/create_table/,/end/' \"db/schema.rb\"") { |i, oe, t| + helper.schema_content = helper.format_content(oe.read()) + } + + # Reads all associations + Open3.popen2e("awk '/add_foreign_key/,/\"/' \"db/schema.rb\"") { |i, oe, t| + helper.associations = helper.format_associations(oe.read()) + } + + helper.create_factories() +end + +main() From 9bbcaa84e42a35497ff970ff4ef509d14fff99a0 Mon Sep 17 00:00:00 2001 From: PeterNotFound114 <98713019+PeterNotFound114@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:51:41 +0000 Subject: [PATCH 6/6] factory generation working properly, some fields need to be renamed --- lib/erd/factory_helper.rb | 57 +++++++------------ lib/erd/make_factory.rb | 10 +--- test/factories/certification_types.rb | 5 +- test/factories/certifications.rb | 6 +- test/factories/charge_types.rb | 8 ++- test/factories/charges.rb | 13 ++++- test/factories/checkouts.rb | 9 ++- test/factories/delayed_jobs.rb | 13 ++++- test/factories/event_types.rb | 6 +- test/factories/events.rb | 8 ++- test/factories/faq.rb | 7 ++- test/factories/memberships.rb | 11 +++- test/factories/notes.rb | 10 +++- test/factories/organization_aliases.rb | 6 +- test/factories/organization_build_statuses.rb | 6 +- test/factories/organization_build_steps.rb | 9 ++- test/factories/organization_categories.rb | 7 ++- test/factories/organization_status_types.rb | 6 +- .../organization_timeline_entries.rb | 6 +- .../organization_timeline_entry_types.rb | 5 +- test/factories/organizations.rb | 7 ++- test/factories/participants.rb | 15 ++++- test/factories/scissor_lift_checkouts.rb | 11 +++- test/factories/scissor_lifts.rb | 5 +- test/factories/shift_participants.rb | 7 ++- test/factories/shift_types.rb | 6 +- test/factories/shifts.rb | 6 +- test/factories/store_items.rb | 7 ++- test/factories/store_purchases.rb | 8 ++- test/factories/tasks.rb | 10 +++- test/factories/tool_inventories.rb | 5 +- test/factories/tool_inventory_tools.rb | 9 ++- test/factories/tool_type_certifications.rb | 6 +- test/factories/tool_types.rb | 5 +- test/factories/tools.rb | 8 ++- 35 files changed, 214 insertions(+), 109 deletions(-) diff --git a/lib/erd/factory_helper.rb b/lib/erd/factory_helper.rb index 0ad8d88b..0e54076f 100644 --- a/lib/erd/factory_helper.rb +++ b/lib/erd/factory_helper.rb @@ -1,37 +1,19 @@ +require 'open3' + class FactoryHelper - # { referencing => referenced } - attr_accessor :associations # [str] attr_accessor :schema_content # corresponding initial values (checked & grouped by regex) in factory file, using lambda to take in # column name and returns the string with the right type of initial value DEFAULT_VALUES = { - /string|text/ => lambda { |n| "#{n} { \"MyString\" }" }, - /integer|bigint|float|decimal/ => lambda { |n| "#{n} { 1 }" }, - /boolean/ => lambda { |n| "#{n} { true }" }, - /datetime|timestamp/ => lambda { |n| "#{n} { Time.now }" }, - /date/ => lambda { |n| "#{n} { Date.today }" } + /string|text/ => lambda { |n| "#{n} \{ \'MyString\' \}" }, + /integer|bigint|float|decimal/ => lambda { |n| "#{n} \{ 1 \}" }, + /boolean/ => lambda { |n| "#{n} \{ true \}" }, + /datetime|timestamp/ => lambda { |n| "#{n} \{ Time.now \}" }, + /date/ => lambda { |n| "#{n} \{ Date.today \}" } } - # Adapter Pattern - # Formats input string from schema.rb specifying foreign keys into a hash table for parsing indexes - def format_associations(str) - # input line format: /^add_foreign_key "", ""$/ - assocs = {} - str.split("\n", -1).each { |ac| - # prunes "add_foreign_key" word - line = ac.scan(/\".*\"/).first - # Sanity check to deal with trailing chars - if !line.nil? - referencing = line.split(", ").first - referenced = line.split(", ").last - assocs[referencing] = referenced - end - } - assocs - end - # Adapter Pattern # Formats column contents from schema into array def format_content(str) @@ -53,7 +35,7 @@ def create_factory_file(block) file_content = "" # Parses the table name of the first column factory_name = parse_table_name(cols[0]).strip - file_content += "FactoryBot.define do\n\tfactory :#{factory_name} do\n\t\t" + file_content += "FactoryBot.define do\n\tfactory \:#{factory_name} do\n\t\t" # Parses all lines matching the template of schema columns, excluding trailing (end) cols = cols.filter!{ |col| col.match?(/^\s*t\./) } @@ -63,9 +45,12 @@ def create_factory_file(block) end file_content += "\n\tend\nend" - puts file_content - puts "----------" + # Writes to the corresponding factory file + Open3.popen2e("echo \"#{file_content}\" > test/factories/#{factory_name}.rb") {|i, oe, t| + puts oe.read() + puts "test/factories/#{factory_name}.rb created!" + } end def parse_table_name(create_table_line) @@ -74,10 +59,10 @@ def parse_table_name(create_table_line) end def parse_line(column_line) - column_type = column_line.scan(/\..*\s/).first - return parse_references(column_line) if column_type == "index" - # Column name enclosed around the quotation marks + column_type = column_line.scan(/\..*\s/).first + # Ignore indexes that are not used on the application level + return "" if column_type.match?(/index/) column_name = column_line.scan(/\".*\"/).first parse_column(column_name, column_type) end @@ -85,18 +70,20 @@ def parse_line(column_line) def parse_column(column_name, type) # Ignores "created_at" and "updated_at" return "" if column_name.match?(/^\"(created_at|updated_at)\"$/) - # Ignores FK fields that ends with "_id" - return "" if column_name.match?(/_id\"$/) + # Processes FK fields that ends with "_id", there should be another way to handle FK columns with aliases + return parse_references(column_name.gsub(/([\"\[\]]|_id\"$)/, "")) if column_name.match?(/_id\"$/) + # value_type is of type [string -> string] value_type = DEFAULT_VALUES.find { |pattern, _| type.match?(pattern) } if !value_type.nil? + # Calls the lambda that is mapped to by the corresponding pattern return DEFAULT_VALUES[value_type.first].call(column_name.gsub(/\"/, "")) end "" end - def parse_references(reference_line) - # Find foreign key in add_references + def parse_references(referenced_table_name) + "association :#{referenced_table_name.strip}" end end \ No newline at end of file diff --git a/lib/erd/make_factory.rb b/lib/erd/make_factory.rb index 27ed5d14..425e38a0 100644 --- a/lib/erd/make_factory.rb +++ b/lib/erd/make_factory.rb @@ -4,9 +4,8 @@ def main() # Removes previous factory files - # Sanity check first - # Open3.popen2e(ls test/factories"){ |i, oe, t| puts oe.read() } - # Open3.popen2e("rm -rf test/factories"){ |i, oe, t| } + Open3.popen2e("rm -rf test/factories/*"){ |i, oe, t| puts oe.read() } + helper = FactoryHelper.new() # Reads all table names and columns in the db/schema file @@ -14,11 +13,6 @@ def main() helper.schema_content = helper.format_content(oe.read()) } - # Reads all associations - Open3.popen2e("awk '/add_foreign_key/,/\"/' \"db/schema.rb\"") { |i, oe, t| - helper.associations = helper.format_associations(oe.read()) - } - helper.create_factories() end diff --git a/test/factories/certification_types.rb b/test/factories/certification_types.rb index 35254dc1..e19c216e 100644 --- a/test/factories/certification_types.rb +++ b/test/factories/certification_types.rb @@ -1,4 +1,5 @@ FactoryBot.define do - factory :certification_types do - end + factory :certification_types do + name { 'MyString' } + end end diff --git a/test/factories/certifications.rb b/test/factories/certifications.rb index 7d3f1697..71099f77 100644 --- a/test/factories/certifications.rb +++ b/test/factories/certifications.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :certifications do - end + factory :certifications do + association :participant + association :certification_type + end end diff --git a/test/factories/charge_types.rb b/test/factories/charge_types.rb index 43001eef..819ab67b 100644 --- a/test/factories/charge_types.rb +++ b/test/factories/charge_types.rb @@ -1,4 +1,8 @@ FactoryBot.define do - factory :charge_types do - end + factory :charge_types do + name { 'MyString' } + requires_booth_chair_approval { true } + default_amount { 1 } + description { 'MyString' } + end end diff --git a/test/factories/charges.rb b/test/factories/charges.rb index 822d35eb..fc8579fa 100644 --- a/test/factories/charges.rb +++ b/test/factories/charges.rb @@ -1,4 +1,13 @@ FactoryBot.define do - factory :charges do - end + factory :charges do + association :organization + association :charge_type + amount { 1 } + description { 'MyString' } + association :issuing_participant + association :receiving_participant + charged_at { Time.now } + is_approved { true } + association :creating_participant + end end diff --git a/test/factories/checkouts.rb b/test/factories/checkouts.rb index 1ff6ee1e..84f929a8 100644 --- a/test/factories/checkouts.rb +++ b/test/factories/checkouts.rb @@ -1,4 +1,9 @@ FactoryBot.define do - factory :checkouts do - end + factory :checkouts do + association :tool + checked_out_at { Time.now } + checked_in_at { Time.now } + association :participant + association :organization + end end diff --git a/test/factories/delayed_jobs.rb b/test/factories/delayed_jobs.rb index 2134d196..88e38a36 100644 --- a/test/factories/delayed_jobs.rb +++ b/test/factories/delayed_jobs.rb @@ -1,4 +1,13 @@ FactoryBot.define do - factory :delayed_jobs do - end + factory :delayed_jobs do + priority { 1 } + attempts { 1 } + handler { 'MyString' } + last_error { 'MyString' } + run_at { Time.now } + locked_at { Time.now } + failed_at { Time.now } + locked_by { 'MyString' } + queue { 'MyString' } + end end diff --git a/test/factories/event_types.rb b/test/factories/event_types.rb index 344b216b..aa9d41e3 100644 --- a/test/factories/event_types.rb +++ b/test/factories/event_types.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :event_types do - end + factory :event_types do + display { true } + name { 'MyString' } + end end diff --git a/test/factories/events.rb b/test/factories/events.rb index 1e95360c..197b74e3 100644 --- a/test/factories/events.rb +++ b/test/factories/events.rb @@ -1,4 +1,8 @@ FactoryBot.define do - factory :events do - end + factory :events do + is_done { true } + association :event_type + description { 'MyString' } + association :participant + end end diff --git a/test/factories/faq.rb b/test/factories/faq.rb index effa54ae..1f3834ed 100644 --- a/test/factories/faq.rb +++ b/test/factories/faq.rb @@ -1,4 +1,7 @@ FactoryBot.define do - factory :faq do - end + factory :faq do + question { 'MyString' } + answer { 'MyString' } + association :organization_category + end end diff --git a/test/factories/memberships.rb b/test/factories/memberships.rb index 569140a6..8c9dc462 100644 --- a/test/factories/memberships.rb +++ b/test/factories/memberships.rb @@ -1,4 +1,11 @@ FactoryBot.define do - factory :memberships do - end + factory :memberships do + association :organization + association :participant + is_booth_chair { true } + title { 'MyString' } + booth_chair_order { 1 } + is_in_csv { true } + is_added_by_csv { true } + end end diff --git a/test/factories/notes.rb b/test/factories/notes.rb index e83b668f..0bd5979e 100644 --- a/test/factories/notes.rb +++ b/test/factories/notes.rb @@ -1,4 +1,10 @@ FactoryBot.define do - factory :notes do - end + factory :notes do + association :participant + association :organization + hidden { true } + title { 'MyString' } + value { 'MyString' } + color { 'MyString' } + end end diff --git a/test/factories/organization_aliases.rb b/test/factories/organization_aliases.rb index 0d03dd3b..ef6f310b 100644 --- a/test/factories/organization_aliases.rb +++ b/test/factories/organization_aliases.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :organization_aliases do - end + factory :organization_aliases do + name { 'MyString' } + association :organization + end end diff --git a/test/factories/organization_build_statuses.rb b/test/factories/organization_build_statuses.rb index 3f4f04f2..932169ee 100644 --- a/test/factories/organization_build_statuses.rb +++ b/test/factories/organization_build_statuses.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :organization_build_statuses do - end + factory :organization_build_statuses do + association :organization + status_type { 'MyString' } + end end diff --git a/test/factories/organization_build_steps.rb b/test/factories/organization_build_steps.rb index cd2c3d98..fe93d2d8 100644 --- a/test/factories/organization_build_steps.rb +++ b/test/factories/organization_build_steps.rb @@ -1,4 +1,9 @@ FactoryBot.define do - factory :organization_build_steps do - end + factory :organization_build_steps do + title { 'MyString' } + requirements { 'MyString' } + step { 1 } + completed { true } + association :organization_build_status + end end diff --git a/test/factories/organization_categories.rb b/test/factories/organization_categories.rb index 1aef2a17..553e051b 100644 --- a/test/factories/organization_categories.rb +++ b/test/factories/organization_categories.rb @@ -1,4 +1,7 @@ FactoryBot.define do - factory :organization_categories do - end + factory :organization_categories do + name { 'MyString' } + building { true } + lookup_key { 'MyString' } + end end diff --git a/test/factories/organization_status_types.rb b/test/factories/organization_status_types.rb index c0d5d099..33fa6a7d 100644 --- a/test/factories/organization_status_types.rb +++ b/test/factories/organization_status_types.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :organization_status_types do - end + factory :organization_status_types do + name { 'MyString' } + display { true } + end end diff --git a/test/factories/organization_timeline_entries.rb b/test/factories/organization_timeline_entries.rb index 2a6dec83..9995a62c 100644 --- a/test/factories/organization_timeline_entries.rb +++ b/test/factories/organization_timeline_entries.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :organization_timeline_entries do - end + factory :organization_timeline_entries do + started_at { Time.now } + ended_at { Time.now } + end end diff --git a/test/factories/organization_timeline_entry_types.rb b/test/factories/organization_timeline_entry_types.rb index 28a4b8d1..1fd1eb1c 100644 --- a/test/factories/organization_timeline_entry_types.rb +++ b/test/factories/organization_timeline_entry_types.rb @@ -1,4 +1,5 @@ FactoryBot.define do - factory :organization_timeline_entry_types do - end + factory :organization_timeline_entry_types do + name { 'MyString' } + end end diff --git a/test/factories/organizations.rb b/test/factories/organizations.rb index bf2fb29e..c7cfc182 100644 --- a/test/factories/organizations.rb +++ b/test/factories/organizations.rb @@ -1,4 +1,7 @@ FactoryBot.define do - factory :organizations do - end + factory :organizations do + name { 'MyString' } + association :organization_category + short_name { 'MyString' } + end end diff --git a/test/factories/participants.rb b/test/factories/participants.rb index 2e029bad..59151de7 100644 --- a/test/factories/participants.rb +++ b/test/factories/participants.rb @@ -1,4 +1,15 @@ FactoryBot.define do - factory :participants do - end + factory :participants do + eppn { 'MyString' } + signed_waiver { true } + phone_number { 'MyString' } + cached_name { 'MyString' } + cached_surname { 'MyString' } + cached_email { 'MyString' } + cached_department { 'MyString' } + cached_student_class { 'MyString' } + cache_updated { Time.now } + admin { true } + watched_safety_video { true } + end end diff --git a/test/factories/scissor_lift_checkouts.rb b/test/factories/scissor_lift_checkouts.rb index aa9091c9..db61cbd5 100644 --- a/test/factories/scissor_lift_checkouts.rb +++ b/test/factories/scissor_lift_checkouts.rb @@ -1,4 +1,11 @@ FactoryBot.define do - factory :scissor_lift_checkouts do - end + factory :scissor_lift_checkouts do + association :scissor_lift + association :participant + association :organization + checked_out_at { Time.now } + checked_in_at { Time.now } + due_at { Time.now } + is_forfeit { true } + end end diff --git a/test/factories/scissor_lifts.rb b/test/factories/scissor_lifts.rb index 62f3c726..2720081f 100644 --- a/test/factories/scissor_lifts.rb +++ b/test/factories/scissor_lifts.rb @@ -1,4 +1,5 @@ FactoryBot.define do - factory :scissor_lifts do - end + factory :scissor_lifts do + name { 'MyString' } + end end diff --git a/test/factories/shift_participants.rb b/test/factories/shift_participants.rb index b306bbf9..c3aa4222 100644 --- a/test/factories/shift_participants.rb +++ b/test/factories/shift_participants.rb @@ -1,4 +1,7 @@ FactoryBot.define do - factory :shift_participants do - end + factory :shift_participants do + association :shift + association :participant + clocked_in_at { Time.now } + end end diff --git a/test/factories/shift_types.rb b/test/factories/shift_types.rb index 3a9a9d1c..904988b1 100644 --- a/test/factories/shift_types.rb +++ b/test/factories/shift_types.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :shift_types do - end + factory :shift_types do + name { 'MyString' } + short_name { 'MyString' } + end end diff --git a/test/factories/shifts.rb b/test/factories/shifts.rb index 0e34c97e..edb37c35 100644 --- a/test/factories/shifts.rb +++ b/test/factories/shifts.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :shifts do - end + factory :shifts do + starts_at { Time.now } + ends_at { Time.now } + end end diff --git a/test/factories/store_items.rb b/test/factories/store_items.rb index 9a3e0e2a..9e4dfb1a 100644 --- a/test/factories/store_items.rb +++ b/test/factories/store_items.rb @@ -1,4 +1,7 @@ FactoryBot.define do - factory :store_items do - end + factory :store_items do + name { 'MyString' } + price { 1 } + quantity { 1 } + end end diff --git a/test/factories/store_purchases.rb b/test/factories/store_purchases.rb index 05618148..1bcc963c 100644 --- a/test/factories/store_purchases.rb +++ b/test/factories/store_purchases.rb @@ -1,4 +1,8 @@ FactoryBot.define do - factory :store_purchases do - end + factory :store_purchases do + association :charge + association :store_item + price_at_purchase { 1 } + quantity_purchased { 1 } + end end diff --git a/test/factories/tasks.rb b/test/factories/tasks.rb index d6a48c0a..8df03996 100644 --- a/test/factories/tasks.rb +++ b/test/factories/tasks.rb @@ -1,4 +1,10 @@ FactoryBot.define do - factory :tasks do - end + factory :tasks do + due_at { Time.now } + # TODO: Rename variable if it is not intended as a FK + completed_by_id { 1 } + name { 'MyString' } + description { 'MyString' } + is_completed { true } + end end diff --git a/test/factories/tool_inventories.rb b/test/factories/tool_inventories.rb index a0c5b4ec..e3fe74b0 100644 --- a/test/factories/tool_inventories.rb +++ b/test/factories/tool_inventories.rb @@ -1,4 +1,5 @@ FactoryBot.define do - factory :tool_inventories do - end + factory :tool_inventories do + + end end diff --git a/test/factories/tool_inventory_tools.rb b/test/factories/tool_inventory_tools.rb index 0d6ae2bd..3996ba46 100644 --- a/test/factories/tool_inventory_tools.rb +++ b/test/factories/tool_inventory_tools.rb @@ -1,4 +1,9 @@ FactoryBot.define do - factory :tool_inventory_tools do - end + factory :tool_inventory_tools do + barcode { 1 } + description { 'MyString' } + active { true } + association :tool_type + association :tool_inventory + end end diff --git a/test/factories/tool_type_certifications.rb b/test/factories/tool_type_certifications.rb index 0cf2c787..eb7c0f85 100644 --- a/test/factories/tool_type_certifications.rb +++ b/test/factories/tool_type_certifications.rb @@ -1,4 +1,6 @@ FactoryBot.define do - factory :tool_type_certifications do - end + factory :tool_type_certifications do + association :tool_type + association :certification_type + end end diff --git a/test/factories/tool_types.rb b/test/factories/tool_types.rb index 8190e387..adfb9175 100644 --- a/test/factories/tool_types.rb +++ b/test/factories/tool_types.rb @@ -1,4 +1,5 @@ FactoryBot.define do - factory :tool_types do - end + factory :tool_types do + name { 'MyString' } + end end diff --git a/test/factories/tools.rb b/test/factories/tools.rb index 96c69697..27f3c358 100644 --- a/test/factories/tools.rb +++ b/test/factories/tools.rb @@ -1,4 +1,8 @@ FactoryBot.define do - factory :tools do - end + factory :tools do + barcode { 1 } + description { 'MyString' } + association :tool_type + active { true } + end end