Fix Style/HashSyntax

This commit is contained in:
Neal Chambers
2023-09-14 11:04:59 +09:00
parent 7ef4df0087
commit bf9db13bb3
30 changed files with 56 additions and 56 deletions

View File

@@ -10,7 +10,7 @@ class AddressGeocoder
return unless latitude.present? && longitude.present?
address.update(latitude: latitude, longitude: longitude)
address.update(latitude:, longitude:)
end
private

View File

@@ -18,7 +18,7 @@ class CustomerSyncer
return unless email && customer && email != customer.email
duplicate = Customer.find_by(email: email, enterprise: order.distributor)
duplicate = Customer.find_by(email:, enterprise: order.distributor)
if duplicate.present?
Spree::Order.where(customer_id: duplicate.id).update_all(customer_id: customer.id)
@@ -27,7 +27,7 @@ class CustomerSyncer
duplicate.destroy
end
customer.update(email: email)
customer.update(email:)
end
def self.create_customer(order)

View File

@@ -27,7 +27,7 @@ class ExchangeVariantBulkUpdater
return if variant_ids.blank?
new_exchange_variants = variant_ids.map do |variant_id|
ExchangeVariant.new(exchange_id: @exchange.id, variant_id: variant_id)
ExchangeVariant.new(exchange_id: @exchange.id, variant_id:)
end
ExchangeVariant.import!(new_exchange_variants)
end

View File

@@ -7,7 +7,7 @@ class ImageImporter
filename = File.basename(valid_url.path)
Spree::Image.create(
attachment: { io: file, filename: filename },
attachment: { io: file, filename: },
viewable_id: product.id,
viewable_type: Spree::Product,
)

View File

@@ -28,10 +28,10 @@ class OrderCycleWarning
if distributors.count > 1
I18n.t(:active_distributors_not_ready_for_checkout_message_plural,
distributor_names: distributor_names)
distributor_names:)
else
I18n.t(:active_distributors_not_ready_for_checkout_message_singular,
distributor_names: distributor_names)
distributor_names:)
end
end
end

View File

@@ -65,7 +65,7 @@ class OrderInvoiceComparator
def current_state_invoice
@current_state_invoice ||= Invoice.new(
order: order,
order:,
data: serialize_for_invoice,
date: Time.zone.today,
number: invoices.count + 1

View File

@@ -13,7 +13,7 @@ class OrderSyncer
def sync!
orders_in_order_cycles_not_closed.all? do |order|
order.assign_attributes(customer_id: customer_id, email: customer&.email,
order.assign_attributes(customer_id:, email: customer&.email,
distributor_id: shop_id)
update_associations_for(order)
line_item_syncer.sync!(order)
@@ -60,9 +60,9 @@ class OrderSyncer
with_state('checkout').where(payment_method_id: payment_method_id_was).last
if payment
payment&.void_transaction!
order.payments.create(payment_method_id: payment_method_id, amount: order.reload.total)
order.payments.create(payment_method_id:, amount: order.reload.total)
else
unless order.payments.with_state('checkout').where(payment_method_id: payment_method_id).any?
unless order.payments.with_state('checkout').where(payment_method_id:).any?
order_update_issues.add(order, I18n.t('admin.payment_method'))
end
end

View File

@@ -23,7 +23,7 @@ class ProductsRenderer
current_order_cycle: order_cycle,
current_distributor: distributor,
variants: variants_for_shop_by_id,
enterprise_fee_calculator: enterprise_fee_calculator).to_json
enterprise_fee_calculator:).to_json
end
private

View File

@@ -9,7 +9,7 @@ class RecurringPayments
Stripe::CreditCardCloner.new(card, stripe_account).find_or_clone
setup_intent = Stripe::SetupIntent.create(
{ payment_method: payment_method_id, customer: customer_id },
stripe_account: stripe_account
stripe_account:
)
setup_intent.client_secret
end

View File

