diff --git a/spec/lib/open_food_network/scope_variant_to_hub_spec.rb b/spec/lib/open_food_network/scope_variant_to_hub_spec.rb index 4b6b2f8cb7..d10d372902 100644 --- a/spec/lib/open_food_network/scope_variant_to_hub_spec.rb +++ b/spec/lib/open_food_network/scope_variant_to_hub_spec.rb @@ -10,16 +10,16 @@ module OpenFoodNetwork let(:v2) { create(:variant, price: 22.22, on_hand: 5) } let(:v3) { create(:variant, price: 33.33, on_hand: 6) } let(:vo) { - create(:variant_override, hub: hub, variant: v, price: 22.22, count_on_hand: 2, + create(:variant_override, hub:, variant: v, price: 22.22, count_on_hand: 2, on_demand: false, sku: "VOSKU") } let(:vo2) { - create(:variant_override, hub: hub, variant: v2, price: 33.33, count_on_hand: nil, + create(:variant_override, hub:, variant: v2, price: 33.33, count_on_hand: nil, on_demand: true) } - let(:vo3) { create(:variant_override, hub: hub, variant: v3, price: 44.44, count_on_hand: 16) } + let(:vo3) { create(:variant_override, hub:, variant: v3, price: 44.44, count_on_hand: 16) } let(:vo_price_only) { - create(:variant_override, :use_producer_stock_settings, hub: hub, variant: v, price: 22.22) + create(:variant_override, :use_producer_stock_settings, hub:, variant: v, price: 22.22) } let(:scoper) { ScopeVariantToHub.new(hub) } diff --git a/spec/lib/open_food_network/scope_variants_to_search_spec.rb b/spec/lib/open_food_network/scope_variants_to_search_spec.rb index f9c72214b1..1c528a8e45 100644 --- a/spec/lib/open_food_network/scope_variants_to_search_spec.rb +++ b/spec/lib/open_food_network/scope_variants_to_search_spec.rb @@ -93,21 +93,21 @@ describe OpenFoodNetwork::ScopeVariantsForSearch do variant = create(:simple_product).variants.first variant.stock_items.first.update!(backorderable: false, count_on_hand: 1) create(:simple_order_cycle, distributors: [d1], variants: [variant]) - create(:variant_override, variant: variant, hub: d1, on_demand: false, count_on_hand: 0) + create(:variant_override, variant:, hub: d1, on_demand: false, count_on_hand: 0) variant end let!(:distributor1_variant_with_override_without_stock_level_set_and_no_producer_stock) do variant = create(:simple_product).variants.first variant.stock_items.first.update!(backorderable: false, count_on_hand: 0) create(:simple_order_cycle, distributors: [d1], variants: [variant]) - create(:variant_override, variant: variant, hub: d1, on_demand: nil, count_on_hand: nil) + create(:variant_override, variant:, hub: d1, on_demand: nil, count_on_hand: nil) variant end let!(:distributor1_variant_with_override_without_stock_level_set_but_producer_in_stock) do variant = create(:simple_product).variants.first variant.stock_items.first.update!(backorderable: false, count_on_hand: 1) create(:simple_order_cycle, distributors: [d1], variants: [variant]) - create(:variant_override, variant: variant, hub: d1, on_demand: nil, count_on_hand: nil) + create(:variant_override, variant:, hub: d1, on_demand: nil, count_on_hand: nil) variant end let!(:distributor2_variant_with_override_in_stock) do @@ -191,7 +191,7 @@ describe OpenFoodNetwork::ScopeVariantsForSearch do variant.stock_items.first.update!(backorderable: false, count_on_hand: 0) create(:simple_order_cycle, distributors: [distributor], variants: [variant]) create(:variant_override, { - variant: variant, + variant:, hub: distributor }.merge(variant_override_attributes)) variant diff --git a/spec/lib/open_food_network/tag_rule_applicator_spec.rb b/spec/lib/open_food_network/tag_rule_applicator_spec.rb index 336324fb3f..9aa14c8ccc 100644 --- a/spec/lib/open_food_network/tag_rule_applicator_spec.rb +++ b/spec/lib/open_food_network/tag_rule_applicator_spec.rb @@ -7,37 +7,37 @@ module OpenFoodNetwork describe TagRuleApplicator do let!(:enterprise) { create(:distributor_enterprise) } let!(:oc_tag_rule) { - create(:filter_order_cycles_tag_rule, enterprise: enterprise, priority: 6, + create(:filter_order_cycles_tag_rule, enterprise:, priority: 6, preferred_customer_tags: "tag1", preferred_exchange_tags: "tag1", preferred_matched_order_cycles_visibility: "visible" ) } let!(:product_tag_rule1) { - create(:filter_products_tag_rule, enterprise: enterprise, priority: 5, + create(:filter_products_tag_rule, enterprise:, priority: 5, preferred_customer_tags: "tag1", preferred_variant_tags: "tag1", preferred_matched_variants_visibility: "visible" ) } let!(:product_tag_rule2) { - create(:filter_products_tag_rule, enterprise: enterprise, priority: 4, + create(:filter_products_tag_rule, enterprise:, priority: 4, preferred_customer_tags: "tag1", preferred_variant_tags: "tag3", preferred_matched_variants_visibility: "hidden" ) } let!(:product_tag_rule3) { - create(:filter_products_tag_rule, enterprise: enterprise, priority: 3, + create(:filter_products_tag_rule, enterprise:, priority: 3, preferred_customer_tags: "tag2", preferred_variant_tags: "tag1", preferred_matched_variants_visibility: "visible" ) } let!(:default_product_tag_rule) { - create(:filter_products_tag_rule, enterprise: enterprise, priority: 2, is_default: true, + create(:filter_products_tag_rule, enterprise:, priority: 2, is_default: true, preferred_variant_tags: "tag1", preferred_matched_variants_visibility: "hidden" ) } let!(:sm_tag_rule) { create( - :filter_shipping_methods_tag_rule, enterprise: enterprise, priority: 1, + :filter_shipping_methods_tag_rule, enterprise:, priority: 1, preferred_customer_tags: "tag1", preferred_shipping_method_tags: "tag1", preferred_matched_shipping_methods_visibility: "visible" diff --git a/spec/lib/reports/bulk_coop_report_spec.rb b/spec/lib/reports/bulk_coop_report_spec.rb index b648e6cbe6..d94e1429c1 100644 --- a/spec/lib/reports/bulk_coop_report_spec.rb +++ b/spec/lib/reports/bulk_coop_report_spec.rb @@ -112,7 +112,7 @@ module Reporting let(:s1) { create(:supplier_enterprise) } before do - s1.enterprise_roles.create!(user: user) + s1.enterprise_roles.create!(user:) end context "that has granted P-OC to the distributor" do diff --git a/spec/lib/reports/customers_report_spec.rb b/spec/lib/reports/customers_report_spec.rb index e42e948f58..005e486199 100644 --- a/spec/lib/reports/customers_report_spec.rb +++ b/spec/lib/reports/customers_report_spec.rb @@ -163,7 +163,7 @@ module Reporting [:first_name, :last_name, :billing_address, :email, :phone, :hub, :hub_address, :shipping_method] end - subject { Addresses.new(user, { fields_to_show: fields_to_show }) } + subject { Addresses.new(user, { fields_to_show: }) } it "returns one row per customer per shipping method" do expect(subject.query_result.size).to eq(2) @@ -199,7 +199,7 @@ module Reporting let(:fields_to_show) do [:first_name, :last_name, :billing_address, :email, :phone, :hub, :hub_address] end - subject { Addresses.new(user, { fields_to_show: fields_to_show }) } + subject { Addresses.new(user, { fields_to_show: }) } it "returns a single row for the customer, otherwise it would return two identical rows" do @@ -249,12 +249,12 @@ module Reporting describe "fetching orders" do let(:supplier) { create(:supplier_enterprise) } - let(:product) { create(:simple_product, supplier: supplier) } + let(:product) { create(:simple_product, supplier:) } let(:order) { create(:order, completed_at: 1.day.ago) } it "only shows orders managed by the current user" do d1 = create(:distributor_enterprise) - d1.enterprise_roles.build(user: user).save + d1.enterprise_roles.build(user:).save d2 = create(:distributor_enterprise) d2.enterprise_roles.build(user: create(:user)).save @@ -267,8 +267,8 @@ module Reporting it "does not show orders through a hub that the current user does not manage" do # Given a supplier enterprise with an order for one of its products - supplier.enterprise_roles.build(user: user).save - order.line_items << create(:line_item_with_shipment, product: product) + supplier.enterprise_roles.build(user:).save + order.line_items << create(:line_item_with_shipment, product:) # When I fetch orders, I should see no orders expect(subject).to receive(:filter).with([]).and_return([]) @@ -287,7 +287,7 @@ module Reporting it "returns orders with a specific supplier" do supplier = create(:supplier_enterprise) supplier2 = create(:supplier_enterprise) - product1 = create(:simple_product, supplier: supplier) + product1 = create(:simple_product, supplier:) product2 = create(:simple_product, supplier: supplier2) order1 = create(:order) order2 = create(:order) diff --git a/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb b/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb index 4a30f5b7dc..aaeb80717c 100644 --- a/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb +++ b/spec/lib/reports/enterprise_fee_summary/enterprise_fee_summary_report_spec.rb @@ -30,7 +30,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do let!(:other_coordinator_fee) { create(:enterprise_fee, :per_item, enterprise: coordinator) } # Set up other requirements for ordering. - let!(:order_cycle) { create(:simple_order_cycle, coordinator: coordinator) } + let!(:order_cycle) { create(:simple_order_cycle, coordinator:) } let!(:product) { create(:product) } let!(:product_tax_category) { create(:tax_category, name: "Sample Product Tax") } let!(:variant) { prepare_variant(tax_category: product_tax_category) } @@ -50,7 +50,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do describe "grouping and sorting of entries" do let!(:order_cycle) do - create(:simple_order_cycle, coordinator: coordinator, coordinator_fees: order_cycle_fees) + create(:simple_order_cycle, coordinator:, coordinator_fees: order_cycle_fees) end let!(:variant) do @@ -95,9 +95,9 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do end let!(:distributor_tax_category) { create(:tax_category, name: "Sample Distributor Tax") } - let!(:customer_order) { prepare_order(customer: customer) } - let!(:customer_incomplete_order) { prepare_incomplete_order(customer: customer) } - let!(:second_customer_order) { prepare_order(customer: customer) } + let!(:customer_order) { prepare_order(customer:) } + let!(:customer_incomplete_order) { prepare_incomplete_order(customer:) } + let!(:second_customer_order) { prepare_order(customer:) } let!(:other_customer_order) { prepare_order(customer: another_customer) } it "doesn't delete params" do @@ -164,7 +164,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do describe "data exclusions" do describe "invalid adjustments (through 'eligible') like failed payments" do - let!(:customer_order) { prepare_order(customer: customer) } + let!(:customer_order) { prepare_order(customer:) } before do # Make the payment fail. See Spree::Payment#revoke_adjustment_eligibility. @@ -197,7 +197,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do fee_type: "admin", amount: 0) end - let!(:customer_order) { prepare_order(customer: customer) } + let!(:customer_order) { prepare_order(customer:) } before do # Change "eligible" in enterprise fee adjustment to false. $0 adjustments that are not @@ -231,7 +231,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do create(:payment_method, :per_item, amount: 0, name: "Sample Payment Method") end - let!(:customer_order) { prepare_order(customer: customer) } + let!(:customer_order) { prepare_order(customer:) } it "is included" do totals = subject.query_result @@ -263,22 +263,22 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do tax_category = create(:tax_category, name: "Sample Producer Tax") create(:enterprise_fee, :per_item, name: "Sample Producer Fee", enterprise: producer, fee_type: "sales", amount: 64.0, - tax_category: tax_category) + tax_category:) end let!(:coordinator_fee) do tax_category = create(:tax_category, name: "Sample Coordinator Tax") create(:enterprise_fee, :per_item, name: "Sample Coordinator Fee", enterprise: coordinator, fee_type: "admin", amount: 512.0, - tax_category: tax_category) + tax_category:) end let!(:distributor_fee) do tax_category = create(:tax_category, name: "Sample Distributor Tax") create(:enterprise_fee, :per_item, name: "Sample Distributor Fee", enterprise: distributor, fee_type: "admin", amount: 4.0, - tax_category: tax_category) + tax_category:) end - let!(:customer_order) { prepare_order(customer: customer) } + let!(:customer_order) { prepare_order(customer:) } it "fetches data correctly" do totals = subject.query_result @@ -310,13 +310,13 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do let!(:producer_fee) do tax_category = create(:tax_category, name: "Producer Tax A") create(:enterprise_fee, :flat_rate, name: "Producer Fee A", enterprise: producer, - fee_type: "sales", tax_category: tax_category, + fee_type: "sales", tax_category:, amount: 10) end let!(:coordinator_fee) do tax_category = create(:tax_category, name: "Coordinator Tax A") create(:enterprise_fee, :flat_rate, name: "Coordinator Fee A", enterprise: coordinator, - fee_type: "admin", tax_category: tax_category, + fee_type: "admin", tax_category:, amount: 15) end let!(:coordinator_fee_inheriting_product_tax_category) do @@ -344,7 +344,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do end let!(:order_cycle) do - create(:simple_order_cycle, coordinator: coordinator, coordinator_fees: coordinator_fees) + create(:simple_order_cycle, coordinator:, coordinator_fees:) end let!(:variant_incoming_exchange_fees) { [producer_fee, coordinator_fee, distributor_fee] } @@ -355,7 +355,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do outgoing_exchange_fees: variant_outgoing_exchange_fees) end - let!(:customer_order) { prepare_order(customer: customer) } + let!(:customer_order) { prepare_order(customer:) } it "fetches data correctly" do totals = subject.query_result @@ -408,8 +408,8 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do shipping_methods: [shipping_method]) end - let!(:order_cycle_a) { create(:simple_order_cycle, coordinator: coordinator) } - let!(:order_cycle_b) { create(:simple_order_cycle, coordinator: coordinator) } + let!(:order_cycle_a) { create(:simple_order_cycle, coordinator:) } + let!(:order_cycle_b) { create(:simple_order_cycle, coordinator:) } let!(:variant_a) { prepare_variant(distributor: distributor_a, order_cycle: order_cycle_a) } let!(:variant_b) { prepare_variant(distributor: distributor_b, order_cycle: order_cycle_b) } @@ -575,9 +575,9 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do shipping_methods: [shipping_method]) end - let!(:order_cycle_a) { create(:simple_order_cycle, coordinator: coordinator) } - let!(:order_cycle_b) { create(:simple_order_cycle, coordinator: coordinator) } - let!(:order_cycle_c) { create(:simple_order_cycle, coordinator: coordinator) } + let!(:order_cycle_a) { create(:simple_order_cycle, coordinator:) } + let!(:order_cycle_b) { create(:simple_order_cycle, coordinator:) } + let!(:order_cycle_c) { create(:simple_order_cycle, coordinator:) } let!(:variant_a) { prepare_variant(distributor: distributor_a, order_cycle: order_cycle_a) } let!(:variant_b) { prepare_variant(distributor: distributor_b, order_cycle: order_cycle_b) } @@ -606,7 +606,7 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do let!(:variant) { prepare_variant(outgoing_exchange_fees: variant_outgoing_exchange_fees) } let!(:variant_outgoing_exchange_fees) { [fee_a, fee_b, fee_c] } - let!(:order) { prepare_order(variant: variant) } + let!(:order) { prepare_order(variant:) } let(:parameters_attributes) { { enterprise_fee_ids: [fee_a.id, fee_b.id] } } @@ -703,8 +703,8 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do end def default_order_options - { customer: customer, distributor: distributor, order_cycle: order_cycle, - shipping_method: shipping_method, variant: variant } + { customer:, distributor:, order_cycle:, + shipping_method:, variant: } end def prepare_incomplete_order(options = {}) @@ -713,14 +713,14 @@ describe Reporting::Reports::EnterpriseFeeSummary::FeeSummary do end def prepare_order(options = {}) - factory_trait_options = { payment_method: payment_method } + factory_trait_options = { payment_method: } target_options = default_order_options.merge(factory_trait_options).merge(options) create(:order, :with_line_item, :completed, target_options) end def default_variant_options - { product: product, producer: producer, coordinator: coordinator, - distributor: distributor, order_cycle: order_cycle } + { product:, producer:, coordinator:, + distributor:, order_cycle: } end def prepare_variant(options = {}) diff --git a/spec/lib/reports/enterprise_fee_summary/permissions_spec.rb b/spec/lib/reports/enterprise_fee_summary/permissions_spec.rb index 11530314d5..8de188cbdf 100644 --- a/spec/lib/reports/enterprise_fee_summary/permissions_spec.rb +++ b/spec/lib/reports/enterprise_fee_summary/permissions_spec.rb @@ -4,8 +4,8 @@ require "spec_helper" describe Reporting::Reports::EnterpriseFeeSummary::Permissions do let!(:order_cycle) { create(:simple_order_cycle) } - let!(:incoming_exchange) { create(:exchange, incoming: true, order_cycle: order_cycle) } - let!(:outgoing_exchange) { create(:exchange, incoming: false, order_cycle: order_cycle) } + let!(:incoming_exchange) { create(:exchange, incoming: true, order_cycle:) } + let!(:outgoing_exchange) { create(:exchange, incoming: false, order_cycle:) } # The factory for order cycle uses the first distributor it finds in the database, if it exists. # However, for this example group, we need to make sure that the coordinator for the second order diff --git a/spec/lib/reports/lettuce_share_report_spec.rb b/spec/lib/reports/lettuce_share_report_spec.rb index d9af25be08..528b085427 100644 --- a/spec/lib/reports/lettuce_share_report_spec.rb +++ b/spec/lib/reports/lettuce_share_report_spec.rb @@ -45,9 +45,9 @@ module Reporting create(:address, address1: "distributor address", city: 'The Shire', zipcode: "1234") } let(:hub) { create(:distributor_enterprise, address: hub_address) } - let(:variant2_override) { create(:variant_override, hub: hub, variant: variant2) } + let(:variant2_override) { create(:variant_override, hub:, variant: variant2) } let(:variant3_override) { - create(:variant_override, hub: hub, variant: variant3, count_on_hand: 0) + create(:variant_override, hub:, variant: variant3, count_on_hand: 0) } it "all items" do diff --git a/spec/lib/reports/line_items_spec.rb b/spec/lib/reports/line_items_spec.rb index 0814778837..0e266352c1 100644 --- a/spec/lib/reports/line_items_spec.rb +++ b/spec/lib/reports/line_items_spec.rb @@ -41,7 +41,7 @@ describe Reporting::LineItems do shipments: [build(:shipment)] ) end - let!(:line_item1) { create(:line_item, order: order) } + let!(:line_item1) { create(:line_item, order:) } let(:orders_relation) { Spree::Order.where(id: order.id) } let(:order_permissions) { FakeOrderPermissions.new([line_item1], orders_relation) } @@ -55,8 +55,8 @@ describe Reporting::LineItems do context "when filtering by product" do subject(:line_items) { reports_line_items.list } - let!(:line_item2) { create(:line_item, order: order) } - let!(:line_item3) { create(:line_item, order: order) } + let!(:line_item2) { create(:line_item, order:) } + let!(:line_item3) { create(:line_item, order:) } let(:order_permissions) do FakeOrderPermissions.new([line_item1, line_item2, line_item3], orders_relation) end diff --git a/spec/lib/reports/order_cycle_management_report_spec.rb b/spec/lib/reports/order_cycle_management_report_spec.rb index 62a18e600b..6b88cdc4e9 100644 --- a/spec/lib/reports/order_cycle_management_report_spec.rb +++ b/spec/lib/reports/order_cycle_management_report_spec.rb @@ -67,12 +67,12 @@ module Reporting describe "fetching orders" do let(:supplier) { create(:supplier_enterprise) } - let(:product) { create(:simple_product, supplier: supplier) } + let(:product) { create(:simple_product, supplier:) } let(:order) { create(:order, completed_at: 1.day.ago) } it "only shows orders managed by the current user" do d1 = create(:distributor_enterprise) - d1.enterprise_roles.create!(user: user) + d1.enterprise_roles.create!(user:) d2 = create(:distributor_enterprise) d2.enterprise_roles.create!(user: create(:user)) @@ -85,8 +85,8 @@ module Reporting it "does not show orders through a hub that the current user does not manage" do # Given a supplier enterprise with an order for one of its products - supplier.enterprise_roles.create!(user: user) - order.line_items << create(:line_item_with_shipment, product: product) + supplier.enterprise_roles.create!(user:) + order.line_items << create(:line_item_with_shipment, product:) # When I fetch orders, I should see no orders expect(subject).to receive(:filter).with([]).and_return([]) @@ -151,7 +151,7 @@ module Reporting subject { Base.new(user, params) } let(:distributor) { create(:distributor_enterprise) } - before { distributor.enterprise_roles.create!(user: user) } + before { distributor.enterprise_roles.create!(user:) } context 'when the report type is payment_methods' do subject { PaymentMethods.new(user) } @@ -159,7 +159,7 @@ module Reporting let!(:order) do create( :completed_order_with_totals, - distributor: distributor, + distributor:, completed_at: 1.day.ago ) end @@ -186,7 +186,7 @@ module Reporting let!(:order) do create( :completed_order_with_totals, - distributor: distributor, + distributor:, completed_at: 1.day.ago ) end diff --git a/spec/lib/reports/orders_and_distributors_report_spec.rb b/spec/lib/reports/orders_and_distributors_report_spec.rb index 76f118eea1..689ea4d791 100644 --- a/spec/lib/reports/orders_and_distributors_report_spec.rb +++ b/spec/lib/reports/orders_and_distributors_report_spec.rb @@ -32,12 +32,12 @@ module Reporting let(:order) { create(:order, state: 'complete', completed_at: Time.zone.now, - distributor: distributor, bill_address: bill_address, + distributor:, bill_address:, special_instructions: shipping_instructions) } let(:payment_method) { create(:payment_method, distributors: [distributor]) } - let(:payment) { create(:payment, payment_method: payment_method, order: order) } - let(:line_item) { create(:line_item_with_shipment, product: product, order: order) } + let(:payment) { create(:payment, payment_method:, order:) } + let(:line_item) { create(:line_item_with_shipment, product:, order:) } before do order.select_shipping_method(shipping_method.id) @@ -76,7 +76,7 @@ module Reporting end it "prints one row per line item" do - create(:line_item_with_shipment, order: order) + create(:line_item_with_shipment, order:) subject = Base.new(create(:admin_user)) @@ -86,7 +86,7 @@ module Reporting context "filtering by distributor" do it do - create(:line_item_with_shipment, order: order) + create(:line_item_with_shipment, order:) report1 = Base.new(create(:admin_user), {}) table = report1.table_rows diff --git a/spec/lib/reports/orders_and_fulfillment/order_cycle_customer_totals_report_spec.rb b/spec/lib/reports/orders_and_fulfillment/order_cycle_customer_totals_report_spec.rb index 6b9ce4121d..c19e9acbd8 100644 --- a/spec/lib/reports/orders_and_fulfillment/order_cycle_customer_totals_report_spec.rb +++ b/spec/lib/reports/orders_and_fulfillment/order_cycle_customer_totals_report_spec.rb @@ -4,7 +4,7 @@ require "spec_helper" describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotals do let!(:distributor) { create(:distributor_enterprise, name: "Apple Market") } - let!(:customer) { create(:customer, enterprise: distributor, user: user, code: "JHN") } + let!(:customer) { create(:customer, enterprise: distributor, user:, code: "JHN") } let(:user) { create(:user, email: "john@example.net") } let(:current_user) { distributor.owner } let(:params) { { display_summary_row: true, q: search_params } } @@ -25,8 +25,8 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotals do number: "R644360121", line_items_count: 1, user: customer.user, - customer: customer, - distributor: distributor, + customer:, + distributor:, completed_at: order_date, ).tap do |order| order.line_items[0].product.supplier.update(name: "Apple Farmer") @@ -84,7 +84,7 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotals do create( :completed_order_with_totals, line_items_count: 1, user: customer.user, - customer: customer, distributor: distributor, + customer:, distributor:, completed_at: order_date, ) end @@ -105,12 +105,12 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotals do create( :order_ready_to_ship, user: customer.user, - customer: customer, distributor: distributor, + customer:, distributor:, completed_at: order_date, ) } let(:completed_payment) { order.payments.completed.first } - let!(:failed_payment) { create(:payment, order: order, state: "failed") } + let!(:failed_payment) { create(:payment, order:, state: "failed") } before do completed_payment.adjustment.update amount: 123.00 @@ -128,7 +128,7 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleCustomerTotals do create( :completed_order_with_totals, line_items_count: 1, user: customer.user, - customer: customer, distributor: distributor, + customer:, distributor:, completed_at: order_date, ) end diff --git a/spec/lib/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier_report_spec.rb b/spec/lib/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier_report_spec.rb index 39283c6fd3..f88dab48bd 100644 --- a/spec/lib/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier_report_spec.rb +++ b/spec/lib/reports/orders_and_fulfillment/order_cycle_distributor_totals_by_supplier_report_spec.rb @@ -9,7 +9,7 @@ module Reporting let!(:distributor) { create(:distributor_enterprise) } let!(:order) do - create(:completed_order_with_totals, line_items_count: 1, distributor: distributor) + create(:completed_order_with_totals, line_items_count: 1, distributor:) end let(:current_user) { distributor.owner } diff --git a/spec/lib/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor_report_spec.rb b/spec/lib/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor_report_spec.rb index 807089057e..a5ddd3f877 100644 --- a/spec/lib/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor_report_spec.rb +++ b/spec/lib/reports/orders_and_fulfillment/order_cycle_supplier_totals_by_distributor_report_spec.rb @@ -9,7 +9,7 @@ module Reporting let!(:distributor) { create(:distributor_enterprise) } let!(:order) do - create(:completed_order_with_totals, line_items_count: 3, distributor: distributor) + create(:completed_order_with_totals, line_items_count: 3, distributor:) end let(:current_user) { distributor.owner } diff --git a/spec/lib/reports/orders_and_fulfillment/orders_cycle_supplier_totals_report_spec.rb b/spec/lib/reports/orders_and_fulfillment/orders_cycle_supplier_totals_report_spec.rb index 91f7d624e0..e5206e429a 100644 --- a/spec/lib/reports/orders_and_fulfillment/orders_cycle_supplier_totals_report_spec.rb +++ b/spec/lib/reports/orders_and_fulfillment/orders_cycle_supplier_totals_report_spec.rb @@ -6,7 +6,7 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleSupplierTotals do let!(:distributor) { create(:distributor_enterprise) } let!(:order) do - create(:completed_order_with_totals, line_items_count: 1, distributor: distributor) + create(:completed_order_with_totals, line_items_count: 1, distributor:) end let!(:supplier) do order.line_items.first.variant.product.supplier @@ -75,7 +75,7 @@ describe Reporting::Reports::OrdersAndFulfillment::OrderCycleSupplierTotals do item.update!(quantity: 3) # And a second item to add up with: - item2 = create(:line_item, order: order) + item2 = create(:line_item, order:) expect(table_headers[4]).to eq "Total Units" expect(report_table[0][4]).to eq 0.6 # kg (= 3 * 0.2kg) diff --git a/spec/lib/reports/packing/packing_report_spec.rb b/spec/lib/reports/packing/packing_report_spec.rb index 7de9141c2c..c1b12e0bfe 100644 --- a/spec/lib/reports/packing/packing_report_spec.rb +++ b/spec/lib/reports/packing/packing_report_spec.rb @@ -9,7 +9,7 @@ describe "Packing Reports" do let(:distributor) { create(:distributor_enterprise) } let(:order_cycle) { create(:simple_order_cycle) } let(:order) { - create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor, + create(:completed_order_with_totals, order_cycle:, distributor:, line_items_count: 0) } let(:line_item) { build(:line_item_with_shipment) } @@ -51,7 +51,7 @@ describe "Packing Reports" do let(:supplier1) { create(:supplier_enterprise) } let(:supplier2) { create(:supplier_enterprise) } let(:order2) { - create(:completed_order_with_totals, distributor: distributor, + create(:completed_order_with_totals, distributor:, bill_address: create(:address), ship_address: create(:address)) } @@ -68,7 +68,7 @@ describe "Packing Reports" do order2.line_items << line_item2 order2.line_items << line_item3 order2.finalize! - supplier1.enterprise_roles.create!(user: user) + supplier1.enterprise_roles.create!(user:) end context "which has not granted P-OC to the distributor" do @@ -121,7 +121,7 @@ describe "Packing Reports" do before do order3.line_items << line_item3 order3.finalize! - distributor.enterprise_roles.create!(user: user) + distributor.enterprise_roles.create!(user:) end it "only shows line items distributed by enterprises managed by the current user" do @@ -132,7 +132,7 @@ describe "Packing Reports" do context "filtering results" do let(:order_cycle2) { create(:simple_order_cycle) } let(:order4) { - create(:completed_order_with_totals, distributor: distributor, order_cycle: order_cycle2, + create(:completed_order_with_totals, distributor:, order_cycle: order_cycle2, line_items_count: 0) } let(:line_item4) { build(:line_item_with_shipment) } @@ -166,7 +166,7 @@ describe "Packing Reports" do describe "ordering and grouping" do let(:distributor2) { create(:distributor_enterprise) } let(:order2) { - create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor2, + create(:completed_order_with_totals, order_cycle:, distributor: distributor2, line_items_count: 2) } diff --git a/spec/lib/reports/products_and_inventory_report_spec.rb b/spec/lib/reports/products_and_inventory_report_spec.rb index a3feb0d5ae..f2449f56f0 100644 --- a/spec/lib/reports/products_and_inventory_report_spec.rb +++ b/spec/lib/reports/products_and_inventory_report_spec.rb @@ -85,7 +85,7 @@ module Reporting describe "fetching child variants" do it "returns some variants" do - product1 = create(:simple_product, supplier: supplier) + product1 = create(:simple_product, supplier:) variant1 = product1.variants.first variant2 = create(:variant, product: product1) @@ -94,7 +94,7 @@ module Reporting it "should only return variants managed by the user" do product1 = create(:simple_product, supplier: create(:supplier_enterprise)) - product2 = create(:simple_product, supplier: supplier) + product2 = create(:simple_product, supplier:) variant1 = product1.variants.first variant2 = product2.variants.first @@ -107,8 +107,8 @@ module Reporting describe "based on report type" do it "returns only variants on hand" do - product1 = create(:simple_product, supplier: supplier, on_hand: 99) - product2 = create(:simple_product, supplier: supplier, on_hand: 0) + product1 = create(:simple_product, supplier:, on_hand: 99) + product2 = create(:simple_product, supplier:, on_hand: 0) subject = Inventory.new enterprise_user expect(subject.filter(variants)).to eq([product1.variants.first]) @@ -116,7 +116,7 @@ module Reporting end it "filters to a specific supplier" do supplier2 = create(:supplier_enterprise) - product1 = create(:simple_product, supplier: supplier) + product1 = create(:simple_product, supplier:) product2 = create(:simple_product, supplier: supplier2) allow(subject).to receive(:params).and_return(supplier_id: supplier.id) @@ -124,8 +124,8 @@ module Reporting end it "filters to a specific distributor" do distributor = create(:distributor_enterprise) - product1 = create(:simple_product, supplier: supplier) - product2 = create(:simple_product, supplier: supplier) + product1 = create(:simple_product, supplier:) + product2 = create(:simple_product, supplier:) order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product2.variants.first]) @@ -136,12 +136,12 @@ module Reporting it "ignores variant overrides without filter" do distributor = create(:distributor_enterprise) - product = create(:simple_product, supplier: supplier, price: 5) + product = create(:simple_product, supplier:, price: 5) variant = product.variants.first order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product.variants.first]) - create(:variant_override, hub: distributor, variant: variant, price: 2) + create(:variant_override, hub: distributor, variant:, price: 2) result = subject.filter(variants) @@ -150,12 +150,12 @@ module Reporting it "considers variant overrides with distributor" do distributor = create(:distributor_enterprise) - product = create(:simple_product, supplier: supplier, price: 5) + product = create(:simple_product, supplier:, price: 5) variant = product.variants.first order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product.variants.first]) - create(:variant_override, hub: distributor, variant: variant, price: 2) + create(:variant_override, hub: distributor, variant:, price: 2) allow(subject).to receive(:params).and_return(distributor_id: distributor.id) result = subject.filter(variants) @@ -165,8 +165,8 @@ module Reporting it "filters to a specific order cycle" do distributor = create(:distributor_enterprise) - product1 = create(:simple_product, supplier: supplier) - product2 = create(:simple_product, supplier: supplier) + product1 = create(:simple_product, supplier:) + product2 = create(:simple_product, supplier:) order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product1.variants.first]) @@ -181,14 +181,14 @@ module Reporting distributor = create(:distributor_enterprise) other_distributor = create(:distributor_enterprise) other_supplier = create(:supplier_enterprise) - not_filtered_variant = create(:simple_product, supplier: supplier).variants.first + not_filtered_variant = create(:simple_product, supplier:).variants.first variant_filtered_by_order_cycle = create(:simple_product, - supplier: supplier).variants.first + supplier:).variants.first variant_filtered_by_distributor = create(:simple_product, - supplier: supplier).variants.first + supplier:).variants.first variant_filtered_by_supplier = create(:simple_product, supplier: other_supplier).variants.first - variant_filtered_by_stock = create(:simple_product, supplier: supplier, + variant_filtered_by_stock = create(:simple_product, supplier:, on_hand: 0).variants.first # This OC contains all products except the one that should be filtered diff --git a/spec/lib/spree/core/product_duplicator_spec.rb b/spec/lib/spree/core/product_duplicator_spec.rb index 0375b19597..08a8d9364e 100644 --- a/spec/lib/spree/core/product_duplicator_spec.rb +++ b/spec/lib/spree/core/product_duplicator_spec.rb @@ -8,7 +8,7 @@ describe Spree::Core::ProductDuplicator do name: "foo", product_properties: [property], variants: [variant], - image: image, + image:, variant_unit: 'item' end diff --git a/spec/lib/stripe/account_connector_spec.rb b/spec/lib/stripe/account_connector_spec.rb index 2fc37b345d..c0181ff3b8 100644 --- a/spec/lib/stripe/account_connector_spec.rb +++ b/spec/lib/stripe/account_connector_spec.rb @@ -74,7 +74,7 @@ module Stripe context "and the user manages the corresponding enterprise" do before do - user.enterprise_roles.create(enterprise: enterprise) + user.enterprise_roles.create(enterprise:) end it "raises no errors" do diff --git a/spec/lib/tasks/data/remove_transient_data_spec.rb b/spec/lib/tasks/data/remove_transient_data_spec.rb index 9cd1091b7c..3b7aacf4db 100644 --- a/spec/lib/tasks/data/remove_transient_data_spec.rb +++ b/spec/lib/tasks/data/remove_transient_data_spec.rb @@ -41,11 +41,11 @@ describe RemoveTransientData do let(:variant) { product.variants.first } let!(:cart) { create(:order, state: 'cart') } - let!(:line_item) { create(:line_item, order: cart, variant: variant) } + let!(:line_item) { create(:line_item, order: cart, variant:) } let!(:adjustment) { create(:adjustment, order: cart) } let!(:old_cart) { create(:order, state: 'cart', updated_at: retention_period - 1.day) } - let!(:old_line_item) { create(:line_item, order: old_cart, variant: variant) } + let!(:old_line_item) { create(:line_item, order: old_cart, variant:) } let!(:old_adjustment) { create(:adjustment, order: old_cart) } before do diff --git a/spec/lib/tasks/data/truncate_data_spec.rb b/spec/lib/tasks/data/truncate_data_spec.rb index d2ae629d8e..fe2b249d8e 100644 --- a/spec/lib/tasks/data/truncate_data_spec.rb +++ b/spec/lib/tasks/data/truncate_data_spec.rb @@ -15,7 +15,7 @@ describe TruncateData do order_cycle = create( :order_cycle, orders_open_at: 25.months.ago, orders_close_at: 25.months.ago + 1.day ) - create(:order, order_cycle: order_cycle) + create(:order, order_cycle:) TruncateData.new.call @@ -28,7 +28,7 @@ describe TruncateData do order_cycle = create( :order_cycle, orders_open_at: 25.months.ago, orders_close_at: 25.months.ago + 1.day ) - create(:order, order_cycle: order_cycle) + create(:order, order_cycle:) TruncateData.new(nil).call diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb index ef19ec4ee9..019ec1f977 100644 --- a/spec/mailers/order_mailer_spec.rb +++ b/spec/mailers/order_mailer_spec.rb @@ -139,7 +139,7 @@ describe Spree::OrderMailer do describe "#cancel_email_for_shop" do let(:distributor) { create(:distributor_enterprise) } - let(:order) { create(:order, distributor: distributor, state: "canceled") } + let(:order) { create(:order, distributor:, state: "canceled") } let(:admin_order_link_href) { "href=\"#{spree.edit_admin_order_url(order)}\"" } let(:mail) { Spree::OrderMailer.cancel_email_for_shop(order) } @@ -163,8 +163,8 @@ describe Spree::OrderMailer do create(:address, address1: "distributor address", city: 'The Shire', zipcode: "1234") } let(:order) { - create(:order_with_line_items, distributor: distributor, bill_address: bill_address, - ship_address: ship_address, + create(:order_with_line_items, distributor:, bill_address:, + ship_address:, special_instructions: shipping_instructions) } diff --git a/spec/mailers/producer_mailer_spec.rb b/spec/mailers/producer_mailer_spec.rb index 8642ecdba4..5de4e2869b 100644 --- a/spec/mailers/producer_mailer_spec.rb +++ b/spec/mailers/producer_mailer_spec.rb @@ -6,7 +6,7 @@ require 'yaml' describe ProducerMailer, type: :mailer do let!(:zone) { create(:zone_with_member) } let!(:tax_rate) { - create(:tax_rate, included_in_price: true, calculator: Calculator::DefaultTax.new, zone: zone, + create(:tax_rate, included_in_price: true, calculator: Calculator::DefaultTax.new, zone:, amount: 0.1) } let!(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) } @@ -34,7 +34,7 @@ describe ProducerMailer, type: :mailer do } let!(:order) do - order = create(:order, distributor: d1, order_cycle: order_cycle, state: 'complete') + order = create(:order, distributor: d1, order_cycle:, state: 'complete') order.line_items << create(:line_item, quantity: 1, variant: p1.variants.first) order.line_items << create(:line_item, quantity: 2, variant: p1.variants.first) order.line_items << create(:line_item, quantity: 3, variant: p2.variants.first) @@ -44,13 +44,13 @@ describe ProducerMailer, type: :mailer do order end let!(:order_incomplete) do - order = create(:order, distributor: d1, order_cycle: order_cycle, state: 'payment') + order = create(:order, distributor: d1, order_cycle:, state: 'payment') order.line_items << create(:line_item, variant: p3.variants.first) order.save order end let!(:order_canceled) do - order = create(:order, distributor: d1, order_cycle: order_cycle, state: 'complete') + order = create(:order, distributor: d1, order_cycle:, state: 'complete') order.line_items << create(:line_item, variant: p5.variants.first) order.finalize! order.cancel @@ -102,7 +102,7 @@ describe ProducerMailer, type: :mailer do context "when a cancelled order has been resumed" do let!(:order_resumed) do - order = create(:order, distributor: d1, order_cycle: order_cycle, state: 'complete') + order = create(:order, distributor: d1, order_cycle:, state: 'complete') order.line_items << create(:line_item, variant: p6.variants.first) order.finalize! order.cancel @@ -165,9 +165,9 @@ describe ProducerMailer, type: :mailer do end it "it orders list via last name" do - create(:order, :with_line_item, distributor: d1, order_cycle: order_cycle, state: 'complete', + create(:order, :with_line_item, distributor: d1, order_cycle:, state: 'complete', bill_address: FactoryBot.create(:address, last_name: "Abby")) - create(:order, :with_line_item, distributor: d1, order_cycle: order_cycle, state: 'complete', + create(:order, :with_line_item, distributor: d1, order_cycle:, state: 'complete', bill_address: FactoryBot.create(:address, last_name: "smith")) expect(mail.body.encoded).to match(/.*Abby.*Doe.*smith/m) end diff --git a/spec/mailers/report_mailer_spec.rb b/spec/mailers/report_mailer_spec.rb index ad66d03b54..443617afd3 100644 --- a/spec/mailers/report_mailer_spec.rb +++ b/spec/mailers/report_mailer_spec.rb @@ -7,7 +7,7 @@ describe ReportMailer do subject(:email) { ReportMailer.with( to: "current_user@example.net", - blob: blob, + blob:, ).report_ready } let(:blob) { ReportBlob.create_for_upload_later!("customers.csv") } diff --git a/spec/mailers/shipment_mailer_spec.rb b/spec/mailers/shipment_mailer_spec.rb index 756fdba189..8710f392e0 100644 --- a/spec/mailers/shipment_mailer_spec.rb +++ b/spec/mailers/shipment_mailer_spec.rb @@ -6,10 +6,10 @@ describe Spree::ShipmentMailer do let(:shipment) do order = build(:order_with_distributor) product = build(:product, name: %{The "BEST" product}) - variant = build(:variant, product: product) - line_item = build(:line_item, variant: variant, order: order, quantity: 1, price: 5) + variant = build(:variant, product:) + line_item = build(:line_item, variant:, order:, quantity: 1, price: 5) shipment = build(:shipment) - allow(shipment).to receive_messages(line_items: [line_item], order: order) + allow(shipment).to receive_messages(line_items: [line_item], order:) allow(shipment).to receive_messages(tracking_url: "TRACK_ME") shipment end diff --git a/spec/mailers/subscription_mailer_spec.rb b/spec/mailers/subscription_mailer_spec.rb index 967bececec..f7d44d31f5 100644 --- a/spec/mailers/subscription_mailer_spec.rb +++ b/spec/mailers/subscription_mailer_spec.rb @@ -11,8 +11,8 @@ describe SubscriptionMailer, type: :mailer do let(:shop) { create(:enterprise) } let(:customer) { create(:customer, enterprise: shop) } - let(:subscription) { create(:subscription, shop: shop, customer: customer, with_items: true) } - let(:proxy_order) { create(:proxy_order, subscription: subscription) } + let(:subscription) { create(:subscription, shop:, customer:, with_items: true) } + let(:proxy_order) { create(:proxy_order, subscription:) } let!(:order) { proxy_order.initialise_order! } context "when changes have been made to the order" do @@ -109,8 +109,8 @@ describe SubscriptionMailer, type: :mailer do subject(:email) { SubscriptionMailer.confirmation_email(order) } let(:customer) { create(:customer) } - let(:subscription) { create(:subscription, customer: customer, with_items: true) } - let(:proxy_order) { create(:proxy_order, subscription: subscription) } + let(:subscription) { create(:subscription, customer:, with_items: true) } + let(:proxy_order) { create(:proxy_order, subscription:) } let!(:order) { proxy_order.initialise_order! } let(:user) { order.user } @@ -174,7 +174,7 @@ describe SubscriptionMailer, type: :mailer do describe "empty order notification" do let(:subscription) { create(:subscription, with_items: true) } - let(:proxy_order) { create(:proxy_order, subscription: subscription) } + let(:proxy_order) { create(:proxy_order, subscription:) } let!(:order) { proxy_order.initialise_order! } before do @@ -192,8 +192,8 @@ describe SubscriptionMailer, type: :mailer do describe "failed payment notification" do let(:customer) { create(:customer) } - let(:subscription) { create(:subscription, customer: customer, with_items: true) } - let(:proxy_order) { create(:proxy_order, subscription: subscription) } + let(:subscription) { create(:subscription, customer:, with_items: true) } + let(:proxy_order) { create(:proxy_order, subscription:) } let!(:order) { proxy_order.initialise_order! } before do diff --git a/spec/migrations/migrate_admin_tax_amounts_spec.rb b/spec/migrations/migrate_admin_tax_amounts_spec.rb index af5df9c110..189bf8fca3 100644 --- a/spec/migrations/migrate_admin_tax_amounts_spec.rb +++ b/spec/migrations/migrate_admin_tax_amounts_spec.rb @@ -78,8 +78,8 @@ describe MigrateAdminTaxAmounts do describe "#applicabe_rates" do let(:distributor) { create(:enterprise) } - let(:order) { create(:order, distributor: distributor) } - let!(:adjustment) { create(:adjustment, order: order) } + let(:order) { create(:order, distributor:) } + let!(:adjustment) { create(:adjustment, order:) } context "when the order is nil" do let(:order) { nil } diff --git a/spec/models/calculator/flat_percent_item_total_spec.rb b/spec/models/calculator/flat_percent_item_total_spec.rb index a0c57c6266..3305c7791a 100644 --- a/spec/models/calculator/flat_percent_item_total_spec.rb +++ b/spec/models/calculator/flat_percent_item_total_spec.rb @@ -16,7 +16,7 @@ describe Calculator::FlatPercentItemTotal do it "computes amount correctly for a given OrderManagement::Stock::Package" do order = double(:order, line_items: [line_item] ) - package = double(:package, order: order) + package = double(:package, order:) expect(calculator.compute(package)).to eq(1.0) end diff --git a/spec/models/calculator/flexi_rate_spec.rb b/spec/models/calculator/flexi_rate_spec.rb index e5a777a412..6f33270b43 100644 --- a/spec/models/calculator/flexi_rate_spec.rb +++ b/spec/models/calculator/flexi_rate_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Calculator::FlexiRate do - let(:line_item) { build_stubbed(:line_item, quantity: quantity) } + let(:line_item) { build_stubbed(:line_item, quantity:) } let(:calculator) do Calculator::FlexiRate.new( preferred_first_item: 2, diff --git a/spec/models/calculator/price_sack_spec.rb b/spec/models/calculator/price_sack_spec.rb index 771b8428ec..afab174fe5 100644 --- a/spec/models/calculator/price_sack_spec.rb +++ b/spec/models/calculator/price_sack_spec.rb @@ -10,7 +10,7 @@ describe Calculator::PriceSack do calculator.preferred_discount_amount = 1 calculator end - let(:line_item) { build_stubbed(:line_item, price: price, quantity: 2) } + let(:line_item) { build_stubbed(:line_item, price:, quantity: 2) } it { is_expected.to validate_numericality_of(:preferred_minimal_amount) } it { is_expected.to validate_numericality_of(:preferred_normal_amount) }