diff --git a/Gemfile.lock b/Gemfile.lock index 81b5e0127f..ddd3efa60b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -440,7 +440,7 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (4.2.1) railties (>= 3.2.16) - json (2.15.2) + json (2.18.1) json-canonicalization (1.0.0) json-jwt (1.17.0) activesupport (>= 4.2) @@ -573,7 +573,7 @@ GEM parallel (1.27.0) paranoia (2.6.4) activerecord (>= 5.1, < 7.2) - parser (3.3.10.1) + parser (3.3.10.2) ast (~> 2.4.1) racc paypal-sdk-core (0.3.4) @@ -772,7 +772,7 @@ GEM rswag-ui (2.17.0) actionpack (>= 5.2, < 8.2) railties (>= 5.2, < 8.2) - rubocop (1.81.7) + rubocop (1.84.2) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -780,7 +780,7 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.47.1, < 2.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.49.0) diff --git a/app/models/spree/product.rb b/app/models/spree/product.rb index 2ad3561b6c..e077af407b 100755 --- a/app/models/spree/product.rb +++ b/app/models/spree/product.rb @@ -251,7 +251,7 @@ module Spree transaction do ExchangeVariant. where(exchange_variants: { variant_id: variants.with_deleted. - select(:id) }).destroy_all + select(:id) }).destroy_all yield end diff --git a/app/models/spree/taxon.rb b/app/models/spree/taxon.rb index 09c772fdf0..a663a05922 100644 --- a/app/models/spree/taxon.rb +++ b/app/models/spree/taxon.rb @@ -35,8 +35,8 @@ module Spree taxons .pluck('spree_taxons.id, enterprises.id AS enterprise_id') .each_with_object({}) do |(taxon_id, enterprise_id), collection| - collection[enterprise_id.to_i] ||= Set.new - collection[enterprise_id.to_i] << taxon_id + collection[enterprise_id.to_i] ||= Set.new + collection[enterprise_id.to_i] << taxon_id end end diff --git a/app/models/spree/variant.rb b/app/models/spree/variant.rb index 63baad819e..d6eda45ca8 100644 --- a/app/models/spree/variant.rb +++ b/app/models/spree/variant.rb @@ -167,8 +167,8 @@ module Spree # In Rails 3, merging two scopes on the same column will consider only the last scope. def self.in_distributor(distributor) where(id: ExchangeVariant.select(:variant_id). - joins(:exchange). - where('exchanges.incoming = ? AND exchanges.receiver_id = ?', false, distributor)) + joins(:exchange). + where('exchanges.incoming = ? AND exchanges.receiver_id = ?', false, distributor)) end def self.indexed @@ -179,11 +179,11 @@ module Spree # "where(id:" is necessary so that the returned relation has no includes # The relation without includes will not be readonly and allow updates on it where(spree_variants: { id: joins(:prices). - where(deleted_at: nil). - where('spree_prices.currency' => + where(deleted_at: nil). + where('spree_prices.currency' => currency || CurrentConfig.get(:currency)). - where.not(spree_prices: { amount: nil }). - select("spree_variants.id") }) + where.not(spree_prices: { amount: nil }). + select("spree_variants.id") }) end def self.linked_to(semantic_id) diff --git a/app/queries/product_scope_query.rb b/app/queries/product_scope_query.rb index bdadbc3401..e900f60769 100644 --- a/app/queries/product_scope_query.rb +++ b/app/queries/product_scope_query.rb @@ -60,8 +60,8 @@ class ProductScopeQuery def product_query_includes [ - image: { attachment_attachment: :blob }, - variants: [:default_price, :stock_items, :variant_overrides] + { image: { attachment_attachment: :blob }, + variants: [:default_price, :stock_items, :variant_overrides] } ] end diff --git a/app/services/dfc_catalog_importer.rb b/app/services/dfc_catalog_importer.rb index 16d81ac6d3..8ec1c74310 100644 --- a/app/services/dfc_catalog_importer.rb +++ b/app/services/dfc_catalog_importer.rb @@ -42,10 +42,10 @@ class DfcCatalogImporter .includes(:semantic_links).references(:semantic_links) .where.not(semantic_links: { semantic_id: present_ids }) .select do |variant| - # Variants that were in the same catalog before: - variant.semantic_links.map(&:semantic_id).any? do |semantic_id| - FdcUrlBuilder.new(semantic_id).catalog_url == catalog_url - end + # Variants that were in the same catalog before: + variant.semantic_links.map(&:semantic_id).any? do |semantic_id| + FdcUrlBuilder.new(semantic_id).catalog_url == catalog_url + end end end end diff --git a/app/services/line_item_syncer.rb b/app/services/line_item_syncer.rb index fb2af07b13..ce7fda37eb 100644 --- a/app/services/line_item_syncer.rb +++ b/app/services/line_item_syncer.rb @@ -51,8 +51,8 @@ class LineItemSyncer def destroy_obsolete_items(order) order.line_items. where(variant_id: subscription_line_items. - select(&:marked_for_destruction?). - map(&:variant_id)). + select(&:marked_for_destruction?). + map(&:variant_id)). destroy_all end diff --git a/app/services/orders/handle_fees_service.rb b/app/services/orders/handle_fees_service.rb index 64e42f63ad..eb6211d5e8 100644 --- a/app/services/orders/handle_fees_service.rb +++ b/app/services/orders/handle_fees_service.rb @@ -130,12 +130,11 @@ module Orders def order_cycle_fees return @order_cycle_fees if defined? @order_cycle_fees + return [] unless order_cycle && distributor @order_cycle_fees = begin fees = [] - return fees unless order_cycle && distributor - order_cycle.exchanges.supplying_to(distributor).each do |exchange| exchange.enterprise_fees.per_item.each do |enterprise_fee| fee_value = FeeValue.new(fee: enterprise_fee, role: exchange.role) diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index 391377ba49..b7c8fa92e4 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -14,12 +14,12 @@ module PermittedAttributes def self.attributes basic_permitted_attributes + [ - group_ids: [], user_ids: [], - shipping_method_ids: [], payment_method_ids: [], - address_attributes: PermittedAttributes::Address.attributes, - business_address_attributes: PermittedAttributes::BusinessAddress.attributes, - producer_properties_attributes: [:id, :property_name, :value, :_destroy], - custom_tab_attributes: PermittedAttributes::CustomTab.attributes, + { group_ids: [], user_ids: [], + shipping_method_ids: [], payment_method_ids: [], + address_attributes: PermittedAttributes::Address.attributes, + business_address_attributes: PermittedAttributes::BusinessAddress.attributes, + producer_properties_attributes: [:id, :property_name, :value, :_destroy], + custom_tab_attributes: PermittedAttributes::CustomTab.attributes }, ] end diff --git a/app/services/permitted_attributes/order_cycle.rb b/app/services/permitted_attributes/order_cycle.rb index dc23c8e5c3..b0351e0901 100644 --- a/app/services/permitted_attributes/order_cycle.rb +++ b/app/services/permitted_attributes/order_cycle.rb @@ -25,8 +25,8 @@ module PermittedAttributes private def attributes - self.class.basic_attributes + [incoming_exchanges: permitted_exchange_attributes, - outgoing_exchanges: permitted_exchange_attributes] + self.class.basic_attributes + [{ incoming_exchanges: permitted_exchange_attributes, + outgoing_exchanges: permitted_exchange_attributes }] end def permitted_exchange_attributes diff --git a/app/services/permitted_attributes/subscription.rb b/app/services/permitted_attributes/subscription.rb index e80469767f..a8b34e85d9 100644 --- a/app/services/permitted_attributes/subscription.rb +++ b/app/services/permitted_attributes/subscription.rb @@ -26,11 +26,11 @@ module PermittedAttributes def other_permitted_attributes [ - subscription_line_items_attributes: [ - :id, :quantity, :variant_id, :price_estimate, :_destroy - ], - bill_address_attributes: PermittedAttributes::Address.attributes, - ship_address_attributes: PermittedAttributes::Address.attributes + { subscription_line_items_attributes: [ + :id, :quantity, :variant_id, :price_estimate, :_destroy + ], + bill_address_attributes: PermittedAttributes::Address.attributes, + ship_address_attributes: PermittedAttributes::Address.attributes } ] end end diff --git a/engines/dfc_provider/spec/requests/catalog_items_spec.rb b/engines/dfc_provider/spec/requests/catalog_items_spec.rb index 1b69192310..1d3854b072 100644 --- a/engines/dfc_provider/spec/requests/catalog_items_spec.rb +++ b/engines/dfc_provider/spec/requests/catalog_items_spec.rb @@ -36,7 +36,7 @@ RSpec.describe "CatalogItems", swagger_doc: "dfc.yaml" do get "List CatalogItems" do produces "application/json" - security [oidc_token: []] + security [{ oidc_token: [] }] response "404", "not found" do context "as platform user" do diff --git a/engines/dfc_provider/spec/requests/product_groups_spec.rb b/engines/dfc_provider/spec/requests/product_groups_spec.rb index 9520acab2c..cea6ed0182 100644 --- a/engines/dfc_provider/spec/requests/product_groups_spec.rb +++ b/engines/dfc_provider/spec/requests/product_groups_spec.rb @@ -35,7 +35,7 @@ RSpec.describe "ProductGroups", swagger_doc: "dfc.yaml" do get "Show ProductGroup" do produces "application/json" - security [oidc_token: []] + security [{ oidc_token: [] }] response "200", "success" do let(:id) { product.id } diff --git a/lib/reporting/line_items.rb b/lib/reporting/line_items.rb index 1fa5cb56c5..8a709aa8e1 100644 --- a/lib/reporting/line_items.rb +++ b/lib/reporting/line_items.rb @@ -15,7 +15,7 @@ module Reporting @orders ||= search_orders end - def list(line_item_includes = [variant: [:supplier, :product]]) + def list(line_item_includes = [{ variant: [:supplier, :product] }]) line_items = order_permissions.visible_line_items.in_orders(orders.result) .order( "supplier.name", diff --git a/lib/reporting/reports/customers/base.rb b/lib/reporting/reports/customers/base.rb index b53fb7b44c..3539775c6d 100644 --- a/lib/reporting/reports/customers/base.rb +++ b/lib/reporting/reports/customers/base.rb @@ -10,10 +10,10 @@ module Reporting .complete.not_state(:canceled) .order(:id)) .group_by do |order| - { - customer_id: order.customer_id || order.email, - hub_id: order.distributor_id, - } + { + customer_id: order.customer_id || order.email, + hub_id: order.distributor_id, + } end.values end diff --git a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb index abc27aa844..51c6a21fe5 100644 --- a/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb +++ b/lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb @@ -44,11 +44,11 @@ module Reporting .filter(&method(:filter_enterprise_fee_by_id)) .filter(&method(:filter_enterprise_fee_by_owner)) .map do |enterprise_fee_id, enterprise_fee_adjustment_ids| - { - enterprise_fee_id:, - enterprise_fee_adjustment_ids:, - order: - } + { + enterprise_fee_id:, + enterprise_fee_adjustment_ids:, + order: + } end end end diff --git a/spec/models/spree/order/state_machine_spec.rb b/spec/models/spree/order/state_machine_spec.rb index 7ac1d81333..f50326789d 100644 --- a/spec/models/spree/order/state_machine_spec.rb +++ b/spec/models/spree/order/state_machine_spec.rb @@ -86,11 +86,11 @@ RSpec.describe Spree::Order do (Spree::Shipment.state_machine.states.keys - [:pending, :backorder, :ready]) .each do |shipment_state| - it "should be false if shipment_state is #{shipment_state}" do - allow(order).to receive_messages completed?: true - order.shipment_state = shipment_state - expect(order.can_cancel?).to be_falsy - end + it "should be false if shipment_state is #{shipment_state}" do + allow(order).to receive_messages completed?: true + order.shipment_state = shipment_state + expect(order.can_cancel?).to be_falsy + end end end diff --git a/spec/models/spree/user_spec.rb b/spec/models/spree/user_spec.rb index 517b405ac7..5e6fea55ef 100644 --- a/spec/models/spree/user_spec.rb +++ b/spec/models/spree/user_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Spree::User do bill_address_attributes: new_bill_address.dup.attributes.merge( 'id' => old_bill_address.id ) - .except!('created_at', 'updated_at') + .except!('created_at', 'updated_at') ) expect(user.bill_address.id).to eq old_bill_address.id diff --git a/spec/queries/outstanding_balance_query_spec.rb b/spec/queries/outstanding_balance_query_spec.rb index 57d4f14adb..e69cbfdd66 100644 --- a/spec/queries/outstanding_balance_query_spec.rb +++ b/spec/queries/outstanding_balance_query_spec.rb @@ -10,7 +10,7 @@ RSpec.describe OutstandingBalanceQuery do let(:normalized_sql_statement) { normalize(query.statement) } it 'returns the CASE statement necessary to compute the order balance' do - expect(normalized_sql_statement).to eq(normalize(<<-SQL.squish)) + expect(normalized_sql_statement).to eq(normalize(<<~SQL.squish)) CASE WHEN "spree_orders"."state" IN ('canceled', 'returned') THEN "spree_orders"."payment_total" WHEN "spree_orders"."state" IS NOT NULL THEN "spree_orders"."payment_total" - "spree_orders"."total" ELSE 0 END diff --git a/spec/services/orders/compare_invoice_service_spec.rb b/spec/services/orders/compare_invoice_service_spec.rb index 4580446b52..a3c5a8a2cc 100644 --- a/spec/services/orders/compare_invoice_service_spec.rb +++ b/spec/services/orders/compare_invoice_service_spec.rb @@ -38,8 +38,8 @@ RSpec.shared_examples "attribute changes - tax total changes" do |boolean, type, create(:order_with_taxes, product_price: 110, tax_rate_amount: 0.1, included_in_price: included_boolean) .tap do |order| - order.create_tax_charge! - order.update_shipping_fees! + order.create_tax_charge! + order.update_shipping_fees! end end diff --git a/spec/support/request/stripe_stubs.rb b/spec/support/request/stripe_stubs.rb index 524233cffc..8132d8751e 100644 --- a/spec/support/request/stripe_stubs.rb +++ b/spec/support/request/stripe_stubs.rb @@ -144,7 +144,7 @@ module StripeStubs customer_id = options[:customer_id] || "cus_A123" { status: 200, body: JSON.generate(id: customer_id, - sources: { data: [id: customer_id] }) } + sources: { data: [{ id: customer_id }] }) } end def payment_successful_refund_mock diff --git a/spec/system/admin/bulk_order_management_spec.rb b/spec/system/admin/bulk_order_management_spec.rb index cf768670f2..33542ff71c 100644 --- a/spec/system/admin/bulk_order_management_spec.rb +++ b/spec/system/admin/bulk_order_management_spec.rb @@ -1044,10 +1044,10 @@ RSpec.describe ' page.driver .dismiss_modal :confirm, text: "Unsaved changes exist and will be lost if you continue." do - within "tr#li_#{li1.id}" do - fill_in "quantity", with: (li1.quantity + 1) - find("a.edit-order").click - end + within "tr#li_#{li1.id}" do + fill_in "quantity", with: (li1.quantity + 1) + find("a.edit-order").click + end end # So we save the changes diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index eac1eb1de0..4e513845b3 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -360,10 +360,10 @@ RSpec.describe "As a consumer, I want to checkout my order" do # And fake the payment status to avoid user interaction. allow_any_instance_of(Taler::Client) .to receive(:fetch_order) do - payment = Spree::Payment.last - url = payment_gateways_confirm_taler_path(payment_id: payment.id) + payment = Spree::Payment.last + url = payment_gateways_confirm_taler_path(payment_id: payment.id) - { "order_status_url" => url, "order_status" => "paid" } + { "order_status_url" => url, "order_status" => "paid" } end end