@@ -9,7 +9,7 @@ module Shop
def self.ready_for_checkout_for(distributor, customer)
new(distributor, customer).call.select do |order_cycle|
order = Spree::Order.new(distributor: distributor, order_cycle: order_cycle)
order = Spree::Order.new(distributor:, order_cycle:)
OrderAvailablePaymentMethods.new(order, customer).to_a.any? &&
OrderAvailableShippingMethods.new(order, customer).to_a.any?
end

View File

@@ -76,8 +76,8 @@ class VoucherAdjustmentsService
return unless amount != adjustment.amount || included_tax != 0
adjustment.update_columns(
amount: amount,
included_tax: included_tax,
amount:,
included_tax:,
updated_at: Time.zone.now
)
end

View File

@@ -9,7 +9,7 @@ class DfcBuilder
product = SuppliedProductBuilder.supplied_product(variant)
DataFoodConsortium::Connector::CatalogItem.new(
id, product: product,
id, product:,
sku: variant.sku,
stockLimitation: stock_limitation(variant),
offers: [offer(variant)],

View File

@@ -4,7 +4,7 @@ require_relative "../spec_helper"
describe QuantitativeValueBuilder do
subject(:builder) { described_class }
let(:variant) { build(:variant, product: product) }
let(:variant) { build(:variant, product:) }
let(:product) { build(:product, name: "Apple") }
describe ".quantity" do

View File

@@ -2,7 +2,7 @@
module AuthorizationHelper
def auth_header(email)
token = allow_token_for(email: email)
token = allow_token_for(email:)
{ "Authorization" => "JWT #{token}" }
end

View File

@@ -17,7 +17,7 @@ module OrderManagement
shipping_methods.each do |shipping_method|
cost = calculate_cost(shipping_method, package)
shipping_rates << shipping_method.shipping_rates.new(cost: cost) unless cost.nil?
shipping_rates << shipping_method.shipping_rates.new(cost:) unless cost.nil?
end
shipping_rates.sort_by! { |r| r.cost || 0 }

View File

@@ -40,7 +40,7 @@ module OrderManagement
uninitialised_order_cycle_ids.each do |order_cycle_id|
Rails.logger.info "Initializing Proxy Order " \
"of subscription #{@subscription.id} in order cycle #{order_cycle_id}"
proxy_orders << ProxyOrder.new(subscription: subscription, order_cycle_id: order_cycle_id)
proxy_orders << ProxyOrder.new(subscription:, order_cycle_id:)
end
end

View File

@@ -116,7 +116,7 @@ module OrderManagement
return if available_variant_ids.include? variant.id
name = "#{variant.product.name} - #{variant.full_name}"
errors.add(:subscription_line_items, :not_available, name: name)
errors.add(:subscription_line_items, :not_available, name:)
end
def available_variant_ids

View File

@@ -10,7 +10,7 @@ module OrderManagement
context "updating order totals" do
before do
2.times { create(:line_item, order: order, price: 10) }
2.times { create(:line_item, order:, price: 10) }
end
it "updates payment totals" do
@@ -151,7 +151,7 @@ module OrderManagement
end
context "when the order has a payment that requires authorization" do
let!(:payment) { create(:payment, order: order, state: "requires_authorization") }
let!(:payment) { create(:payment, order:, state: "requires_authorization") }
it "returns requires_authorization" do
expect {
@@ -161,8 +161,8 @@ module OrderManagement
end
context "when order has a payment that requires authorization and a completed payment" do
let!(:payment) { create(:payment, order: order, state: "requires_authorization") }
let!(:completed_payment) { create(:payment, :completed, order: order) }
let!(:payment) { create(:payment, order:, state: "requires_authorization") }
let!(:completed_payment) { create(:payment, :completed, order:) }
it "returns paid" do
updater.update_payment_state
@@ -282,7 +282,7 @@ module OrderManagement
context '#shipping_address_from_distributor' do
let(:distributor) { build(:distributor_enterprise) }
let(:shipment) {
create(:shipment_with, :shipping_method, shipping_method: shipping_method)
create(:shipment_with, :shipping_method, shipping_method:)
}
before do
@@ -337,7 +337,7 @@ module OrderManagement
context "and 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,
originator_type: "Spree::TaxRate")
}

