diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index 25bf52056f..d2045aa9f1 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -290,8 +290,8 @@ describe Admin::EnterprisesController, type: :controller do describe "vouchers" do let(:enterprise) { create(:distributor_enterprise) } - let!(:voucher_a) { create(:voucher, enterprise: enterprise, code: "voucher 1") } - let(:voucher_b) { create(:voucher, enterprise: enterprise, code: "voucher 2") } + let!(:voucher_a) { create(:voucher, enterprise:, code: "voucher 1") } + let(:voucher_b) { create(:voucher, enterprise:, code: "voucher 2") } before do controller_login_as_enterprise_user [enterprise] @@ -333,7 +333,7 @@ describe Admin::EnterprisesController, type: :controller do context "when activating and deactivating voucher at the same time" do it "deactivates and activates accordingly" do voucher_b - voucher_c = create(:voucher, enterprise: enterprise, code: "voucher 3") + voucher_c = create(:voucher, enterprise:, code: "voucher 3") voucher_c.destroy spree_put :update, diff --git a/spec/models/calculator/weight_spec.rb b/spec/models/calculator/weight_spec.rb index 7e02739801..915562c7b1 100644 --- a/spec/models/calculator/weight_spec.rb +++ b/spec/models/calculator/weight_spec.rb @@ -21,7 +21,7 @@ describe Calculator::Weight do describe "line item with variant_unit weight and variant unit_value" do let(:variant) { build_stubbed(:variant, unit_value: 10_000) } - let(:line_item) { build_stubbed(:line_item, variant: variant, quantity: 2) } + let(:line_item) { build_stubbed(:line_item, variant:, quantity: 2) } before { subject.set_preference(:per_unit, 5) @@ -59,7 +59,7 @@ describe Calculator::Weight do line_item2 = build_stubbed(:line_item, variant: variant2, quantity: 2) order = double(:order, line_items: [line_item1, line_item2]) - object_with_order = double(:object_with_order, order: order) + object_with_order = double(:object_with_order, order:) subject.set_preference(:per_unit, 5) subject.set_preference(:unit_from_list, "kg") @@ -70,11 +70,11 @@ describe Calculator::Weight do context "when line item final_weight_volume is set" do let!(:product) { build_stubbed(:product, product_attributes) } - let!(:variant) { build_stubbed(:variant, variant_attributes.merge(product: product)) } + let!(:variant) { build_stubbed(:variant, variant_attributes.merge(product:)) } let(:calculator) { described_class.new(preferred_per_unit: 6, preferred_unit_from_list: "kg") } let(:line_item) do - build_stubbed(:line_item, variant: variant, quantity: 2).tap do |object| + build_stubbed(:line_item, variant:, quantity: 2).tap do |object| object.send(:calculate_final_weight_volume) end end @@ -191,7 +191,7 @@ describe Calculator::Weight do build_stubbed(:product, variant_unit: 'items', variant_unit_scale: nil, variant_unit_name: "bunch") } - let(:line_item) { build_stubbed(:line_item, variant: variant, quantity: 1) } + let(:line_item) { build_stubbed(:line_item, variant:, quantity: 1) } before { subject.set_preference(:per_unit, 5) @@ -199,7 +199,7 @@ describe Calculator::Weight do } context "when unit_value is zero variant.weight is present" do - let(:variant) { build_stubbed(:variant, product: product, unit_value: 0, weight: 10.0) } + let(:variant) { build_stubbed(:variant, product:, unit_value: 0, weight: 10.0) } it "uses the variant weight" do expect(subject.compute(line_item)).to eq 50.0 @@ -207,7 +207,7 @@ describe Calculator::Weight do end context "when unit_value is zero variant.weight is nil" do - let(:variant) { build_stubbed(:variant, product: product, unit_value: 0, weight: nil) } + let(:variant) { build_stubbed(:variant, product:, unit_value: 0, weight: nil) } it "uses zero weight" do expect(subject.compute(line_item)).to eq 0 @@ -216,7 +216,7 @@ describe Calculator::Weight do context "when unit_value is nil and variant.weight is present" do let(:variant) { - build_stubbed(:variant, product: product, unit_description: "bunches", unit_value: nil, + build_stubbed(:variant, product:, unit_description: "bunches", unit_value: nil, weight: 10.0) } @@ -229,7 +229,7 @@ describe Calculator::Weight do context "when unit_value is nil and variant.weight is nil" do let(:variant) { - build_stubbed(:variant, product: product, unit_description: "bunches", unit_value: nil, + build_stubbed(:variant, product:, unit_description: "bunches", unit_value: nil, weight: nil) } diff --git a/spec/models/column_preference_spec.rb b/spec/models/column_preference_spec.rb index cfb51edb3d..9a7e76a70a 100644 --- a/spec/models/column_preference_spec.rb +++ b/spec/models/column_preference_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe ColumnPreference, type: :model do subject { ColumnPreference.new( - user: user, action_name: :customers_index, column_name: :email + user:, action_name: :customers_index, column_name: :email ) } let(:user) { build(:user) } @@ -19,11 +19,11 @@ describe ColumnPreference, type: :model do end let!(:col1_pref) { - ColumnPreference.create(user: user, action_name: 'some_action', column_name: 'col1', + ColumnPreference.create(user:, action_name: 'some_action', column_name: 'col1', visible: true) } let!(:col2_pref) { - ColumnPreference.create(user: user, action_name: 'some_action', column_name: 'col2', + ColumnPreference.create(user:, action_name: 'some_action', column_name: 'col2', visible: false) } let(:defaults) { diff --git a/spec/models/concerns/calculated_adjustments_spec.rb b/spec/models/concerns/calculated_adjustments_spec.rb index 0c54d9be02..3020088b0f 100644 --- a/spec/models/concerns/calculated_adjustments_spec.rb +++ b/spec/models/concerns/calculated_adjustments_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' # So we'll just test it using Order and ShippingMethod. These classes are including the module. describe CalculatedAdjustments do let(:calculator) { build(:calculator) } - let(:tax_rate) { Spree::TaxRate.new(calculator: calculator) } + let(:tax_rate) { Spree::TaxRate.new(calculator:) } before do allow(calculator).to receive(:compute) { 10 } diff --git a/spec/models/concerns/order_shipment_spec.rb b/spec/models/concerns/order_shipment_spec.rb index c69e54b4a0..9bf8f8678f 100644 --- a/spec/models/concerns/order_shipment_spec.rb +++ b/spec/models/concerns/order_shipment_spec.rb @@ -15,7 +15,7 @@ describe OrderShipment do context "when order has single shipment" do it "returns the shipments shipping_method" do shipping_method = create(:shipping_method_with, :flat_rate) - shipment = create(:shipment_with, :shipping_method, shipping_method: shipping_method) + shipment = create(:shipment_with, :shipping_method, shipping_method:) order.shipments = [shipment] expect(order.shipping_method).to eq shipment.shipping_method @@ -33,7 +33,7 @@ describe OrderShipment do end context "when order has a shipment" do - let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) } + let(:shipment) { create(:shipment_with, :shipping_method, shipping_method:) } before { order.shipments = [shipment] } context "when no shipping_method_id is provided" do diff --git a/spec/models/concerns/product_stock_spec.rb b/spec/models/concerns/product_stock_spec.rb index c8ce00dc28..0024035f91 100644 --- a/spec/models/concerns/product_stock_spec.rb +++ b/spec/models/concerns/product_stock_spec.rb @@ -21,7 +21,7 @@ describe ProductStock do context 'when product has more than one variant' do before do - product.variants << create(:variant, product: product) + product.variants << create(:variant, product:) end describe "product.on_demand" do diff --git a/spec/models/customer_spec.rb b/spec/models/customer_spec.rb index f6c3018ee7..a9441b8393 100644 --- a/spec/models/customer_spec.rb +++ b/spec/models/customer_spec.rb @@ -53,24 +53,24 @@ describe Customer, type: :model do let!(:enterprise) { create(:distributor_enterprise) } it "associates no user using non-existing email" do - c = Customer.create(enterprise: enterprise, + c = Customer.create(enterprise:, email: 'some-email-not-associated-with-a-user@email.com') expect(c.user).to be_nil end it "associates an existing user using email" do non_existing_email = 'some-email-not-associated-with-a-user@email.com' - c1 = Customer.create(enterprise: enterprise, email: non_existing_email, user: user1) + c1 = Customer.create(enterprise:, email: non_existing_email, user: user1) expect(c1.user).to eq user1 expect(c1.email).to eq non_existing_email expect(c1.email).to_not eq user1.email - c2 = Customer.create(enterprise: enterprise, email: user2.email) + c2 = Customer.create(enterprise:, email: user2.email) expect(c2.user).to eq user2 end it "associates an existing user using email case-insensitive" do - c = Customer.create(enterprise: enterprise, email: user2.email.upcase) + c = Customer.create(enterprise:, email: user2.email.upcase) expect(c.user).to eq user2 end end @@ -79,8 +79,8 @@ describe Customer, type: :model do context 'managed_by' do let!(:user) { create(:user) } let!(:enterprise) { create(:enterprise, owner: user) } - let!(:customer) { create(:customer, enterprise: enterprise, user: user) } - let!(:customer1) { create(:customer, enterprise: enterprise) } + let!(:customer) { create(:customer, enterprise:, user:) } + let!(:customer1) { create(:customer, enterprise:) } let!(:user1) { create(:user) } let!(:enterprise1) { create(:enterprise, owner: user1) } @@ -103,7 +103,7 @@ describe Customer, type: :model do it 'returns customers of managed enterprises' do user2 = create(:user) - EnterpriseRole.create!(user: user2, enterprise: enterprise) + EnterpriseRole.create!(user: user2, enterprise:) expect(Customer.managed_by(user2)).to match_array [customer, customer1] end @@ -124,7 +124,7 @@ describe Customer, type: :model do let!(:customer4) { create(:customer) } let!(:customer5) { create(:customer, created_manually: true) } - let!(:order_ready_for_details) { create(:order_ready_for_details, customer: customer) } + let!(:order_ready_for_details) { create(:order_ready_for_details, customer:) } let!(:order_ready_for_payment) { create(:order_ready_for_payment, customer: customer2) } let!(:order_ready_for_confirmation) { create(:order_ready_for_confirmation, customer: customer3) diff --git a/spec/models/enterprise_fee_spec.rb b/spec/models/enterprise_fee_spec.rb index 892669e2ec..1bfcda4b9f 100644 --- a/spec/models/enterprise_fee_spec.rb +++ b/spec/models/enterprise_fee_spec.rb @@ -145,9 +145,9 @@ describe EnterpriseFee do describe "clearing all enterprise fee adjustments on an order" do it "clears adjustments from many fees and on all line items" do order_cycle = create(:order_cycle) - order = create(:order, order_cycle: order_cycle) - line_item1 = create(:line_item, order: order, variant: order_cycle.variants.first) - line_item2 = create(:line_item, order: order, variant: order_cycle.variants.second) + order = create(:order, order_cycle:) + line_item1 = create(:line_item, order:, variant: order_cycle.variants.first) + line_item2 = create(:line_item, order:, variant: order_cycle.variants.second) order_cycle.coordinator_fees[0].create_adjustment('foo1', line_item1.order, true) order_cycle.coordinator_fees[0].create_adjustment('foo2', line_item2.order, true) @@ -187,7 +187,7 @@ describe EnterpriseFee do describe "soft-deletion" do let(:tax_category) { create(:tax_category) } - let(:enterprise_fee) { create(:enterprise_fee, tax_category: tax_category ) } + let(:enterprise_fee) { create(:enterprise_fee, tax_category: ) } let!(:adjustment) { create(:adjustment, originator: enterprise_fee) } before do diff --git a/spec/models/enterprise_relationship_spec.rb b/spec/models/enterprise_relationship_spec.rb index 644c051062..bbad680132 100644 --- a/spec/models/enterprise_relationship_spec.rb +++ b/spec/models/enterprise_relationship_spec.rb @@ -164,7 +164,7 @@ describe EnterpriseRelationship do :create_variant_overrides] ) } let!(:vo1) { - create(:variant_override, hub: hub, + create(:variant_override, hub:, variant: create( :variant, product: create( @@ -173,7 +173,7 @@ describe EnterpriseRelationship do )) } let!(:vo2) { - create(:variant_override, hub: hub, + create(:variant_override, hub:, variant: create( :variant, product: create( @@ -182,7 +182,7 @@ describe EnterpriseRelationship do )) } let!(:vo3) { - create(:variant_override, hub: hub, + create(:variant_override, hub:, variant: create( :variant, product: create( @@ -237,7 +237,7 @@ describe EnterpriseRelationship do permissions_list: [:add_to_order_cycles] ) } let!(:vo1) { - create(:variant_override, hub: hub, + create(:variant_override, hub:, variant: create( :variant, product: create( @@ -247,7 +247,7 @@ describe EnterpriseRelationship do permission_revoked_at: Time.now.in_time_zone) } let!(:vo2) { - create(:variant_override, hub: hub, + create(:variant_override, hub:, variant: create( :variant, product: create( @@ -257,7 +257,7 @@ describe EnterpriseRelationship do permission_revoked_at: Time.now.in_time_zone) } let!(:vo3) { - create(:variant_override, hub: hub, + create(:variant_override, hub:, variant: create( :variant, product: create( @@ -322,7 +322,7 @@ describe EnterpriseRelationship do let!(:some_other_variant) { create(:variant) } let!(:incoming_external_variant) { incoming_external_exchange.exchange_variants.create!( - exchange: incoming_external_exchange, variant: variant + exchange: incoming_external_exchange, variant: ) } let!(:incoming_internal_only_variant) { @@ -332,7 +332,7 @@ describe EnterpriseRelationship do } let!(:outgoing_internal_variant) { outgoing_internal_exchange.exchange_variants.create!( - exchange: outgoing_internal_exchange, variant: variant + exchange: outgoing_internal_exchange, variant: ) } let!(:outgoing_internal_only_variant) { diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 78d7fc9912..f8a8937701 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -128,7 +128,7 @@ describe Enterprise do describe "name uniqueness" do let(:owner) { create(:user, email: 'owner@example.com') } - let!(:enterprise) { create(:enterprise, name: 'Enterprise', owner: owner) } + let!(:enterprise) { create(:enterprise, name: 'Enterprise', owner:) } it "prevents duplicate names for new records" do e = Enterprise.new name: enterprise.name @@ -552,7 +552,7 @@ describe Enterprise do user.spree_roles = [] e1 = create(:enterprise) e2 = create(:enterprise) - e1.enterprise_roles.build(user: user).save + e1.enterprise_roles.build(user:).save enterprises = Enterprise.managed_by user expect(enterprises.count).to eq(1) @@ -575,11 +575,11 @@ describe Enterprise do describe "callbacks" do describe "after creation" do let(:owner) { create(:user, enterprise_limit: 10) } - let(:hub1) { create(:distributor_enterprise, owner: owner) } - let(:hub2) { create(:distributor_enterprise, owner: owner) } - let(:hub3) { create(:distributor_enterprise, owner: owner) } - let(:producer1) { create(:supplier_enterprise, owner: owner) } - let(:producer2) { create(:supplier_enterprise, owner: owner) } + let(:hub1) { create(:distributor_enterprise, owner:) } + let(:hub2) { create(:distributor_enterprise, owner:) } + let(:hub3) { create(:distributor_enterprise, owner:) } + let(:producer1) { create(:supplier_enterprise, owner:) } + let(:producer2) { create(:supplier_enterprise, owner:) } describe "when a producer is created" do before do diff --git a/spec/models/exchange_spec.rb b/spec/models/exchange_spec.rb index 62b7af1693..86f8ad36f4 100644 --- a/spec/models/exchange_spec.rb +++ b/spec/models/exchange_spec.rb @@ -55,7 +55,7 @@ describe Exchange do let(:supplier) { create(:supplier_enterprise) } let(:coordinator) { create(:distributor_enterprise) } let(:distributor) { create(:distributor_enterprise) } - let(:oc) { create(:simple_order_cycle, coordinator: coordinator) } + let(:oc) { create(:simple_order_cycle, coordinator:) } let(:incoming_exchange) { oc.exchanges.create! sender: supplier, receiver: coordinator, incoming: true } @@ -102,7 +102,7 @@ describe Exchange do let(:supplier) { create(:supplier_enterprise) } let(:coordinator) { create(:distributor_enterprise, is_primary_producer: true) } let(:distributor) { create(:distributor_enterprise) } - let(:oc) { create(:simple_order_cycle, coordinator: coordinator) } + let(:oc) { create(:simple_order_cycle, coordinator:) } describe "finding exchanges managed by a particular user" do let(:user) do diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index eae8291131..9ee874dce5 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -434,21 +434,21 @@ describe OrderCycle do let(:user) { create(:user) } let(:oc) { create(:order_cycle) } let!(:order) { - create(:completed_order_with_totals, distributor: shop, user: user, order_cycle: oc) + create(:completed_order_with_totals, distributor: shop, user:, order_cycle: oc) } let!(:order_from_other_hub) { - create(:completed_order_with_totals, distributor: create(:enterprise), user: user, + create(:completed_order_with_totals, distributor: create(:enterprise), user:, order_cycle: oc) } let!(:order_from_other_user) { create(:completed_order_with_totals, distributor: shop, user: create(:user), order_cycle: oc) } let!(:order_from_other_oc) { - create(:completed_order_with_totals, distributor: shop, user: user, + create(:completed_order_with_totals, distributor: shop, user:, order_cycle: create(:order_cycle)) } let!(:order_cancelled) { - create(:completed_order_with_totals, distributor: shop, user: user, order_cycle: oc) + create(:completed_order_with_totals, distributor: shop, user:, order_cycle: oc) } before { order_cancelled.cancel } @@ -520,7 +520,7 @@ describe OrderCycle do create(:simple_order_cycle, orders_open_at: 1.week.ago, orders_close_at: 1.day.ago) } let(:schedule) { create(:schedule, order_cycles: [oc]) } - let!(:subscription) { create(:subscription, schedule: schedule, with_items: true) } + let!(:subscription) { create(:subscription, schedule:, with_items: true) } it "syncs subscriptions when transitioning from closed to open" do expect(OrderManagement::Subscriptions::ProxyOrderSyncer).to receive(:new).and_call_original diff --git a/spec/models/product_import/entry_validator_spec.rb b/spec/models/product_import/entry_validator_spec.rb index 5469c47364..4648298545 100644 --- a/spec/models/product_import/entry_validator_spec.rb +++ b/spec/models/product_import/entry_validator_spec.rb @@ -33,7 +33,7 @@ describe ProductImport::EntryValidator do units: "500", unit_type: "g", name: 'Tomato', - enterprise: enterprise, + enterprise:, enterprise_id: enterprise.id, producer: enterprise, producer_id: enterprise.id, @@ -49,7 +49,7 @@ describe ProductImport::EntryValidator do units: "1", unit_type: "kg", name: 'Potatoes', - enterprise: enterprise, + enterprise:, enterprise_id: enterprise.id, producer: enterprise, producer_id: enterprise.id, @@ -80,7 +80,7 @@ describe ProductImport::EntryValidator do variant_unit_name: "", name: potatoes.name, display_name: 'Potatoes', - enterprise: enterprise, + enterprise:, enterprise_id: enterprise.id, producer: enterprise, producer_id: enterprise.id, diff --git a/spec/models/product_import/inventory_reset_strategy_spec.rb b/spec/models/product_import/inventory_reset_strategy_spec.rb index 09f03a2a03..3eed624486 100644 --- a/spec/models/product_import/inventory_reset_strategy_spec.rb +++ b/spec/models/product_import/inventory_reset_strategy_spec.rb @@ -14,7 +14,7 @@ describe ProductImport::InventoryResetStrategy do :variant_override, count_on_hand: 10, hub: enterprise, - variant: variant + variant: ) end let(:excluded_items_ids) { [variant_override.id] } @@ -55,7 +55,7 @@ describe ProductImport::InventoryResetStrategy do :variant_override, count_on_hand: 10, hub: enterprise, - variant: variant + variant: ) end let!(:variant_override_on_demand) do @@ -64,7 +64,7 @@ describe ProductImport::InventoryResetStrategy do count_on_hand: nil, on_demand: true, hub: enterprise, - variant: variant + variant: ) end let(:excluded_items_ids) do @@ -82,14 +82,14 @@ describe ProductImport::InventoryResetStrategy do :variant_override, count_on_hand: 3, hub: enterprise, - variant: variant + variant: ) non_excluded_variant_override_on_demand = create( :variant_override, count_on_hand: nil, on_demand: true, hub: enterprise, - variant: variant + variant: ) inventory_reset.reset(supplier_ids) expect(non_excluded_variant_override_with_count_on_hand.reload.count_on_hand).to eq(0) @@ -140,7 +140,7 @@ describe ProductImport::InventoryResetStrategy do :variant_override, count_on_hand: 10, hub: enterprise, - variant: variant + variant: ) end @@ -157,7 +157,7 @@ describe ProductImport::InventoryResetStrategy do count_on_hand: nil, on_demand: true, hub: enterprise, - variant: variant + variant: ) end @@ -211,7 +211,7 @@ describe ProductImport::InventoryResetStrategy do :variant_override, count_on_hand: 10, hub: enterprise, - variant: variant + variant: ) end @@ -228,7 +228,7 @@ describe ProductImport::InventoryResetStrategy do count_on_hand: nil, on_demand: true, hub: enterprise, - variant: variant + variant: ) end diff --git a/spec/models/product_importer_spec.rb b/spec/models/product_importer_spec.rb index 3c05ffaef0..d63249428e 100644 --- a/spec/models/product_importer_spec.rb +++ b/spec/models/product_importer_spec.rb @@ -934,7 +934,7 @@ describe ProductImport::ProductImporter do updated_ids = importer.updated_ids - importer = import_data csv_data, reset_all_absent: true, updated_ids: updated_ids, + importer = import_data csv_data, reset_all_absent: true, updated_ids:, enterprises_to_reset: [enterprise.id] importer.reset_absent(updated_ids) @@ -973,7 +973,7 @@ describe ProductImport::ProductImporter do updated_ids = importer.updated_ids importer = import_data csv_data, import_into: 'inventories', reset_all_absent: true, - updated_ids: updated_ids, + updated_ids:, enterprises_to_reset: [enterprise2.id] importer.reset_absent(updated_ids) @@ -1013,9 +1013,9 @@ def import_data(csv_data, args = {}) import_user, start: start_row, end: end_row, - updated_ids: updated_ids, - enterprises_to_reset: enterprises_to_reset, - settings: settings) + updated_ids:, + enterprises_to_reset:, + settings:) end def filter(type, entries) diff --git a/spec/models/proxy_order_spec.rb b/spec/models/proxy_order_spec.rb index 17078eb5d2..c6ec6bd628 100644 --- a/spec/models/proxy_order_spec.rb +++ b/spec/models/proxy_order_spec.rb @@ -14,7 +14,7 @@ describe ProxyOrder, type: :model do context "when the order cycle is not yet closed" do let(:proxy_order) { - create(:proxy_order, subscription: subscription, order: order, order_cycle: order_cycle) + create(:proxy_order, subscription:, order:, order_cycle:) } before { order_cycle.update(orders_open_at: 1.day.ago, orders_close_at: 3.days.from_now) } @@ -56,7 +56,7 @@ describe ProxyOrder, type: :model do context "when the order cycle is already closed" do let(:proxy_order) { - create(:proxy_order, subscription: subscription, order: order, order_cycle: order_cycle) + create(:proxy_order, subscription:, order:, order_cycle:) } before { order_cycle.update(orders_open_at: 3.days.ago, orders_close_at: 1.minute.ago) } @@ -91,7 +91,7 @@ describe ProxyOrder, type: :model do payments: [create(:payment)], distributor: shipment.shipping_method.distributors.first) } - let(:proxy_order) { create(:proxy_order, order: order, canceled_at: Time.zone.now) } + let(:proxy_order) { create(:proxy_order, order:, canceled_at: Time.zone.now) } let(:order_cycle) { proxy_order.order_cycle } around do |example| diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 9cb1af5a20..1ceb168452 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -327,7 +327,7 @@ describe Spree::Ability do let(:user) do user = create(:user) user.spree_roles = [] - s1.enterprise_roles.build(user: user).save + s1.enterprise_roles.build(user:).save user end @@ -470,7 +470,7 @@ describe Spree::Ability do context "where the enterprise is in an order_cycle" do let!(:order_cycle) { create(:simple_order_cycle) } let!(:exchange){ - create(:exchange, incoming: true, order_cycle: order_cycle, + create(:exchange, incoming: true, order_cycle:, receiver: order_cycle.coordinator, sender: s1) } @@ -497,7 +497,7 @@ describe Spree::Ability do let(:user) do user = create(:user) user.spree_roles = [] - d1.enterprise_roles.build(user: user).save + d1.enterprise_roles.build(user:).save user end # create order for each enterprise @@ -683,7 +683,7 @@ describe Spree::Ability do context "for a given order_cycle" do let!(:order_cycle) { create(:simple_order_cycle, coordinator: d2) } let!(:exchange){ - create(:exchange, incoming: false, order_cycle: order_cycle, receiver: d1, + create(:exchange, incoming: false, order_cycle:, receiver: d1, sender: order_cycle.coordinator) } @@ -709,7 +709,7 @@ describe Spree::Ability do let(:user) do user = create(:user) user.spree_roles = [] - d1.enterprise_roles.build(user: user).save + d1.enterprise_roles.build(user:).save user end @@ -748,7 +748,7 @@ describe Spree::Ability do let(:user) do user = create(:user) user.spree_roles = [] - s1.enterprise_roles.build(user: user).save + s1.enterprise_roles.build(user:).save user end @@ -799,8 +799,8 @@ describe Spree::Ability do let!(:distributor) { create(:distributor_enterprise) } let!(:producer) { create(:supplier_enterprise) } let!(:product) { create(:product, supplier: producer) } - let!(:variant) { create(:variant, product: product) } - let!(:variant_override) { create(:variant_override, hub: distributor, variant: variant) } + let!(:variant) { create(:variant, product:) } + let!(:variant_override) { create(:variant_override, hub: distributor, variant:) } subject { user } diff --git a/spec/models/spree/address_spec.rb b/spec/models/spree/address_spec.rb index 84276a0adc..66e07f5983 100644 --- a/spec/models/spree/address_spec.rb +++ b/spec/models/spree/address_spec.rb @@ -65,7 +65,7 @@ describe Spree::Address do let(:state) { build_stubbed(:state, name: 'maryland', abbr: 'md') } let(:country) { state.country } - let(:address) { build_stubbed(:address, country: country, state: state) } + let(:address) { build_stubbed(:address, country:, state:) } before do country.states_required = true @@ -178,13 +178,13 @@ describe Spree::Address do context '#state_text' do context 'both name and abbr is present' do let(:state) { build(:state, name: 'virginia', abbr: 'va') } - let(:address) { build(:address, state: state) } + let(:address) { build(:address, state:) } specify { expect(address.state_text).to eq 'va' } end context 'only name is present' do let(:state) { build(:state, name: 'virginia', abbr: nil) } - let(:address) { build(:address, state: state) } + let(:address) { build(:address, state:) } specify { expect(address.state_text).to eq 'virginia' } end end diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index f8e0388c67..c85b61360e 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -34,8 +34,8 @@ module Spree let(:adjustable) { instance_double(LineItem) } before do - allow(adjustment).to receive_messages originator: originator, label: 'adjustment', - adjustable: adjustable, amount: 0 + allow(adjustment).to receive_messages originator:, label: 'adjustment', + adjustable:, amount: 0 end it "should do nothing when closed" do @@ -180,7 +180,7 @@ module Spree describe "TaxRate adjustments" do let!(:zone) { create(:zone_with_member) } let!(:order) { create(:order, bill_address: create(:address)) } - let!(:line_item) { create(:line_item, order: order) } + let!(:line_item) { create(:line_item, order:) } let(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) } let(:tax_rate) { create(:tax_rate, included_in_price: true, amount: 0.10) } let(:adjustment) { line_item.adjustments.reload.first } @@ -220,18 +220,18 @@ module Spree let(:zone) { create(:zone_with_member) } let(:inclusive_tax) { true } let(:tax_rate) { - create(:tax_rate, included_in_price: inclusive_tax, zone: zone, amount: 0.25) + create(:tax_rate, included_in_price: inclusive_tax, zone:, amount: 0.25) } let(:tax_category) { create(:tax_category, name: "Shipping", tax_rates: [tax_rate] ) } let(:hub) { create(:distributor_enterprise, charges_sales_tax: true) } let(:order) { create(:order, distributor: hub, state: 'payment') } - let(:line_item) { create(:line_item, order: order) } + let(:line_item) { create(:line_item, order:) } let(:shipping_method) { - create(:shipping_method_with, :flat_rate, tax_category: tax_category) + create(:shipping_method_with, :flat_rate, tax_category:) } let(:shipment) { - create(:shipment_with, :shipping_method, shipping_method: shipping_method, order: order) + create(:shipment_with, :shipping_method, shipping_method:, order:) } describe "the shipping charge" do @@ -337,19 +337,19 @@ module Spree let(:zone) { create(:zone_with_member) } let(:fee_tax_rate) { create(:tax_rate, included_in_price: true, calculator: ::Calculator::DefaultTax.new, - zone: zone, amount: 0.1) + zone:, amount: 0.1) } let(:fee_tax_category) { create(:tax_category, tax_rates: [fee_tax_rate]) } let(:coordinator) { create(:distributor_enterprise, charges_sales_tax: true) } let(:variant) { create(:variant, product: create(:product, tax_category: nil)) } let(:order_cycle) { - create(:simple_order_cycle, coordinator: coordinator, coordinator_fees: [enterprise_fee], + create(:simple_order_cycle, coordinator:, coordinator_fees: [enterprise_fee], distributors: [coordinator], variants: [variant]) } - let(:line_item) { create(:line_item, variant: variant) } + let(:line_item) { create(:line_item, variant:) } let(:order) { - create(:order, line_items: [line_item], order_cycle: order_cycle, + create(:order, line_items: [line_item], order_cycle:, distributor: coordinator, state: 'payment') } let(:fee) { order.all_adjustments.reload.enterprise_fee.first } @@ -430,7 +430,7 @@ module Spree context "when enterprise fees inherit tax_category from the product they are applied to" do let(:product_tax_rate) { create(:tax_rate, included_in_price: true, calculator: ::Calculator::DefaultTax.new, - zone: zone, amount: 0.2) + zone:, amount: 0.2) } let(:product_tax_category) { create(:tax_category, tax_rates: [product_tax_rate]) } @@ -525,20 +525,20 @@ module Spree let!(:zone) { create(:zone_with_member) } let!(:tax_category) { create(:tax_category, name: "Tax Test") } let(:distributor) { create(:distributor_enterprise, charges_sales_tax: true) } - let(:order) { create(:order, distributor: distributor, state: "payment") } + let(:order) { create(:order, distributor:, state: "payment") } let(:included_in_price) { true } let(:tax_rate) { - create(:tax_rate, included_in_price: included_in_price, zone: zone, + create(:tax_rate, included_in_price:, zone:, calculator: ::Calculator::FlatRate.new(preferred_amount: 0.1)) } - let(:variant) { create(:variant, tax_category: tax_category) } + let(:variant) { create(:variant, tax_category:) } let(:product) { variant.product } describe "tax adjustment creation" do before do tax_category.tax_rates << tax_rate allow(order).to receive(:tax_zone) { zone } - order.line_items << create(:line_item, variant: variant, quantity: 5) + order.line_items << create(:line_item, variant:, quantity: 5) order.update(state: "payment") order.create_tax_charge! end @@ -563,7 +563,7 @@ module Spree describe "inclusive and additional scopes" do let(:included) { true } let(:adjustment) { - create(:adjustment, adjustable: order, originator: tax_rate, included: included) + create(:adjustment, adjustable: order, originator: tax_rate, included:) } context "when tax is included in price" do @@ -586,7 +586,7 @@ module Spree let!(:return_authorization) { create(:return_authorization, amount: 123) } let(:order) { return_authorization.order } let!(:return_adjustment) { - create(:adjustment, originator: return_authorization, order: order, + create(:adjustment, originator: return_authorization, order:, adjustable: order, amount: 456) } diff --git a/spec/models/spree/calculator_spec.rb b/spec/models/spree/calculator_spec.rb index 27ca7a3018..a2e8daf912 100644 --- a/spec/models/spree/calculator_spec.rb +++ b/spec/models/spree/calculator_spec.rb @@ -8,8 +8,8 @@ module Spree let!(:enterprise) { create(:enterprise) } let!(:order) { create(:order) } let!(:shipment) { create(:shipment) } - let!(:line_item) { create(:line_item, order: order) } - let!(:line_item2) { create(:line_item, order: order) } + let!(:line_item) { create(:line_item, order:) } + let!(:line_item2) { create(:line_item, order:) } before do order.reload.shipments = [shipment] diff --git a/spec/models/spree/credit_card_spec.rb b/spec/models/spree/credit_card_spec.rb index 23f40b3489..3ef4c951ca 100644 --- a/spec/models/spree/credit_card_spec.rb +++ b/spec/models/spree/credit_card_spec.rb @@ -218,11 +218,11 @@ module Spree describe "setting default credit card for a user" do let(:user) { create(:user) } let(:onetime_card_attrs) do - { user: user, gateway_payment_profile_id: "tok_1EY..." } + { user:, gateway_payment_profile_id: "tok_1EY..." } end let(:stored_card_attrs) do { - user: user, + user:, gateway_customer_profile_id: "cus_F2T...", gateway_payment_profile_id: "card_1EY..." } @@ -255,7 +255,7 @@ module Spree end context "and I update another card" do - let!(:card2) { create(:credit_card, user: user) } + let!(:card2) { create(:credit_card, user:) } context "without specifying it as the default" do it "keeps the existing default" do diff --git a/spec/models/spree/gateway/stripe_sca_spec.rb b/spec/models/spree/gateway/stripe_sca_spec.rb index e9c7042233..7f1661f4e2 100644 --- a/spec/models/spree/gateway/stripe_sca_spec.rb +++ b/spec/models/spree/gateway/stripe_sca_spec.rb @@ -11,7 +11,7 @@ describe Spree::Gateway::StripeSCA, type: :model do create( :payment, state: "checkout", - order: order, + order:, amount: order.total, payment_method: subject, source: credit_card, @@ -92,7 +92,7 @@ describe Spree::Gateway::StripeSCA, type: :model do expect(Checkout::StripeRedirect).to receive(:new).with(subject, order) { redirect_double } expect(redirect_double).to receive(:path).and_return("http://stripe-test.org") - expect(subject.external_payment_url(order: order)).to eq "http://stripe-test.org" + expect(subject.external_payment_url(order:)).to eq "http://stripe-test.org" end end @@ -101,9 +101,9 @@ describe Spree::Gateway::StripeSCA, type: :model do def payment_intent(amount, status) JSON.generate( object: "payment_intent", - amount: amount, - status: status, - charges: { data: [{ id: "ch_1234", amount: amount }] } + amount:, + status:, + charges: { data: [{ id: "ch_1234", amount: }] } ) end end diff --git a/spec/models/spree/inventory_unit_spec.rb b/spec/models/spree/inventory_unit_spec.rb index 7a77bba476..03eb0e7f61 100644 --- a/spec/models/spree/inventory_unit_spec.rb +++ b/spec/models/spree/inventory_unit_spec.rb @@ -64,8 +64,8 @@ describe Spree::InventoryUnit do let(:variant) { create(:variant) } let(:inventory_units) { [ - create(:inventory_unit, variant: variant), - create(:inventory_unit, variant: variant) + create(:inventory_unit, variant:), + create(:inventory_unit, variant:) ] } diff --git a/spec/models/spree/line_item_spec.rb b/spec/models/spree/line_item_spec.rb index e5f3141d54..527b86d551 100644 --- a/spec/models/spree/line_item_spec.rb +++ b/spec/models/spree/line_item_spec.rb @@ -252,7 +252,7 @@ module Spree context "when a variant override is in place" do let!(:hub) { create(:distributor_enterprise) } - let!(:vo) { create(:variant_override, hub: hub, variant: v, count_on_hand: 2) } + let!(:vo) { create(:variant_override, hub:, variant: v, count_on_hand: 2) } before do li.order.update(distributor_id: hub.id) @@ -278,12 +278,12 @@ module Spree create(:order, distributor: hub, order_cycle: create(:simple_order_cycle), - bill_address: bill_address, + bill_address:, ship_address: bill_address) } let!(:shipping_method) { create(:shipping_method, distributors: [hub]) } let!(:line_item) { - create(:line_item, variant: variant_on_demand, quantity: 10, order: order) + create(:line_item, variant: variant_on_demand, quantity: 10, order:) } before do @@ -335,7 +335,7 @@ module Spree let!(:variant) { line_item.variant } context "when a variant override applies" do - let!(:vo) { create(:variant_override, hub: shop, variant: variant, count_on_hand: 3 ) } + let!(:vo) { create(:variant_override, hub: shop, variant:, count_on_hand: 3 ) } it "draws stock from the variant override" do expect(vo.reload.count_on_hand).to eq 3 @@ -363,7 +363,7 @@ module Spree let!(:variant) { line_item.variant } context "when a variant override applies" do - let!(:vo) { create(:variant_override, hub: shop, variant: variant, count_on_hand: 3 ) } + let!(:vo) { create(:variant_override, hub: shop, variant:, count_on_hand: 3 ) } it "restores stock to the variant override" do expect(vo.reload.count_on_hand).to eq 3 @@ -406,7 +406,7 @@ module Spree end context "when a variant override is in place" do - let!(:vo) { create(:variant_override, hub: hub, variant: v, count_on_hand: 5) } + let!(:vo) { create(:variant_override, hub:, variant: v, count_on_hand: 5) } context "and stock on the variant override is sufficient" do it { expect(li.sufficient_stock?).to be true } @@ -788,7 +788,7 @@ module Spree describe "when the associated variant is soft-deleted" do let!(:variant) { create(:variant) } - let!(:line_item) { create(:line_item, variant: variant) } + let!(:line_item) { create(:line_item, variant:) } it "returns the associated variant or product" do line_item.variant.delete diff --git a/spec/models/spree/order/checkout_spec.rb b/spec/models/spree/order/checkout_spec.rb index 84b28216aa..391442e2f6 100644 --- a/spec/models/spree/order/checkout_spec.rb +++ b/spec/models/spree/order/checkout_spec.rb @@ -129,7 +129,7 @@ describe Spree::Order::Checkout do order.order_cycle = create(:simple_order_cycle, distributors: [order.distributor], variants: [order.line_items.first.variant, other_variant]) - order.line_items << create(:line_item, order: order, variant: other_variant) + order.line_items << create(:line_item, order:, variant: other_variant) end it "can progress to delivery" do diff --git a/spec/models/spree/order/state_machine_spec.rb b/spec/models/spree/order/state_machine_spec.rb index 3426532cb1..80bada4c86 100644 --- a/spec/models/spree/order/state_machine_spec.rb +++ b/spec/models/spree/order/state_machine_spec.rb @@ -89,18 +89,18 @@ describe Spree::Order do context "#cancel" do let!(:variant) { build(:variant) } let!(:inventory_units) { - [build(:inventory_unit, variant: variant), - build(:inventory_unit, variant: variant)] + [build(:inventory_unit, variant:), + build(:inventory_unit, variant:)] } let!(:shipment) do shipment = build(:shipment) - allow(shipment).to receive_messages inventory_units: inventory_units + allow(shipment).to receive_messages(inventory_units:) allow(order).to receive_messages shipments: [shipment] shipment end before do - allow(order).to receive_messages line_items: [build(:line_item, variant: variant, + allow(order).to receive_messages line_items: [build(:line_item, variant:, quantity: 2)] allow(order.line_items).to receive_messages find_by_variant_id: order.line_items.first @@ -161,7 +161,7 @@ describe Spree::Order do allow(order).to receive_messages allow_cancel?: true allow(order).to receive_messages allow_resume?: true allow(order).to receive_messages line_items: - [build(:line_item, variant: variant, quantity: 2)] + [build(:line_item, variant:, quantity: 2)] allow(order.line_items).to receive_messages find_by_variant_id: order.line_items.first order.update(total: 10) order.cancel! diff --git a/spec/models/spree/order/tax_spec.rb b/spec/models/spree/order/tax_spec.rb index 900720aa8c..b815c24e97 100644 --- a/spec/models/spree/order/tax_spec.rb +++ b/spec/models/spree/order/tax_spec.rb @@ -9,7 +9,7 @@ module Spree context "#tax_zone" do let(:bill_address) { create :address } let(:ship_address) { create :address } - let(:order) { Spree::Order.create(ship_address: ship_address, bill_address: bill_address) } + let(:order) { Spree::Order.create(ship_address:, bill_address:) } let(:zone) { create :zone } context "when no zones exist" do @@ -119,23 +119,23 @@ module Spree let(:order) { create(:order) } let(:zone) { create(:zone_with_member) } let(:tax_rate20) { - create(:tax_rate, amount: 0.20, included_in_price: false, zone: zone) + create(:tax_rate, amount: 0.20, included_in_price: false, zone:) } let(:tax_rate30) { - create(:tax_rate, amount: 0.30, included_in_price: false, zone: zone) + create(:tax_rate, amount: 0.30, included_in_price: false, zone:) } let!(:variant) { create(:variant, tax_category: tax_rate20.tax_category, price: 10) } let!(:line_item) { - create(:line_item, variant: variant, order: order, quantity: 2) + create(:line_item, variant:, order:, quantity: 2) } let!(:shipping_method) { create(:shipping_method, tax_category: tax_rate30.tax_category) } let!(:shipment) { - create(:shipment_with, :shipping_method, order: order, cost: 50, - shipping_method: shipping_method) + create(:shipment_with, :shipping_method, order:, cost: 50, + shipping_method:) } before do @@ -148,7 +148,7 @@ module Spree context "when the order has legacy taxes" do let!(:legacy_tax_adjustment) { - create(:adjustment, order: order, adjustable: order, included: false, + create(:adjustment, order:, adjustable: order, included: false, label: "legacy", originator_type: "Spree::TaxRate") } diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 9c9d63593f..a813e14bc2 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe Spree::Order do let(:user) { build(:user, email: "spree@example.com") } - let(:order) { build(:order, user: user) } + let(:order) { build(:order, user:) } describe "#errors" do it "provides friendly error messages" do @@ -192,7 +192,7 @@ describe Spree::Order do end it "should change the shipment state to ready if order is paid" do - Spree::Shipment.create(order: order) + Spree::Shipment.create(order:) order.shipments.reload allow(order).to receive_messages(paid?: true, complete?: true) @@ -293,7 +293,7 @@ describe Spree::Order do context "#amount" do before do - @order = create(:order, user: user) + @order = create(:order, user:) @order.line_items = [create(:line_item, price: 1.0, quantity: 2), create(:line_item, price: 1.0, quantity: 1)] end @@ -708,7 +708,7 @@ describe Spree::Order do context "with a taxed shipment" do let!(:shipment) { - create(:shipment_with, :shipping_method, shipping_method: shipping_method, order: order) + create(:shipment_with, :shipping_method, shipping_method:, order:) } before do @@ -735,19 +735,19 @@ describe Spree::Order do let(:enterprise_fee) { create(:enterprise_fee) } let!(:fee_adjustment) { create(:adjustment, adjustable: order, originator: enterprise_fee, - amount: 100, order: order, state: "closed") + amount: 100, order:, state: "closed") } let!(:fee_tax1) { create(:adjustment, adjustable: fee_adjustment, originator_type: "Spree::TaxRate", - amount: 12.3, order: order, state: "closed") + amount: 12.3, order:, state: "closed") } let!(:fee_tax2) { create(:adjustment, adjustable: fee_adjustment, originator_type: "Spree::TaxRate", - amount: 4.5, order: order, state: "closed") + amount: 4.5, order:, state: "closed") } let!(:admin_adjustment) { create(:adjustment, adjustable: order, originator: nil, - amount: 6.7, order: order, state: "closed") + amount: 6.7, order:, state: "closed") } it "returns a sum of all taxes on enterprise fees" do @@ -761,20 +761,20 @@ describe Spree::Order do let(:order) { create(:order) } let(:shipping_method) { create(:shipping_method_with, :flat_rate) } let!(:shipment) do - create(:shipment_with, :shipping_method, shipping_method: shipping_method, order: order) + create(:shipment_with, :shipping_method, shipping_method:, order:) end let(:enterprise_fee) { create(:enterprise_fee) } let!(:fee) { create(:adjustment, adjustable: order, originator: enterprise_fee, label: "EF", amount: 20, - order: order) + order:) } let!(:fee_tax) { create(:adjustment, adjustable: fee, originator: fee_tax_rate, - amount: 2, order: order, state: "closed") + amount: 2, order:, state: "closed") } let!(:shipping_tax) { create(:adjustment, adjustable: shipment, originator: shipping_tax_rate, - amount: 10, order: order, state: "closed") + amount: 10, order:, state: "closed") } before do @@ -955,7 +955,7 @@ describe Spree::Order do describe "sending confirmation emails" do let!(:distributor) { create(:distributor_enterprise) } - let!(:order) { create(:order, distributor: distributor) } + let!(:order) { create(:order, distributor:) } it "sends confirmation emails" do mailer = double(:mailer, deliver_later: true) @@ -966,7 +966,7 @@ describe Spree::Order do end it "does not send confirmation emails when the order belongs to a subscription" do - create(:proxy_order, order: order) + create(:proxy_order, order:) expect(Spree::OrderMailer).not_to receive(:confirm_email_for_customer) expect(Spree::OrderMailer).not_to receive(:confirm_email_for_shop) @@ -1005,7 +1005,7 @@ describe Spree::Order do context "when creating an order" do it "does not create a customer" do expect { - create(:order, distributor: distributor) + create(:order, distributor:) }.to_not change { Customer.count } @@ -1014,11 +1014,11 @@ describe Spree::Order do it "associates an existing customer" do customer = create( :customer, - user: user, + user:, email: user.email, enterprise: distributor ) - order = create(:order, user: user, distributor: distributor) + order = create(:order, user:, distributor:) expect(order.customer).to eq customer end @@ -1026,13 +1026,13 @@ describe Spree::Order do context "when updating the order" do before do - order.update!(distributor: distributor) + order.update!(distributor:) end it "associates an existing customer" do customer = create( :customer, - user: user, + user:, email: user.email, enterprise: distributor ) @@ -1062,7 +1062,7 @@ describe Spree::Order do # Change email instantly without confirmation via Devise: order.user.update_columns(email: "new@email.org") - other_order = create(:order, user: order.user, distributor: distributor) + other_order = create(:order, user: order.user, distributor:) expect { other_order.update!(state: "complete") @@ -1077,7 +1077,7 @@ describe Spree::Order do order.update!(state: "complete") # The user may check out as guest first: - guest_order = create(:order, user: nil, email: "new@email.org", distributor: distributor) + guest_order = create(:order, user: nil, email: "new@email.org", distributor:) guest_order.update!(state: "complete") # Afterwards the user changes their email in their profile. @@ -1088,7 +1088,7 @@ describe Spree::Order do # The two customer entries are merged and one is deleted: expect { - other_order = create(:order, user: order.user, distributor: distributor) + other_order = create(:order, user: order.user, distributor:) }.to change { Customer.count }.by(-1) expect(other_order.customer.email).to eq "new@email.org" @@ -1103,7 +1103,7 @@ describe Spree::Order do end describe "when a guest order is placed with a registered email" do - let(:order) { create(:order_with_totals_and_distribution, user: user) } + let(:order) { create(:order_with_totals_and_distribution, user:) } let(:payment_method) { create(:payment_method, distributors: [order.distributor]) } let(:shipping_method) { create(:shipping_method, distributors: [order.distributor]) } let(:user) { create(:user, email: 'registered@email.com') } @@ -1128,12 +1128,12 @@ describe Spree::Order do describe "a completed order with shipping and transaction fees" do let(:distributor) { create(:distributor_enterprise_with_tax) } let(:zone) { create(:zone_with_member) } - let(:shipping_tax_rate) { create(:tax_rate, amount: 0.25, included_in_price: true, zone: zone) } + let(:shipping_tax_rate) { create(:tax_rate, amount: 0.25, included_in_price: true, zone:) } let(:shipping_tax_category) { create(:tax_category, tax_rates: [shipping_tax_rate]) } let(:order) { - create(:completed_order_with_fees, distributor: distributor, shipping_fee: shipping_fee, - payment_fee: payment_fee, - shipping_tax_category: shipping_tax_category) + create(:completed_order_with_fees, distributor:, shipping_fee:, + payment_fee:, + shipping_tax_category:) } let(:shipping_fee) { 3 } let(:payment_fee) { 5 } @@ -1189,7 +1189,7 @@ describe Spree::Order do it "updates shipping fees" do order.shipments = [create(:shipment_with, :shipping_method, - shipping_method: shipping_method)] + shipping_method:)] order.save expect(order.adjustment_total).to eq expected_fees - (item_num * shipping_fee) @@ -1218,7 +1218,7 @@ describe Spree::Order do describe "retrieving previously ordered items" do let(:distributor) { create(:distributor_enterprise) } let(:order_cycle) { create(:simple_order_cycle) } - let!(:order) { create(:order, distributor: distributor, order_cycle: order_cycle) } + let!(:order) { create(:order, distributor:, order_cycle:) } it "returns no items if nothing has been ordered" do expect(order.finalised_line_items).to eq [] @@ -1238,11 +1238,11 @@ describe Spree::Order do context "when an order has been finalised in this order cycle" do let!(:prev_order) { - create(:completed_order_with_totals, distributor: distributor, order_cycle: order_cycle, + create(:completed_order_with_totals, distributor:, order_cycle:, user: order.user) } let!(:prev_order2) { - create(:completed_order_with_totals, distributor: distributor, order_cycle: order_cycle, + create(:completed_order_with_totals, distributor:, order_cycle:, user: order.user) } let(:product) { create(:product) } @@ -1267,7 +1267,7 @@ describe Spree::Order do let!(:payment_method) { create(:stripe_sca_payment_method, distributor_ids: [enterprise.id]) } - let!(:payment) { create(:payment, order: order, payment_method: payment_method) } + let!(:payment) { create(:payment, order:, payment_method:) } it "does not include the :confirm step" do expect(order.checkout_steps).to_not include "confirm" @@ -1296,7 +1296,7 @@ describe Spree::Order do it "advances to complete state without error" do advance_to_delivery_state(order) order.next! - order.payments << create(:payment, order: order) + order.payments << create(:payment, order:) expect { order.next! }.to change { order.state }.from("payment").to("confirmation") expect { order.next! }.to change { order.state }.from("confirmation").to("complete") @@ -1304,7 +1304,7 @@ describe Spree::Order do end context "when the order is a subscription" do - let!(:proxy_order) { create(:proxy_order, order: order) } + let!(:proxy_order) { create(:proxy_order, order:) } let!(:order_cycle) { proxy_order.order_cycle } context "and order_cycle has no order_close_at set" do @@ -1380,7 +1380,7 @@ describe Spree::Order do end describe "#ensure_updated_shipments" do - before { Spree::Shipment.create!(order: order) } + before { Spree::Shipment.create!(order:) } context "when the order is not completed" do it "destroys current shipments" do @@ -1422,7 +1422,7 @@ describe Spree::Order do let(:distributor) { create(:distributor_enterprise) } let(:order) do - create(:order, distributor: distributor).tap do |order| + create(:order, distributor:).tap do |order| order.line_items << build(:line_item, variant: aaron_apple.variants.first) order.line_items << build(:line_item, variant: zed_banana.variants.first) order.line_items << build(:line_item, variant: zed_apple.variants.first) @@ -1465,7 +1465,7 @@ describe Spree::Order do describe "#voucher_adjustments" do let(:distributor) { create(:distributor_enterprise) } - let(:order) { create(:order, user: user, distributor: distributor) } + let(:order) { create(:order, user:, distributor:) } let(:voucher) { create(:voucher_flat_rate, code: 'new_code', enterprise: order.distributor) } context "when no voucher adjustment" do diff --git a/spec/models/spree/payment_method_spec.rb b/spec/models/spree/payment_method_spec.rb index d69895d934..2cc9de695e 100644 --- a/spec/models/spree/payment_method_spec.rb +++ b/spec/models/spree/payment_method_spec.rb @@ -34,7 +34,7 @@ describe Spree::PaymentMethod do [nil, 'both', 'back_end'].each do |display_on| Spree::Gateway::Test.create( name: 'Display Both', - display_on: display_on, + display_on:, active: true, environment: 'test', description: 'foofah', diff --git a/spec/models/spree/payment_spec.rb b/spec/models/spree/payment_spec.rb index 6d39f2e553..624911bbb1 100644 --- a/spec/models/spree/payment_spec.rb +++ b/spec/models/spree/payment_spec.rb @@ -51,8 +51,8 @@ describe Spree::Payment do context "creating a new payment alongside other incomplete payments" do let(:order) { create(:order_with_totals) } - let!(:incomplete_payment) { create(:payment, order: order, state: "pending") } - let(:new_payment) { create(:payment, order: order, state: "checkout") } + let!(:incomplete_payment) { create(:payment, order:, state: "pending") } + let(:new_payment) { create(:payment, order:, state: "checkout") } it "invalidates other incomplete payments on the order" do new_payment @@ -378,13 +378,13 @@ describe Spree::Payment do } it "should create another adjustment and revoke the previous one" do - payment = create(:payment, order: order, payment_method: payment_method) + payment = create(:payment, order:, payment_method:) expect(order.all_adjustments.payment_fee.eligible.length).to eq(1) payment.void_transaction! expect(order.all_adjustments.payment_fee.eligible.length).to eq(0) - payment = create(:payment, order: order, payment_method: payment_method) + payment = create(:payment, order:, payment_method:) expect(order.all_adjustments.payment_fee.eligible.length).to eq(1) end end @@ -598,7 +598,7 @@ describe Spree::Payment do context "#save" do context "completed payments" do it "updates order payment total" do - payment = create(:payment, :completed, amount: 100, order: order) + payment = create(:payment, :completed, amount: 100, order:) expect(order.payment_total).to eq payment.amount end end @@ -606,13 +606,13 @@ describe Spree::Payment do context "non-completed payments" do it "doesn't update order payment total" do expect { - create(:payment, amount: 100, order: order) + create(:payment, amount: 100, order:) }.not_to change { order.payment_total } end end context 'when the payment was completed but now void' do - let(:payment) { create(:payment, :completed, amount: 100, order: order) } + let(:payment) { create(:payment, :completed, amount: 100, order:) } it 'updates order payment total' do payment.void @@ -634,7 +634,7 @@ describe Spree::Payment do expect(order_updater).to receive(:update_payment_state) expect(order_updater).to receive(:update_shipment_state) - create(:payment, amount: 100, order: order) + create(:payment, amount: 100, order:) end end @@ -653,7 +653,7 @@ describe Spree::Payment do expect do Spree::Payment.create( amount: 100, - order: order, + order:, source: card, payment_method: gateway ) @@ -703,7 +703,7 @@ describe Spree::Payment do end context 'when the payment was completed but now void' do - let(:payment) { create(:payment, :completed, amount: 100, order: order) } + let(:payment) { create(:payment, :completed, amount: 100, order:) } it 'updates order payment total' do payment.void @@ -912,7 +912,7 @@ describe Spree::Payment do describe "applying transaction fees" do let!(:order) { create(:order) } - let!(:line_item) { create(:line_item, order: order, quantity: 3, price: 5.00) } + let!(:line_item) { create(:line_item, order:, quantity: 3, price: 5.00) } before do order.reload.update_order! @@ -920,7 +920,7 @@ describe Spree::Payment do context "when order-based calculator" do let!(:shop) { create(:enterprise) } - let!(:payment_method) { create(:payment_method, calculator: calculator) } + let!(:payment_method) { create(:payment_method, calculator:) } let!(:calculator) do ::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) end @@ -928,10 +928,10 @@ describe Spree::Payment do context "when order complete" do let!(:order) { create(:completed_order_with_totals, distributor: shop) } let!(:variant) { order.line_items.first.variant } - let!(:inventory_item) { create(:inventory_item, enterprise: shop, variant: variant) } + let!(:inventory_item) { create(:inventory_item, enterprise: shop, variant:) } it "creates adjustment" do - payment = create(:payment, order: order, payment_method: payment_method, + payment = create(:payment, order:, payment_method:, amount: order.total) expect(payment.adjustment).to be_present expect(payment.adjustment.amount).not_to eq(0) @@ -944,7 +944,7 @@ describe Spree::Payment do context 'OFN specs from previously decorated model' do describe "applying transaction fees" do let!(:order) { create(:order) } - let!(:line_item) { create(:line_item, order: order, quantity: 3, price: 5.00) } + let!(:line_item) { create(:line_item, order:, quantity: 3, price: 5.00) } before do order.reload.update_order! @@ -957,7 +957,7 @@ describe Spree::Payment do preferred_enterprise_id: shop.id) } let(:payment) { - create(:payment, order: order, payment_method: payment_method, amount: order.total) + create(:payment, order:, payment_method:, amount: order.total) } let(:calculator) { ::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) } diff --git a/spec/models/spree/preference_spec.rb b/spec/models/spree/preference_spec.rb index 0eb32f9837..b70cf1bc1a 100644 --- a/spec/models/spree/preference_spec.rb +++ b/spec/models/spree/preference_spec.rb @@ -19,7 +19,7 @@ describe Spree::Preference do p.key = key p.save - Spree::Preference.find_by(key: key) + Spree::Preference.find_by(key:) end it ":boolean" do