From f59a0dd1eef0812f85a7de90d8b3ac422f2e93fe Mon Sep 17 00:00:00 2001 From: marlena-b Date: Mon, 14 Oct 2024 12:33:36 +0200 Subject: [PATCH] get rid of destroy_all in tests --- .../test/client_authentication/create_test.rb | 5 ----- .../test/client_authentication/set_password_test.rb | 5 ----- .../test/client_orders/customer_registered_test.rb | 7 +------ .../test/client_orders/item_added_to_basket_test.rb | 6 ------ .../test/client_orders/item_removed_from_basket_test.rb | 7 ------- .../test/client_orders/order_cancelled_test.rb | 6 ------ .../test/client_orders/order_expired_test.rb | 8 +------- rails_application/test/client_orders/order_paid_test.rb | 6 ------ rails_application/test/client_orders/order_placed_test.rb | 8 +------- .../test/client_orders/update_paid_orders_summary_test.rb | 5 ----- rails_application/test/customers/connect_account_test.rb | 5 ----- .../test/customers/customer_promoted_to_vip_test.rb | 5 ----- .../test/customers/update_paid_orders_summary_test.rb | 5 ----- rails_application/test/integration/client_orders_test.rb | 3 --- rails_application/test/integration/discount_test.rb | 1 - rails_application/test/integration/login_test.rb | 5 ----- rails_application/test/integration/orders_test.rb | 1 - rails_application/test/invoices/invoices_test.rb | 7 ------- .../test/orders/assign_customer_first_test.rb | 8 +------- rails_application/test/orders/customer_registered_test.rb | 7 +------ .../test/orders/item_added_to_basket_test.rb | 6 ------ .../test/orders/item_removed_from_basket_test.rb | 7 ------- rails_application/test/orders/order_cancelled_test.rb | 6 ------ rails_application/test/orders/order_expired_test.rb | 5 ----- rails_application/test/orders/order_paid_test.rb | 6 ------ rails_application/test/orders/order_placed_test.rb | 6 ------ 26 files changed, 5 insertions(+), 141 deletions(-) diff --git a/rails_application/test/client_authentication/create_test.rb b/rails_application/test/client_authentication/create_test.rb index ce8023e17..ab8c81f4b 100644 --- a/rails_application/test/client_authentication/create_test.rb +++ b/rails_application/test/client_authentication/create_test.rb @@ -4,11 +4,6 @@ module ClientAuthentication class CreateTest < InMemoryTestCase cover "Authentication*" - def setup - super - Account.destroy_all - end - def test_set_create customer_id = SecureRandom.uuid product_id = SecureRandom.uuid diff --git a/rails_application/test/client_authentication/set_password_test.rb b/rails_application/test/client_authentication/set_password_test.rb index 6f048d973..ee9310f30 100644 --- a/rails_application/test/client_authentication/set_password_test.rb +++ b/rails_application/test/client_authentication/set_password_test.rb @@ -4,11 +4,6 @@ module ClientAuthentication class SetPasswordTest < InMemoryTestCase cover "Authentication*" - def setup - super - Account.destroy_all - end - def test_set_password customer_id = SecureRandom.uuid account_id = SecureRandom.uuid diff --git a/rails_application/test/client_orders/customer_registered_test.rb b/rails_application/test/client_orders/customer_registered_test.rb index 8e71a7aa4..dac1810d6 100644 --- a/rails_application/test/client_orders/customer_registered_test.rb +++ b/rails_application/test/client_orders/customer_registered_test.rb @@ -4,11 +4,6 @@ module ClientOrders class CustomerRegisteredTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Client.destroy_all - end - def test_customer_registered event_store = Rails.configuration.event_store @@ -52,4 +47,4 @@ def test_customer_assigned_to_order end end -end \ No newline at end of file +end diff --git a/rails_application/test/client_orders/item_added_to_basket_test.rb b/rails_application/test/client_orders/item_added_to_basket_test.rb index dbfce0672..361fac293 100644 --- a/rails_application/test/client_orders/item_added_to_basket_test.rb +++ b/rails_application/test/client_orders/item_added_to_basket_test.rb @@ -4,12 +4,6 @@ module ClientOrders class ItemAddedToBasketTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Order.destroy_all - OrderLine.destroy_all - end - def test_add_new_item event_store = Rails.configuration.event_store diff --git a/rails_application/test/client_orders/item_removed_from_basket_test.rb b/rails_application/test/client_orders/item_removed_from_basket_test.rb index 949d25edb..854354298 100644 --- a/rails_application/test/client_orders/item_removed_from_basket_test.rb +++ b/rails_application/test/client_orders/item_removed_from_basket_test.rb @@ -4,13 +4,6 @@ module ClientOrders class ItemRemovedFromBasketTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Order.destroy_all - OrderLine.destroy_all - Product.destroy_all - end - def test_remove_item_when_quantity_gt_1 event_store = Rails.configuration.event_store diff --git a/rails_application/test/client_orders/order_cancelled_test.rb b/rails_application/test/client_orders/order_cancelled_test.rb index f18d54a49..87f0a68e0 100644 --- a/rails_application/test/client_orders/order_cancelled_test.rb +++ b/rails_application/test/client_orders/order_cancelled_test.rb @@ -4,12 +4,6 @@ module ClientOrders class OrderCancelledTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Client.destroy_all - Order.destroy_all - end - def test_order_confirmed event_store = Rails.configuration.event_store customer_id = SecureRandom.uuid diff --git a/rails_application/test/client_orders/order_expired_test.rb b/rails_application/test/client_orders/order_expired_test.rb index 9e1eb4b35..cddc54da1 100644 --- a/rails_application/test/client_orders/order_expired_test.rb +++ b/rails_application/test/client_orders/order_expired_test.rb @@ -4,12 +4,6 @@ module ClientOrders class OrderExpiredTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Client.destroy_all - Order.destroy_all - end - def test_order_expired event_store = Rails.configuration.event_store customer_id = SecureRandom.uuid @@ -49,4 +43,4 @@ def test_order_expired assert_equal("Expired", orders.first.state) end end -end \ No newline at end of file +end diff --git a/rails_application/test/client_orders/order_paid_test.rb b/rails_application/test/client_orders/order_paid_test.rb index 94ead9954..692a7c0cb 100644 --- a/rails_application/test/client_orders/order_paid_test.rb +++ b/rails_application/test/client_orders/order_paid_test.rb @@ -4,12 +4,6 @@ module ClientOrders class OrderConfirmedTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Client.destroy_all - Order.destroy_all - end - def test_order_confirmed event_store = Rails.configuration.event_store customer_id = SecureRandom.uuid diff --git a/rails_application/test/client_orders/order_placed_test.rb b/rails_application/test/client_orders/order_placed_test.rb index d73964bde..b178b7c24 100644 --- a/rails_application/test/client_orders/order_placed_test.rb +++ b/rails_application/test/client_orders/order_placed_test.rb @@ -4,12 +4,6 @@ module ClientOrders class OrderPlacedTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Client.destroy_all - Order.destroy_all - end - def test_order_placed event_store = Rails.configuration.event_store customer_id = SecureRandom.uuid @@ -94,4 +88,4 @@ def assert_clickable_order_number(customer_id, order_id, order_number) assert_equal(order_number, links_to_orders.first.text) end end -end \ No newline at end of file +end diff --git a/rails_application/test/client_orders/update_paid_orders_summary_test.rb b/rails_application/test/client_orders/update_paid_orders_summary_test.rb index be18faa0b..04be62a8a 100644 --- a/rails_application/test/client_orders/update_paid_orders_summary_test.rb +++ b/rails_application/test/client_orders/update_paid_orders_summary_test.rb @@ -4,11 +4,6 @@ module ClientOrders class UpdatePaidOrdersSummaryTest < InMemoryTestCase cover "ClientOrders*" - def setup - super - Client.destroy_all - end - def test_update_orders_summary customer_id = SecureRandom.uuid other_customer_id = SecureRandom.uuid diff --git a/rails_application/test/customers/connect_account_test.rb b/rails_application/test/customers/connect_account_test.rb index 1bbac4a6f..182d02daa 100644 --- a/rails_application/test/customers/connect_account_test.rb +++ b/rails_application/test/customers/connect_account_test.rb @@ -4,11 +4,6 @@ module Customers class ConnectAccountTest < InMemoryTestCase cover "Customers" - def setup - super - Customer.destroy_all - end - def test_first_register_then_connect customer_id = SecureRandom.uuid account_id = SecureRandom.uuid diff --git a/rails_application/test/customers/customer_promoted_to_vip_test.rb b/rails_application/test/customers/customer_promoted_to_vip_test.rb index 91785cbe5..5b747506b 100644 --- a/rails_application/test/customers/customer_promoted_to_vip_test.rb +++ b/rails_application/test/customers/customer_promoted_to_vip_test.rb @@ -4,11 +4,6 @@ module Customers class CustomerPromotedToVipTest < InMemoryTestCase cover "Customers" - def setup - super - Customer.destroy_all - end - def test_promote_customer_to_vip event_store = Rails.configuration.event_store diff --git a/rails_application/test/customers/update_paid_orders_summary_test.rb b/rails_application/test/customers/update_paid_orders_summary_test.rb index 323537829..750bd9e22 100644 --- a/rails_application/test/customers/update_paid_orders_summary_test.rb +++ b/rails_application/test/customers/update_paid_orders_summary_test.rb @@ -4,11 +4,6 @@ module Customers class UpdatePaidOrdersSummaryTest < InMemoryTestCase cover "Customers" - def setup - super - Customer.destroy_all - end - def test_update_orders_summary customer_id = SecureRandom.uuid other_customer_id = SecureRandom.uuid diff --git a/rails_application/test/integration/client_orders_test.rb b/rails_application/test/integration/client_orders_test.rb index 1163a7d51..394cfcbf8 100644 --- a/rails_application/test/integration/client_orders_test.rb +++ b/rails_application/test/integration/client_orders_test.rb @@ -6,9 +6,6 @@ class ClientOrdersTests < InMemoryRESIntegrationTestCase def setup super Rails.configuration.payment_gateway.call.reset - ClientOrders::Client.destroy_all - ClientOrders::Order.destroy_all - Orders::Order.destroy_all add_available_vat_rate(10) end diff --git a/rails_application/test/integration/discount_test.rb b/rails_application/test/integration/discount_test.rb index a96cfbe9f..4ec99d1ef 100644 --- a/rails_application/test/integration/discount_test.rb +++ b/rails_application/test/integration/discount_test.rb @@ -3,7 +3,6 @@ class DiscountTest < InMemoryRESIntegrationTestCase def setup super - Orders::Order.destroy_all add_available_vat_rate(10) end diff --git a/rails_application/test/integration/login_test.rb b/rails_application/test/integration/login_test.rb index 05aa223b5..be4bd231f 100644 --- a/rails_application/test/integration/login_test.rb +++ b/rails_application/test/integration/login_test.rb @@ -1,11 +1,6 @@ require "test_helper" class LoginTest < InMemoryRESIntegrationTestCase - def setup - super - Customers::Customer.destroy_all - end - def test_login password = "1234qwer" customer_id = register_customer("Arkency") diff --git a/rails_application/test/integration/orders_test.rb b/rails_application/test/integration/orders_test.rb index f3b257cab..f7d3b643d 100644 --- a/rails_application/test/integration/orders_test.rb +++ b/rails_application/test/integration/orders_test.rb @@ -4,7 +4,6 @@ class OrdersTest < InMemoryRESIntegrationTestCase def setup super Rails.configuration.payment_gateway.call.reset - Orders::Order.destroy_all add_available_vat_rate(10) end diff --git a/rails_application/test/invoices/invoices_test.rb b/rails_application/test/invoices/invoices_test.rb index c9359fe1c..09cf52eee 100644 --- a/rails_application/test/invoices/invoices_test.rb +++ b/rails_application/test/invoices/invoices_test.rb @@ -4,13 +4,6 @@ module Invoices class InvoicesTest < InMemoryRESIntegrationTestCase cover "Invoices*" - def setup - super - Invoice.destroy_all - InvoiceItem.destroy_all - Order.destroy_all - end - def test_create_draft_order_when_not_exists event_store = Rails.configuration.event_store order_id = SecureRandom.uuid diff --git a/rails_application/test/orders/assign_customer_first_test.rb b/rails_application/test/orders/assign_customer_first_test.rb index 25c65f8b4..58713fe60 100644 --- a/rails_application/test/orders/assign_customer_first_test.rb +++ b/rails_application/test/orders/assign_customer_first_test.rb @@ -4,12 +4,6 @@ module Orders class AssignCustomerFirstTest < InMemoryTestCase cover "Orders*" - def setup - super - Order.destroy_all - OrderLine.destroy_all - end - def test_create_draft_order_when_not_exists event_store = Rails.configuration.event_store customer_id = SecureRandom.uuid @@ -24,4 +18,4 @@ def test_create_draft_order_when_not_exists assert event_store.event_in_stream?(customer_registered.event_id, "Orders$all") end end -end \ No newline at end of file +end diff --git a/rails_application/test/orders/customer_registered_test.rb b/rails_application/test/orders/customer_registered_test.rb index a1bd29aef..d023d3453 100644 --- a/rails_application/test/orders/customer_registered_test.rb +++ b/rails_application/test/orders/customer_registered_test.rb @@ -4,11 +4,6 @@ module Orders class CustomerRegisteredTest < InMemoryTestCase cover "Orders*" - def setup - super - Customer.destroy_all - end - def test_customer_registered event_store = Rails.configuration.event_store @@ -52,4 +47,4 @@ def test_customer_assigned_to_order end end -end \ No newline at end of file +end diff --git a/rails_application/test/orders/item_added_to_basket_test.rb b/rails_application/test/orders/item_added_to_basket_test.rb index 72c4b8522..9fd504718 100644 --- a/rails_application/test/orders/item_added_to_basket_test.rb +++ b/rails_application/test/orders/item_added_to_basket_test.rb @@ -4,12 +4,6 @@ module Orders class ItemAddedToBasketTest < InMemoryTestCase cover "Orders*" - def setup - super - Order.destroy_all - OrderLine.destroy_all - end - def test_add_new_item event_store = Rails.configuration.event_store diff --git a/rails_application/test/orders/item_removed_from_basket_test.rb b/rails_application/test/orders/item_removed_from_basket_test.rb index dc66379ea..f5d437e08 100644 --- a/rails_application/test/orders/item_removed_from_basket_test.rb +++ b/rails_application/test/orders/item_removed_from_basket_test.rb @@ -4,13 +4,6 @@ module Orders class ItemRemovedFromBasketTest < InMemoryTestCase cover "Orders*" - def setup - super - Order.destroy_all - OrderLine.destroy_all - Product.destroy_all - end - def test_remove_item_when_quantity_gt_1 event_store = Rails.configuration.event_store diff --git a/rails_application/test/orders/order_cancelled_test.rb b/rails_application/test/orders/order_cancelled_test.rb index 67cb67dda..cea32ee8a 100644 --- a/rails_application/test/orders/order_cancelled_test.rb +++ b/rails_application/test/orders/order_cancelled_test.rb @@ -4,12 +4,6 @@ module Orders class OrderCancelledTest < InMemoryTestCase cover "Orders*" - def setup - super - Customer.destroy_all - Order.destroy_all - end - def test_cancel_confirmed_order event_store = Rails.configuration.event_store customer_id = SecureRandom.uuid diff --git a/rails_application/test/orders/order_expired_test.rb b/rails_application/test/orders/order_expired_test.rb index fef4ddf32..3103744a7 100644 --- a/rails_application/test/orders/order_expired_test.rb +++ b/rails_application/test/orders/order_expired_test.rb @@ -4,11 +4,6 @@ module Orders class OrderExpiredTest < InMemoryTestCase cover "Orders*" - def setup - super - Order.destroy_all - end - def test_expire_created_order event_store = Rails.configuration.event_store diff --git a/rails_application/test/orders/order_paid_test.rb b/rails_application/test/orders/order_paid_test.rb index fb917e6c4..900bb8947 100644 --- a/rails_application/test/orders/order_paid_test.rb +++ b/rails_application/test/orders/order_paid_test.rb @@ -4,12 +4,6 @@ module Orders class OrderConfirmedTest < InMemoryTestCase cover "Orders*" - def setup - super - Customer.destroy_all - Order.destroy_all - end - def test_order_confirmed event_store = Rails.configuration.event_store customer_id = SecureRandom.uuid diff --git a/rails_application/test/orders/order_placed_test.rb b/rails_application/test/orders/order_placed_test.rb index a378a7815..5ef342dc9 100644 --- a/rails_application/test/orders/order_placed_test.rb +++ b/rails_application/test/orders/order_placed_test.rb @@ -5,12 +5,6 @@ class OrderPlacedTest < InMemoryTestCase include ActiveJob::TestHelper cover "Orders" - def setup - super - Order.destroy_all - OrderLine.destroy_all - end - def test_create_when_not_exists event_store = Rails.configuration.event_store