View File

@@ -9,7 +9,7 @@ module OrderManagement
let(:variant) { build(:variant, weight: 25.0) }
let(:stock_location) { build(:stock_location) }
let(:distributor) { create(:enterprise) }
let(:order) { build(:order, distributor: distributor) }
let(:order) { build(:order, distributor:) }
subject { Package.new(stock_location, order) }
@@ -91,7 +91,7 @@ module OrderManagement
shipping_method = build(:shipping_method)
subject.shipping_rates = [
Spree::ShippingRate.new(shipping_method: shipping_method, cost: 10.00, selected: true)
Spree::ShippingRate.new(shipping_method:, cost: 10.00, selected: true)
]
shipment = subject.to_shipment

View File

@@ -6,7 +6,7 @@ module OrderManagement
module Stock
describe Packer do
let(:distributor) { create(:distributor_enterprise) }
let(:order) { create(:order_with_line_items, line_items_count: 5, distributor: distributor) }
let(:order) { create(:order_with_line_items, line_items_count: 5, distributor:) }
let(:stock_location) { create(:stock_location) }
subject { Packer.new(stock_location, order) }
@@ -34,7 +34,7 @@ module OrderManagement
variant.on_demand = false
variant.save
expect {
create(:variant_override, variant: variant, hub: distributor, count_on_hand: 10)
create(:variant_override, variant:, hub: distributor, count_on_hand: 10)
}.to change {
subject.package.on_hand.size
}.from(4).to(5)

View File

@@ -81,8 +81,8 @@ module OrderManagement
describe "updating estimates for shipping and payment fees" do
let(:subscription) {
create(:subscription, with_items: true,
payment_method: payment_method,
shipping_method: shipping_method)
payment_method:,
shipping_method:)
}
let!(:sli1) { subscription.subscription_line_items.first }
let!(:sli2) { subscription.subscription_line_items.second }

View File

@@ -48,8 +48,8 @@ module OrderManagement
end
context "when more that one payment exists on the order" do
let!(:payment1) { create(:payment, order: order) }
let!(:payment2) { create(:payment, order: order) }
let!(:payment1) { create(:payment, order:) }
let!(:payment2) { create(:payment, order:) }
before do
allow(order).to receive(:new_outstanding_balance) { 7 }

View File

@@ -62,7 +62,7 @@ module OrderManagement
:subscription,
begins_at: now + 1.minute,
ends_at: now + 2.minutes,
schedule: schedule
schedule:
)
end
@@ -140,7 +140,7 @@ module OrderManagement
before { expect(subscription.save!).to be true }
context "when a proxy order exists" do
let!(:proxy_order) { create(:proxy_order, subscription: subscription, order_cycle: oc) }
let!(:proxy_order) { create(:proxy_order, subscription:, order_cycle: oc) }
context "for an oc included in the relevant schedule" do
context "and the proxy order has already been placed" do
@@ -228,7 +228,7 @@ module OrderManagement
:subscription,
begins_at: now + 1.minute,
ends_at: now + 2.minutes,
schedule: schedule
schedule:
)
end
@@ -284,7 +284,7 @@ module OrderManagement
context "for an oc not included in the relevant schedule" do
let!(:proxy_order) {
create(:proxy_order, subscription: subscription, order_cycle: open_oc)
create(:proxy_order, subscription:, order_cycle: open_oc)
}
before do
open_oc.schedule_ids = []
@@ -412,7 +412,7 @@ module OrderManagement
:subscription,
begins_at: now + 1.minute,
ends_at: now + 2.minutes,
schedule: schedule
schedule:
)
end
let(:syncer) { ProxyOrderSyncer.new(subscription) }

