diff --git a/lib/open_food_network/enterprise_fee_calculator.rb b/lib/open_food_network/enterprise_fee_calculator.rb index 2c095ff968..66001716ab 100644 --- a/lib/open_food_network/enterprise_fee_calculator.rb +++ b/lib/open_food_network/enterprise_fee_calculator.rb @@ -139,7 +139,7 @@ module OpenFoodNetwork def calculate_fee_for(variant, enterprise_fee) # Spree's Calculator interface accepts Orders or LineItems, # so we meet that interface with a struct. - line_item = OpenStruct.new variant: variant, quantity: 1, price: variant.price, + line_item = OpenStruct.new variant:, quantity: 1, price: variant.price, amount: variant.price enterprise_fee.compute_amount(line_item) end diff --git a/lib/open_food_network/i18n_inflections.rb b/lib/open_food_network/i18n_inflections.rb index e8bb21001e..8903cd7dae 100644 --- a/lib/open_food_network/i18n_inflections.rb +++ b/lib/open_food_network/i18n_inflections.rb @@ -35,7 +35,7 @@ module OpenFoodNetwork return word unless key - I18n.t(key, scope: "inflections", count: count, default: word) + I18n.t(key, scope: "inflections", count:, default: word) end private diff --git a/lib/open_food_network/order_cycle_form_applicator.rb b/lib/open_food_network/order_cycle_form_applicator.rb index 5397be7a31..0b850340e4 100644 --- a/lib/open_food_network/order_cycle_form_applicator.rb +++ b/lib/open_food_network/order_cycle_form_applicator.rb @@ -24,11 +24,11 @@ module OpenFoodNetwork if exchange_exists?(exchange[:enterprise_id], @order_cycle.coordinator_id, true) update_exchange(exchange[:enterprise_id], @order_cycle.coordinator_id, true, - variant_ids: variant_ids, enterprise_fee_ids: enterprise_fee_ids, + variant_ids:, enterprise_fee_ids:, receival_instructions: exchange[:receival_instructions] ) else add_exchange(exchange[:enterprise_id], @order_cycle.coordinator_id, true, - variant_ids: variant_ids, enterprise_fee_ids: enterprise_fee_ids, + variant_ids:, enterprise_fee_ids:, receival_instructions: exchange[:receival_instructions], ) end end @@ -40,15 +40,15 @@ module OpenFoodNetwork if exchange_exists?(@order_cycle.coordinator_id, exchange[:enterprise_id], false) update_exchange(@order_cycle.coordinator_id, exchange[:enterprise_id], false, - variant_ids: variant_ids, - enterprise_fee_ids: enterprise_fee_ids, + variant_ids:, + enterprise_fee_ids:, pickup_time: exchange[:pickup_time], pickup_instructions: exchange[:pickup_instructions], tag_list: exchange[:tag_list] ) else add_exchange(@order_cycle.coordinator_id, exchange[:enterprise_id], false, - variant_ids: variant_ids, - enterprise_fee_ids: enterprise_fee_ids, + variant_ids:, + enterprise_fee_ids:, pickup_time: exchange[:pickup_time], pickup_instructions: exchange[:pickup_instructions], tag_list: exchange[:tag_list] ) @@ -63,13 +63,13 @@ module OpenFoodNetwork attr_accessor :touched_exchanges def exchange_exists?(sender_id, receiver_id, incoming) - @order_cycle.exchanges.where(sender_id: sender_id, receiver_id: receiver_id, - incoming: incoming).present? + @order_cycle.exchanges.where(sender_id:, receiver_id:, + incoming:).present? end def add_exchange(sender_id, receiver_id, incoming, attrs = {}) - attrs = attrs.reverse_merge(sender_id: sender_id, receiver_id: receiver_id, - incoming: incoming) + attrs = attrs.reverse_merge(sender_id:, receiver_id:, + incoming:) variant_ids = attrs.delete :variant_ids exchange = @order_cycle.exchanges.build attrs @@ -82,8 +82,8 @@ module OpenFoodNetwork end def update_exchange(sender_id, receiver_id, incoming, attrs = {}) - exchange = @order_cycle.exchanges.where(sender_id: sender_id, receiver_id: receiver_id, - incoming: incoming).first + exchange = @order_cycle.exchanges.where(sender_id:, receiver_id:, + incoming:).first return unless permission_for(exchange) remove_unauthorized_exchange_attributes(exchange, attrs) @@ -148,7 +148,7 @@ module OpenFoodNetwork def find_exchange(sender_id, receiver_id, incoming) @order_cycle.exchanges. - find_by(sender_id: sender_id, receiver_id: receiver_id, incoming: incoming) + find_by(sender_id:, receiver_id:, incoming:) end def incoming_exchange_variant_ids(attrs) diff --git a/lib/open_food_network/scope_variant_to_hub.rb b/lib/open_food_network/scope_variant_to_hub.rb index 17c8517f72..d7a29cbb9c 100644 --- a/lib/open_food_network/scope_variant_to_hub.rb +++ b/lib/open_food_network/scope_variant_to_hub.rb @@ -19,7 +19,7 @@ module OpenFoodNetwork end def price_in(currency) - Spree::Price.new(amount: price, currency: currency) + Spree::Price.new(amount: price, currency:) end # Uses variant_override.count_on_hand instead of Stock::Quantifier.stock_items.count_on_hand diff --git a/lib/reporting/report_headers_builder.rb b/lib/reporting/report_headers_builder.rb index 369757f9c6..37b85d3629 100644 --- a/lib/reporting/report_headers_builder.rb +++ b/lib/reporting/report_headers_builder.rb @@ -43,7 +43,7 @@ module Reporting def translate_header(key) # Quite some headers use currency interpolation, so providing it by default - default_params = { currency: currency_symbol, currency_symbol: currency_symbol } + default_params = { currency: currency_symbol, currency_symbol: } report.custom_headers[key] || I18n.t("report_header_#{key}", **default_params) end diff --git a/lib/reporting/report_renderer.rb b/lib/reporting/report_renderer.rb index a22f417e4d..05b5a4f45c 100644 --- a/lib/reporting/report_renderer.rb +++ b/lib/reporting/report_renderer.rb @@ -55,7 +55,7 @@ module Reporting def to_html(layout: nil) ApplicationController.render( template: "admin/reports/_table", - layout: layout, + layout:, locals: { report: @report } ) end diff --git a/lib/reporting/report_rows_builder.rb b/lib/reporting/report_rows_builder.rb index bc444ac09e..f8b09488b0 100644 --- a/lib/reporting/report_rows_builder.rb +++ b/lib/reporting/report_rows_builder.rb @@ -42,7 +42,7 @@ module Reporting @computed_data = report.query_result.map { |item| row = @builder.build_row(item) - OpenStruct.new(item: item, full_row: row, row: @builder.slice_and_format_row(row)) + OpenStruct.new(item:, full_row: row, row: @builder.slice_and_format_row(row)) } @computed_data.uniq! { |data| data.row.to_h.values } if @report.skip_duplicate_rows? 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 de29622269..a502d34d96 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 @@ -7,7 +7,7 @@ module Reporting attr_accessor :parameters def initialize(user, params = {}, render: false) - super(user, params, render: render) + super(user, params, render:) end def search @@ -45,9 +45,9 @@ module Reporting .filter(&method(:filter_enterprise_fee_by_owner)) .map do |enterprise_fee_id, enterprise_fee_adjustment_ids| { - enterprise_fee_id: enterprise_fee_id, - enterprise_fee_adjustment_ids: enterprise_fee_adjustment_ids, - order: order + enterprise_fee_id:, + enterprise_fee_adjustment_ids:, + order: } end end @@ -88,7 +88,7 @@ module Reporting tax_rate_ids << nil if tax_rate_ids.empty? tax_rate_ids.map do |tax_rate_id| { - tax_rate_id: tax_rate_id, + tax_rate_id:, enterprise_fee_id: item[:enterprise_fee_id], order: item[:order], } @@ -234,7 +234,7 @@ module Reporting query = Spree::Adjustment.tax query = query.where(included: true) unless included.nil? query = query.where(originator_id: tax_rate_id(query_result_row)) unless all == true - query.where(order_id: order_id) + query.where(order_id:) .where(adjustable_type: 'Spree::Adjustment') .where(adjustable_id: adjustment_ids) .pick("sum(amount)") || 0 diff --git a/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb b/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb index a27aa154a2..c2fc14159b 100644 --- a/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb +++ b/lib/reporting/reports/enterprise_fee_summary/fee_summary.rb @@ -7,7 +7,7 @@ module Reporting attr_accessor :permissions, :parameters def initialize(user, params = {}, render: false) - super(user, params, render: render) + super(user, params, render:) @parameters = Parameters.new(params.fetch(:q, {})) @parameters.validate! @permissions = Permissions.new(user) diff --git a/lib/reporting/reports/list.rb b/lib/reporting/reports/list.rb index 5874b70c70..c15742fbef 100644 --- a/lib/reporting/reports/list.rb +++ b/lib/reporting/reports/list.rb @@ -16,7 +16,7 @@ module Reporting customers: customers_report_types, products_and_inventory: products_and_inventory_report_types, users_and_enterprises: [], - enterprise_fee_summary: enterprise_fee_summary, + enterprise_fee_summary:, order_cycle_management: order_cycle_management_report_types, sales_tax: sales_tax_report_types, xero_invoices: xero_report_types, diff --git a/lib/reporting/reports/order_cycle_management/base.rb b/lib/reporting/reports/order_cycle_management/base.rb index 68c08fe81f..e20e13ab25 100644 --- a/lib/reporting/reports/order_cycle_management/base.rb +++ b/lib/reporting/reports/order_cycle_management/base.rb @@ -72,7 +72,7 @@ module Reporting end def customer_code(email) - customer = Customer.where(email: email).first + customer = Customer.where(email:).first customer.nil? ? "" : customer.code end end diff --git a/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb b/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb index 447c2239ed..87837d32a0 100644 --- a/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb +++ b/lib/reporting/reports/orders_and_fulfillment/order_cycle_supplier_totals.rb @@ -15,7 +15,7 @@ module Reporting total_cost: proc { |line_items| line_items.sum(&:amount) }, sku: variant_sku, producer_charges_sales_tax?: supplier_charges_sales_tax?, - product_tax_category: product_tax_category + product_tax_category: } end diff --git a/lib/reporting/reports/packing/customer.rb b/lib/reporting/reports/packing/customer.rb index 5e5b7addde..a5609725a2 100644 --- a/lib/reporting/reports/packing/customer.rb +++ b/lib/reporting/reports/packing/customer.rb @@ -22,7 +22,7 @@ module Reporting group_by: proc { |_item, row| row_header(row) }, header: true, fields_used_in_header: [:first_name, :last_name, :customer_code, :phone], - summary_row: summary_row, + summary_row:, } ] end diff --git a/lib/reporting/reports/packing/product.rb b/lib/reporting/reports/packing/product.rb index 83f6bd2e1b..e219fc2c88 100644 --- a/lib/reporting/reports/packing/product.rb +++ b/lib/reporting/reports/packing/product.rb @@ -27,7 +27,7 @@ module Reporting group_by: proc { |_item, row| "#{row.product} - #{row.variant}" }, header: true, fields_used_in_header: [:product, :variant], - summary_row: summary_row, + summary_row:, header_class: "h3", } ] diff --git a/lib/reporting/reports/packing/supplier.rb b/lib/reporting/reports/packing/supplier.rb index c8ed63adba..cca255786b 100644 --- a/lib/reporting/reports/packing/supplier.rb +++ b/lib/reporting/reports/packing/supplier.rb @@ -20,7 +20,7 @@ module Reporting { group_by: :supplier, header: true, - summary_row: summary_row, + summary_row:, summary_row_label: I18n.t('admin.reports.total_by_supplier').upcase }, { @@ -28,7 +28,7 @@ module Reporting header: true, header_class: 'h4', fields_used_in_header: [:first_name, :last_name, :customer_code, :phone], - summary_row: summary_row, + summary_row:, summary_row_class: "", summary_row_label: I18n.t('admin.reports.total_by_customer') } diff --git a/lib/reporting/reports/sales_tax/sales_tax_totals_by_order.rb b/lib/reporting/reports/sales_tax/sales_tax_totals_by_order.rb index 7437e11f87..a1d4973751 100644 --- a/lib/reporting/reports/sales_tax/sales_tax_totals_by_order.rb +++ b/lib/reporting/reports/sales_tax/sales_tax_totals_by_order.rb @@ -33,8 +33,8 @@ module Reporting tax_rate_ids << nil if tax_rate_ids.empty? tax_rate_ids.map do |tax_rate_id| { - tax_rate_id: tax_rate_id, - order: order + tax_rate_id:, + order: } end end diff --git a/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb b/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb index 603e11b5c3..0271b38d59 100644 --- a/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb +++ b/lib/reporting/reports/sales_tax/sales_tax_totals_by_producer.rb @@ -27,7 +27,7 @@ module Reporting line_item.tax_rates.map do |tax_rate| { tax_rate_id: tax_rate.id, - line_item: line_item + line_item: } end end.group_by do |hash| @@ -81,8 +81,8 @@ module Reporting line_item.adjustments.eligible.tax.sum(&:amount) end.sum { - total_excl_tax: total_excl_tax, - tax: tax, + total_excl_tax:, + tax:, total_incl_tax: total_excl_tax + tax } end diff --git a/lib/spree/core/controller_helpers/respond_with.rb b/lib/spree/core/controller_helpers/respond_with.rb index 3e0f641297..716586f34a 100644 --- a/lib/spree/core/controller_helpers/respond_with.rb +++ b/lib/spree/core/controller_helpers/respond_with.rb @@ -19,7 +19,7 @@ module ActionController !ApplicationController.spree_responders[self.class.to_s.to_sym].try(:[], action_name.to_sym) if action = options.delete(:action) - render action: action + render(action:) else defined_response.call end diff --git a/lib/stripe/account_connector.rb b/lib/stripe/account_connector.rb index f92d452aa0..7eb0fab237 100644 --- a/lib/stripe/account_connector.rb +++ b/lib/stripe/account_connector.rb @@ -25,7 +25,7 @@ module Stripe StripeAccount.create( stripe_user_id: token.stripe_user_id, stripe_publishable_key: token.stripe_publishable_key, - enterprise: enterprise + enterprise: ) end diff --git a/lib/stripe/credit_card_clone_destroyer.rb b/lib/stripe/credit_card_clone_destroyer.rb index 178d8aa657..b50ea657b3 100644 --- a/lib/stripe/credit_card_clone_destroyer.rb +++ b/lib/stripe/credit_card_clone_destroyer.rb @@ -16,7 +16,7 @@ module Stripe Stripe::CreditCardCloneFinder.new(card, stripe_account).find_cloned_card next unless customer_id - stripe_customer = Stripe::Customer.retrieve(customer_id, stripe_account: stripe_account) + stripe_customer = Stripe::Customer.retrieve(customer_id, stripe_account:) stripe_customer.delete if stripe_customer && !stripe_customer.deleted? end end diff --git a/lib/stripe/credit_card_clone_finder.rb b/lib/stripe/credit_card_clone_finder.rb index d8e1b73557..322ce1be80 100644 --- a/lib/stripe/credit_card_clone_finder.rb +++ b/lib/stripe/credit_card_clone_finder.rb @@ -11,7 +11,7 @@ module Stripe return nil unless fingerprint = fingerprint_for_card(@card) return nil unless email = @card.user&.email - customers = Stripe::Customer.list({ email: email, limit: 100 }, + customers = Stripe::Customer.list({ email:, limit: 100 }, stripe_account: @stripe_account) customers.auto_paging_each do |customer| diff --git a/lib/stripe/payment_intent_validator.rb b/lib/stripe/payment_intent_validator.rb index 10f176af61..326f8df60b 100644 --- a/lib/stripe/payment_intent_validator.rb +++ b/lib/stripe/payment_intent_validator.rb @@ -29,7 +29,7 @@ module Stripe def stripe_account_id enterprise_id = payment.payment_method&.preferred_enterprise_id - StripeAccount.find_by(enterprise_id: enterprise_id)&.stripe_user_id + StripeAccount.find_by(enterprise_id:)&.stripe_user_id end def raise_if_last_payment_error_present(payment_intent_response) diff --git a/lib/tasks/sample_data/addressing.rb b/lib/tasks/sample_data/addressing.rb index 96319f98a3..3db2753b71 100644 --- a/lib/tasks/sample_data/addressing.rb +++ b/lib/tasks/sample_data/addressing.rb @@ -10,8 +10,8 @@ module Addressing address1: parts[0], city: parts[1], zipcode: parts[2], - state: state, - country: country + state:, + country: ) end diff --git a/lib/tasks/sample_data/enterprise_factory.rb b/lib/tasks/sample_data/enterprise_factory.rb index 7a2055eed5..ef68cc93d3 100644 --- a/lib/tasks/sample_data/enterprise_factory.rb +++ b/lib/tasks/sample_data/enterprise_factory.rb @@ -14,7 +14,7 @@ module SampleData name = data[:name] log "- #{name}" data[:long_description] = data[:long_description].strip_heredoc.tr("\n", " ") - Enterprise.create_with(data).find_or_create_by!(name: name) + Enterprise.create_with(data).find_or_create_by!(name:) end end diff --git a/lib/tasks/sample_data/order_cycle_factory.rb b/lib/tasks/sample_data/order_cycle_factory.rb index 0f9dc258e8..13ca7fe62e 100644 --- a/lib/tasks/sample_data/order_cycle_factory.rb +++ b/lib/tasks/sample_data/order_cycle_factory.rb @@ -52,7 +52,7 @@ module SampleData def create_order_cycle(name, coordinator_name, supplier_names, distributor_names, data) coordinator = Enterprise.find_by(name: coordinator_name) - return if OrderCycle.active.where(name: name).exists? + return if OrderCycle.active.where(name:).exists? log "- #{name}" cycle = create_order_cycle_with_fee(name, coordinator) @@ -61,10 +61,10 @@ module SampleData def create_order_cycle_with_fee(name, coordinator) cycle = OrderCycle.create!( - name: name, + name:, orders_open_at: 1.day.ago, orders_close_at: 1.month.from_now, - coordinator: coordinator + coordinator: ) cycle.coordinator_fees << coordinator.enterprise_fees.first cycle diff --git a/lib/tasks/sample_data/payment_method_factory.rb b/lib/tasks/sample_data/payment_method_factory.rb index ba545b2d11..979075f19a 100644 --- a/lib/tasks/sample_data/payment_method_factory.rb +++ b/lib/tasks/sample_data/payment_method_factory.rb @@ -48,8 +48,8 @@ module SampleData def create_payment_method(provider_class, enterprise, name, description, calculator) payment_method = provider_class.new( - name: name, - description: description, + name:, + description:, environment: Rails.env, distributor_ids: [enterprise.id] ) diff --git a/lib/tasks/sample_data/user_factory.rb b/lib/tasks/sample_data/user_factory.rb index d7b0648871..445c3fd402 100644 --- a/lib/tasks/sample_data/user_factory.rb +++ b/lib/tasks/sample_data/user_factory.rb @@ -33,11 +33,11 @@ module SampleData password = Spree::User.friendly_token log "- #{email}" user = Spree::User.create_with( - password: password, + password:, password_confirmation: password, confirmation_sent_at: Time.zone.now, confirmed_at: Time.zone.now - ).find_or_create_by!(email: email) + ).find_or_create_by!(email:) [name, user] end end diff --git a/lib/tasks/subscriptions/debug.rake b/lib/tasks/subscriptions/debug.rake index 9ea8caa839..3b2e29d90a 100644 --- a/lib/tasks/subscriptions/debug.rake +++ b/lib/tasks/subscriptions/debug.rake @@ -22,7 +22,7 @@ namespace :ofn do puts "Last edited on #{subscription.updated_at}" puts "Canceled at #{subscription.canceled_at} and paused at #{subscription.paused_at}" - ProxyOrder.where(order_cycle_id: order_cycle_id, + ProxyOrder.where(order_cycle_id:, subscription_id: subscription.id).each do |proxy_order| puts puts "Proxy Order #{proxy_order.id}" diff --git a/lib/tasks/subscriptions/test.rake b/lib/tasks/subscriptions/test.rake index ae8d7b3061..ff6317b841 100644 --- a/lib/tasks/subscriptions/test.rake +++ b/lib/tasks/subscriptions/test.rake @@ -19,7 +19,7 @@ namespace :ofn do # Reset Proxy Orders of the Order Cycle # by detatching them from existing orders and resetting placed and confirmed dates - ProxyOrder.find_by(order_cycle_id: order_cycle_id)&.update!( + ProxyOrder.find_by(order_cycle_id:)&.update!( order_id: nil, confirmed_at: nil, placed_at: nil) diff --git a/spec/constraints/feature_toggle_constraint_spec.rb b/spec/constraints/feature_toggle_constraint_spec.rb index 858408821b..4c9e477d17 100644 --- a/spec/constraints/feature_toggle_constraint_spec.rb +++ b/spec/constraints/feature_toggle_constraint_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe FeatureToggleConstraint do subject { described_class.new("baking") } - let(:request) { double(env: env) } + let(:request) { double(env:) } let(:env) { {} } it "constraints an unknown feature" do