View File

@@ -20,7 +20,7 @@ module OrderManagement
end
context "when a payment is present" do
let(:payment) { create(:payment, payment_method: payment_method, amount: 10) }
let(:payment) { create(:payment, payment_method:, amount: 10) }
before { allow(order).to receive(:pending_payments).once { [payment] } }

View File

@@ -6,10 +6,10 @@ module OrderManagement
module Subscriptions
describe Validator do
let(:owner) { create(:user) }
let(:shop) { create(:enterprise, name: "Shop", owner: owner) }
let(:shop) { create(:enterprise, name: "Shop", owner:) }
describe "delegation" do
let(:subscription) { create(:subscription, shop: shop) }
let(:subscription) { create(:subscription, shop:) }
let(:validator) { Validator.new(subscription) }
it "delegates to subscription" do
@@ -28,7 +28,7 @@ module OrderManagement
describe "validations" do
let(:subscription_stubs) do
{
shop: shop,
shop:,
customer: true,
schedule: true,
shipping_method: true,

View File

@@ -12,9 +12,9 @@ module OrderManagement
let!(:variant) { product.variants.first }
let!(:schedule) { create(:schedule, order_cycles: [order_cycle]) }
let!(:subscription) { create(:subscription, shop: shop, schedule: schedule) }
let!(:subscription) { create(:subscription, shop:, schedule:) }
let!(:subscription_line_item) do
create(:subscription_line_item, subscription: subscription, variant: variant)
create(:subscription_line_item, subscription:, variant:)
end
let(:current_order_cycle) do

View File

@@ -4,9 +4,9 @@ module Web
module CookiesPolicyHelper
def render_cookie_entry(cookie_name, cookie_desc, cookie_domain = nil)
render partial: 'cookies_policy_entry',
locals: { cookie_name: cookie_name,
cookie_desc: cookie_desc,
cookie_domain: cookie_domain }
locals: { cookie_name:,
cookie_desc:,
cookie_domain: }
end
def matomo_iframe_src

View File

@@ -14,14 +14,14 @@ module Web
end
def destroy
cookies.delete(COOKIE_NAME, domain: domain)
cookies.delete(COOKIE_NAME, domain:)
end
def set
cookies[COOKIE_NAME] = {
value: COOKIE_NAME,
expires: 1.year.from_now,
domain: domain,
domain:,
httponly: true
}
end

View File

@@ -77,7 +77,7 @@ module OpenFoodNetwork
return nil unless allow_search_by_email?
Spree::Order.joins(:bill_address).order('id DESC')
.complete.where(email: email)
.complete.where(email:)
.first&.bill_address
end
@@ -85,7 +85,7 @@ module OpenFoodNetwork
return nil unless allow_search_by_email?
Spree::Order.complete.joins(:ship_address, shipments: :shipping_methods).order('id DESC')
.where(email: email, spree_shipping_methods: { require_ship_address: true })
.where(email:, spree_shipping_methods: { require_ship_address: true })
.first&.ship_address
end

View File

@@ -17,7 +17,7 @@ module OpenFoodNetwork
label, adjustable, true, "closed", tax_category(adjustable)
)
AdjustmentMetadata.create! adjustment: adjustment, enterprise: enterprise_fee.enterprise,
AdjustmentMetadata.create! adjustment:, enterprise: enterprise_fee.enterprise,
fee_name: enterprise_fee.name, fee_type: enterprise_fee.fee_type,
enterprise_role: role
end
@@ -31,7 +31,7 @@ module OpenFoodNetwork
end
def base_adjustment_label
I18n.t(:enterprise_fee_by_name, name: enterprise_fee.name, role: role,
I18n.t(:enterprise_fee_by_name, name: enterprise_fee.name, role:,
enterprise_name: enterprise_fee.enterprise.name)
end