mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #11583 from macanudo527/fix_stylehash_10
Fix Style/HashSyntax 11/13
This commit is contained in:
@@ -875,36 +875,6 @@ Style/HashLikeCase:
|
||||
# SupportedShorthandSyntax: always, never, either, consistent
|
||||
Style/HashSyntax:
|
||||
Exclude:
|
||||
- 'spec/serializers/api/order_serializer_spec.rb'
|
||||
- 'spec/serializers/api/product_serializer_spec.rb'
|
||||
- 'spec/services/cap_quantity_spec.rb'
|
||||
- 'spec/services/cart_service_spec.rb'
|
||||
- 'spec/services/checkout/payment_method_fetcher_spec.rb'
|
||||
- 'spec/services/default_stock_location_spec.rb'
|
||||
- 'spec/services/invoice_data_generator_spec.rb'
|
||||
- 'spec/services/order_available_payment_methods_spec.rb'
|
||||
- 'spec/services/order_available_shipping_methods_spec.rb'
|
||||
- 'spec/services/order_cart_reset_spec.rb'
|
||||
- 'spec/services/order_checkout_restart_spec.rb'
|
||||
- 'spec/services/order_cycle_distributed_products_spec.rb'
|
||||
- 'spec/services/order_cycle_form_spec.rb'
|
||||
- 'spec/services/order_cycle_webhook_service_spec.rb'
|
||||
- 'spec/services/order_data_masker_spec.rb'
|
||||
- 'spec/services/order_factory_spec.rb'
|
||||
- 'spec/services/order_fees_handler_spec.rb'
|
||||
- 'spec/services/order_invoice_comparator_spec.rb'
|
||||
- 'spec/services/order_payment_finder_spec.rb'
|
||||
- 'spec/services/order_syncer_spec.rb'
|
||||
- 'spec/services/order_tax_adjustments_fetcher_spec.rb'
|
||||
- 'spec/services/order_workflow_spec.rb'
|
||||
- 'spec/services/paypal_items_builder_spec.rb'
|
||||
- 'spec/services/permissions/order_spec.rb'
|
||||
- 'spec/services/place_proxy_order_spec.rb'
|
||||
- 'spec/services/process_payment_intent_spec.rb'
|
||||
- 'spec/services/product_tag_rules_filterer_spec.rb'
|
||||
- 'spec/services/products_renderer_spec.rb'
|
||||
- 'spec/services/search_orders_spec.rb'
|
||||
- 'spec/services/sets/product_set_spec.rb'
|
||||
- 'spec/services/tax_rate_finder_spec.rb'
|
||||
- 'spec/services/user_default_address_setter_spec.rb'
|
||||
- 'spec/services/variants_stock_levels_spec.rb'
|
||||
|
||||
@@ -12,9 +12,9 @@ describe Api::OrderSerializer do
|
||||
|
||||
describe '#serializable_hash' do
|
||||
let!(:completed_payment) do
|
||||
create(:payment, :completed, order: order, amount: order.total - 1)
|
||||
create(:payment, :completed, order:, amount: order.total - 1)
|
||||
end
|
||||
let!(:payment) { create(:payment, order: order, state: 'checkout', amount: 123.45) }
|
||||
let!(:payment) { create(:payment, order:, state: 'checkout', amount: 123.45) }
|
||||
|
||||
it "serializes an order" do
|
||||
expect(serializer.serializable_hash[:number]).to eq(order.number)
|
||||
|
||||
@@ -12,7 +12,7 @@ describe Api::ProductSerializer do
|
||||
let!(:taxon) { create(:taxon) }
|
||||
let!(:property) { create(:property) }
|
||||
let!(:product) { create(:product, primary_taxon: taxon, properties: [property], price: 20.00) }
|
||||
let(:variant1) { create(:variant, product: product) }
|
||||
let(:variant1) { create(:variant, product:) }
|
||||
|
||||
let(:serializer) {
|
||||
described_class.new(product,
|
||||
|
||||
@@ -6,9 +6,9 @@ describe CapQuantity do
|
||||
describe "checking that line items are available to purchase" do
|
||||
let(:order_cycle) { create(:simple_order_cycle) }
|
||||
let(:shop) { order_cycle.coordinator }
|
||||
let(:order) { create(:order, order_cycle: order_cycle, distributor: shop) }
|
||||
let(:order) { create(:order, order_cycle:, distributor: shop) }
|
||||
let(:ex) {
|
||||
create(:exchange, order_cycle: order_cycle, sender: shop, receiver: shop, incoming: false)
|
||||
create(:exchange, order_cycle:, sender: shop, receiver: shop, incoming: false)
|
||||
}
|
||||
let(:variant1) { create(:variant, on_hand: 5) }
|
||||
let(:variant2) { create(:variant, on_hand: 5) }
|
||||
|
||||
@@ -15,7 +15,7 @@ describe CartService do
|
||||
end
|
||||
|
||||
context "end-to-end" do
|
||||
let(:order) { create(:order, distributor: distributor, order_cycle: order_cycle) }
|
||||
let(:order) { create(:order, distributor:, order_cycle:) }
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
let(:order_cycle) {
|
||||
create(:simple_order_cycle, distributors: [distributor],
|
||||
@@ -89,7 +89,7 @@ describe CartService do
|
||||
|
||||
describe "when the soft-deleted variant is already in the cart" do
|
||||
let!(:existing_line_item) {
|
||||
create(:line_item, variant: variant, quantity: 2, order: order)
|
||||
create(:line_item, variant:, quantity: 2, order:)
|
||||
}
|
||||
|
||||
it "removes the line_item from the cart" do
|
||||
@@ -181,7 +181,7 @@ describe CartService do
|
||||
and_return(true)
|
||||
expect(variant).to receive(:on_demand).and_return(false)
|
||||
expect(order).to receive_message_chain(:contents, :update_or_create).
|
||||
with(variant, { quantity: quantity, max_quantity: nil })
|
||||
with(variant, { quantity:, max_quantity: nil })
|
||||
|
||||
cart_service.send(:attempt_cart_add, variant, quantity)
|
||||
end
|
||||
@@ -280,7 +280,7 @@ describe CartService do
|
||||
|
||||
describe "checking variant is available under the distributor" do
|
||||
let(:product) { double(:product) }
|
||||
let(:variant) { double(:variant, product: product) }
|
||||
let(:variant) { double(:variant, product:) }
|
||||
let(:order_cycle_distributed_variants) { double(:order_cycle_distributed_variants) }
|
||||
|
||||
before do
|
||||
|
||||
@@ -4,8 +4,8 @@ require 'spec_helper'
|
||||
|
||||
describe Checkout::PaymentMethodFetcher do
|
||||
let!(:order) { create(:completed_order_with_totals) }
|
||||
let(:payment1) { build(:payment, order: order) }
|
||||
let(:payment2) { build(:payment, order: order) }
|
||||
let(:payment1) { build(:payment, order:) }
|
||||
let(:payment2) { build(:payment, order:) }
|
||||
let(:service) { Checkout::PaymentMethodFetcher.new(order) }
|
||||
|
||||
describe '#call' do
|
||||
|
||||
@@ -7,7 +7,7 @@ describe DefaultStockLocation do
|
||||
context 'when a location named default already exists' do
|
||||
let!(:location) do
|
||||
country = create(:country)
|
||||
state = Spree::State.create(name: 'Alabama', country: country)
|
||||
state = Spree::State.create(name: 'Alabama', country:)
|
||||
Spree::StockLocation.create!(
|
||||
name: 'default',
|
||||
country_id: country.id,
|
||||
|
||||
@@ -8,13 +8,13 @@ describe InvoiceDataGenerator do
|
||||
let!(:invoice_data_generator){ InvoiceDataGenerator.new(order) }
|
||||
let!(:latest_invoice){
|
||||
create(:invoice,
|
||||
order: order,
|
||||
order:,
|
||||
data: invoice_data_generator.serialize_for_invoice)
|
||||
}
|
||||
let(:new_invoice_data) {
|
||||
InvoiceDataGenerator.new(order).generate
|
||||
}
|
||||
let(:new_invoice) { create(:invoice, order: order, data: new_invoice_data) }
|
||||
let(:new_invoice) { create(:invoice, order:, data: new_invoice_data) }
|
||||
let(:new_invoice_presenter) { new_invoice.presenter }
|
||||
|
||||
context "mutable attribute updated" do
|
||||
|
||||
@@ -6,7 +6,7 @@ describe OrderAvailablePaymentMethods do
|
||||
context "when the order has no current_distributor" do
|
||||
it "returns an empty array" do
|
||||
order_cycle = create(:sells_own_order_cycle)
|
||||
order = build(:order, distributor: nil, order_cycle: order_cycle)
|
||||
order = build(:order, distributor: nil, order_cycle:)
|
||||
|
||||
expect(OrderAvailablePaymentMethods.new(order).to_a).to eq []
|
||||
end
|
||||
@@ -19,7 +19,7 @@ describe OrderAvailablePaymentMethods do
|
||||
distributors: [distributor],
|
||||
display_on: 'back_end')
|
||||
order_cycle = create(:sells_own_order_cycle)
|
||||
order = build(:order, distributor: distributor, order_cycle: order_cycle)
|
||||
order = build(:order, distributor:, order_cycle:)
|
||||
|
||||
available_payment_methods = OrderAvailablePaymentMethods.new(order).to_a
|
||||
|
||||
@@ -33,7 +33,7 @@ describe OrderAvailablePaymentMethods do
|
||||
distributors: [distributor],
|
||||
display_on: 'back_end')
|
||||
order_cycle = create(:sells_own_order_cycle)
|
||||
order = build(:order, distributor: distributor, order_cycle: order_cycle)
|
||||
order = build(:order, distributor:, order_cycle:)
|
||||
|
||||
available_payment_methods = OrderAvailablePaymentMethods.new(order).to_a
|
||||
|
||||
@@ -51,7 +51,7 @@ describe OrderAvailablePaymentMethods do
|
||||
payment_method_ii = create(:payment_method, distributors: [distributor_ii])
|
||||
payment_method_iii = create(:payment_method, distributors: [distributor_iii])
|
||||
order_cycle = create(:sells_own_order_cycle, distributors: [distributor_i, distributor_ii])
|
||||
order = build(:order, distributor: distributor_i, order_cycle: order_cycle)
|
||||
order = build(:order, distributor: distributor_i, order_cycle:)
|
||||
|
||||
available_payment_methods = OrderAvailablePaymentMethods.new(order).to_a
|
||||
|
||||
@@ -74,7 +74,7 @@ describe OrderAvailablePaymentMethods do
|
||||
distributor_i.distributor_payment_methods.first,
|
||||
distributor_ii.distributor_payment_methods.first,
|
||||
]
|
||||
order = build(:order, distributor: distributor_i, order_cycle: order_cycle)
|
||||
order = build(:order, distributor: distributor_i, order_cycle:)
|
||||
|
||||
available_payment_methods = OrderAvailablePaymentMethods.new(order).to_a
|
||||
|
||||
@@ -91,7 +91,7 @@ describe OrderAvailablePaymentMethods do
|
||||
let!(:other_distributor_payment_method) do
|
||||
create(:payment_method, distributors: [other_distributor])
|
||||
end
|
||||
let(:customer) { create(:customer, user: user, enterprise: distributor) }
|
||||
let(:customer) { create(:customer, user:, enterprise: distributor) }
|
||||
let!(:tag_rule) {
|
||||
create(:filter_payment_methods_tag_rule,
|
||||
enterprise: distributor,
|
||||
@@ -122,7 +122,7 @@ describe OrderAvailablePaymentMethods do
|
||||
}
|
||||
|
||||
let(:order_cycle) { create(:sells_own_order_cycle) }
|
||||
let(:order) { build(:order, distributor: distributor, order_cycle: order_cycle) }
|
||||
let(:order) { build(:order, distributor:, order_cycle:) }
|
||||
|
||||
context "when the customer is nil" do
|
||||
let(:available_payment_methods) { OrderAvailablePaymentMethods.new(order).to_a }
|
||||
@@ -172,7 +172,7 @@ describe OrderAvailablePaymentMethods do
|
||||
}
|
||||
|
||||
let(:order_cycle) { create(:sells_own_order_cycle) }
|
||||
let(:order) { build(:order, distributor: distributor, order_cycle: order_cycle) }
|
||||
let(:order) { build(:order, distributor:, order_cycle:) }
|
||||
|
||||
context "when the customer is nil" do
|
||||
let(:available_payment_methods) { OrderAvailablePaymentMethods.new(order).to_a }
|
||||
|
||||
@@ -6,7 +6,7 @@ describe OrderAvailableShippingMethods do
|
||||
context "when the order has no current_distributor" do
|
||||
it "returns an empty array" do
|
||||
order_cycle = create(:sells_own_order_cycle)
|
||||
order = build(:order, distributor: nil, order_cycle: order_cycle)
|
||||
order = build(:order, distributor: nil, order_cycle:)
|
||||
|
||||
expect(OrderAvailableShippingMethods.new(order).to_a).to eq []
|
||||
end
|
||||
@@ -18,7 +18,7 @@ describe OrderAvailableShippingMethods do
|
||||
backoffice_only_shipping_method = create(:shipping_method,
|
||||
distributors: [distributor], display_on: 'back_end')
|
||||
order_cycle = create(:sells_own_order_cycle)
|
||||
order = build(:order, distributor: distributor, order_cycle: order_cycle)
|
||||
order = build(:order, distributor:, order_cycle:)
|
||||
|
||||
available_shipping_methods = OrderAvailableShippingMethods.new(order).to_a
|
||||
|
||||
@@ -36,7 +36,7 @@ describe OrderAvailableShippingMethods do
|
||||
shipping_method_ii = create(:shipping_method, distributors: [distributor_ii])
|
||||
shipping_method_iii = create(:shipping_method, distributors: [distributor_iii])
|
||||
order_cycle = create(:sells_own_order_cycle, distributors: [distributor_i, distributor_ii])
|
||||
order = build(:order, distributor: distributor_i, order_cycle: order_cycle)
|
||||
order = build(:order, distributor: distributor_i, order_cycle:)
|
||||
|
||||
available_shipping_methods = OrderAvailableShippingMethods.new(order).to_a
|
||||
|
||||
@@ -59,7 +59,7 @@ describe OrderAvailableShippingMethods do
|
||||
distributor_i.distributor_shipping_methods.first,
|
||||
distributor_ii.distributor_shipping_methods.first,
|
||||
]
|
||||
order = build(:order, distributor: distributor_i, order_cycle: order_cycle)
|
||||
order = build(:order, distributor: distributor_i, order_cycle:)
|
||||
|
||||
available_shipping_methods = OrderAvailableShippingMethods.new(order).to_a
|
||||
|
||||
@@ -76,7 +76,7 @@ describe OrderAvailableShippingMethods do
|
||||
let!(:other_distributor_shipping_method) do
|
||||
create(:shipping_method, distributors: [other_distributor])
|
||||
end
|
||||
let(:customer) { create(:customer, user: user, enterprise: distributor) }
|
||||
let(:customer) { create(:customer, user:, enterprise: distributor) }
|
||||
let!(:tag_rule) {
|
||||
create(:filter_shipping_methods_tag_rule,
|
||||
enterprise: distributor,
|
||||
@@ -107,7 +107,7 @@ describe OrderAvailableShippingMethods do
|
||||
}
|
||||
|
||||
let(:order_cycle) { create(:sells_own_order_cycle) }
|
||||
let(:order) { build(:order, distributor: distributor, order_cycle: order_cycle) }
|
||||
let(:order) { build(:order, distributor:, order_cycle:) }
|
||||
|
||||
context "when the customer is nil" do
|
||||
let(:available_shipping_methods) { OrderAvailableShippingMethods.new(order).to_a }
|
||||
@@ -154,7 +154,7 @@ describe OrderAvailableShippingMethods do
|
||||
}
|
||||
|
||||
let(:order_cycle) { create(:sells_own_order_cycle) }
|
||||
let(:order) { build(:order, distributor: distributor, order_cycle: order_cycle) }
|
||||
let(:order) { build(:order, distributor:, order_cycle:) }
|
||||
|
||||
context "when the customer is nil" do
|
||||
let(:available_shipping_methods) { OrderAvailableShippingMethods.new(order).to_a }
|
||||
@@ -217,7 +217,7 @@ describe OrderAvailableShippingMethods do
|
||||
|
||||
context "when certain shipping categories are required" do
|
||||
subject { OrderAvailableShippingMethods.new(order) }
|
||||
let(:order) { build(:order, distributor: distributor, order_cycle: oc) }
|
||||
let(:order) { build(:order, distributor:, order_cycle: oc) }
|
||||
let(:oc) { create(:order_cycle) }
|
||||
let(:distributor) { oc.distributors.first }
|
||||
let(:standard_shipping) {
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'spec_helper'
|
||||
|
||||
describe OrderCartReset do
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
let(:order) { create(:order, :with_line_item, distributor: distributor) }
|
||||
let(:order) { create(:order, :with_line_item, distributor:) }
|
||||
|
||||
context "if order distributor is not the requested distributor" do
|
||||
let(:new_distributor) { create(:distributor_enterprise) }
|
||||
|
||||
@@ -15,9 +15,9 @@ describe OrderCheckoutRestart do
|
||||
|
||||
context "when the order is in a subsequent state" do
|
||||
# 'pending' is the only shipment state possible for incomplete orders
|
||||
let!(:shipment_pending) { create(:shipment, order: order, state: 'pending') }
|
||||
let!(:payment_failed) { create(:payment, order: order, state: 'failed') }
|
||||
let!(:payment_checkout) { create(:payment, order: order, state: 'checkout') }
|
||||
let!(:shipment_pending) { create(:shipment, order:, state: 'pending') }
|
||||
let!(:payment_failed) { create(:payment, order:, state: 'failed') }
|
||||
let!(:payment_checkout) { create(:payment, order:, state: 'checkout') }
|
||||
|
||||
before do
|
||||
order.update_attribute(:state, "payment")
|
||||
|
||||
@@ -62,7 +62,7 @@ describe OrderCycleDistributedProducts do
|
||||
|
||||
context "with variant overrides" do
|
||||
let!(:override) {
|
||||
create(:variant_override, hub: distributor, variant: variant, count_on_hand: 0)
|
||||
create(:variant_override, hub: distributor, variant:, count_on_hand: 0)
|
||||
}
|
||||
|
||||
it "does not return product when an override is out of stock" do
|
||||
@@ -85,9 +85,9 @@ describe OrderCycleDistributedProducts do
|
||||
let(:oc) { create(:simple_order_cycle, distributors: [distributor], variants: [v1, v3]) }
|
||||
let(:customer) { create(:customer) }
|
||||
let(:product) { create(:simple_product) }
|
||||
let!(:v1) { create(:variant, product: product) }
|
||||
let!(:v2) { create(:variant, product: product) }
|
||||
let!(:v3) { create(:variant, product: product) }
|
||||
let!(:v1) { create(:variant, product:) }
|
||||
let!(:v2) { create(:variant, product:) }
|
||||
let!(:v3) { create(:variant, product:) }
|
||||
let!(:vo) { create(:variant_override, hub: distributor, variant_id: v3.id, count_on_hand: 0) }
|
||||
let(:variants) { described_class.new(distributor, oc, customer).variants_relation }
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ describe OrderCycleForm do
|
||||
let(:shipping_method) { create(:shipping_method, distributors: [distributor]) }
|
||||
let(:distributor_payment_method) { payment_method.distributor_payment_methods.first }
|
||||
let(:distributor_shipping_method) { shipping_method.distributor_shipping_methods.first }
|
||||
let(:variant) { create(:variant, product: create(:product, supplier: supplier)) }
|
||||
let(:variant) { create(:variant, product: create(:product, supplier:)) }
|
||||
let(:params) { { name: 'Some new name' } }
|
||||
let(:form) { OrderCycleForm.new(order_cycle, params, user) }
|
||||
let(:outgoing_exchange_params) do
|
||||
|
||||
@@ -9,7 +9,7 @@ describe OrderCycleWebhookService do
|
||||
name: "Order cycle 1",
|
||||
orders_open_at: "2022-09-19 09:00:00".to_time,
|
||||
orders_close_at: "2022-09-19 17:00:00".to_time,
|
||||
coordinator: coordinator,
|
||||
coordinator:,
|
||||
)
|
||||
}
|
||||
let(:coordinator) { create :distributor_enterprise, name: "Starship Enterprise" }
|
||||
@@ -66,7 +66,7 @@ describe OrderCycleWebhookService do
|
||||
let(:order_cycle) {
|
||||
create(
|
||||
:simple_order_cycle,
|
||||
coordinator: coordinator,
|
||||
coordinator:,
|
||||
distributors: two_distributors,
|
||||
)
|
||||
}
|
||||
@@ -97,7 +97,7 @@ describe OrderCycleWebhookService do
|
||||
let(:order_cycle) {
|
||||
create(
|
||||
:simple_order_cycle,
|
||||
coordinator: coordinator,
|
||||
coordinator:,
|
||||
distributors: [create(:distributor_enterprise, owner: user)],
|
||||
)
|
||||
}
|
||||
@@ -116,7 +116,7 @@ describe OrderCycleWebhookService do
|
||||
let(:order_cycle) {
|
||||
create(
|
||||
:simple_order_cycle,
|
||||
coordinator: coordinator,
|
||||
coordinator:,
|
||||
suppliers: [supplier],
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ require 'spec_helper'
|
||||
describe OrderDataMasker do
|
||||
describe '#call' do
|
||||
let(:distributor) { create(:enterprise) }
|
||||
let(:order) { create(:order, distributor: distributor, ship_address: create(:address)) }
|
||||
let(:order) { create(:order, distributor:, ship_address: create(:address)) }
|
||||
|
||||
context 'when displaying customer names is allowed' do
|
||||
before { distributor.show_customer_names_to_suppliers = true }
|
||||
|
||||
@@ -6,7 +6,7 @@ describe OrderFactory do
|
||||
let(:variant1) { create(:variant, price: 5.0) }
|
||||
let(:variant2) { create(:variant, price: 7.0) }
|
||||
let(:user) { create(:user) }
|
||||
let(:customer) { create(:customer, user: user) }
|
||||
let(:customer) { create(:customer, user:) }
|
||||
let(:shop) { create(:distributor_enterprise) }
|
||||
let(:order_cycle) { create(:simple_order_cycle) }
|
||||
let!(:other_shipping_method_a) { create(:shipping_method) }
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'spec_helper'
|
||||
|
||||
describe OrderFeesHandler do
|
||||
let(:order_cycle) { create(:order_cycle) }
|
||||
let(:order) { create(:order_with_line_items, line_items_count: 1, order_cycle: order_cycle) }
|
||||
let(:order) { create(:order_with_line_items, line_items_count: 1, order_cycle:) }
|
||||
let(:line_item) { order.line_items.first }
|
||||
|
||||
let(:service) { OrderFeesHandler.new(order) }
|
||||
|
||||
@@ -9,7 +9,7 @@ describe OrderInvoiceComparator do
|
||||
let!(:invoice_data_generator){ InvoiceDataGenerator.new(order) }
|
||||
let!(:invoice){
|
||||
create(:invoice,
|
||||
order: order,
|
||||
order:,
|
||||
data: invoice_data_generator.serialize_for_invoice)
|
||||
}
|
||||
let(:subject) {
|
||||
@@ -137,7 +137,7 @@ describe OrderInvoiceComparator do
|
||||
let!(:invoice_data_generator){ InvoiceDataGenerator.new(order) }
|
||||
let!(:invoice){
|
||||
create(:invoice,
|
||||
order: order,
|
||||
order:,
|
||||
data: invoice_data_generator.serialize_for_invoice)
|
||||
}
|
||||
let(:subject) {
|
||||
|
||||
@@ -7,8 +7,8 @@ describe OrderPaymentFinder do
|
||||
let(:finder) { OrderPaymentFinder.new(order) }
|
||||
|
||||
context "when order has several non pending payments" do
|
||||
let!(:failed_payment) { create(:payment, order: order, state: 'failed') }
|
||||
let!(:complete_payment) { create(:payment, :completed, order: order) }
|
||||
let!(:failed_payment) { create(:payment, order:, state: 'failed') }
|
||||
let!(:complete_payment) { create(:payment, :completed, order:) }
|
||||
|
||||
it "#last_payment returns the last payment" do
|
||||
expect(finder.last_payment).to eq complete_payment
|
||||
@@ -20,8 +20,8 @@ describe OrderPaymentFinder do
|
||||
end
|
||||
|
||||
context "when order has a pending payment and a non pending payment" do
|
||||
let!(:processing_payment) { create(:payment, order: order, state: 'processing') }
|
||||
let!(:failed_payment) { create(:payment, order: order, state: 'failed') }
|
||||
let!(:processing_payment) { create(:payment, order:, state: 'processing') }
|
||||
let!(:failed_payment) { create(:payment, order:, state: 'failed') }
|
||||
|
||||
it "#last_payment returns the last payment" do
|
||||
expect(finder.last_payment).to eq failed_payment
|
||||
@@ -33,7 +33,7 @@ describe OrderPaymentFinder do
|
||||
end
|
||||
|
||||
context "and an extra last pending payment" do
|
||||
let!(:pending_payment) { create(:payment, order: order, state: 'pending') }
|
||||
let!(:pending_payment) { create(:payment, order:, state: 'pending') }
|
||||
|
||||
it "#last_payment returns the last payment" do
|
||||
expect(finder.last_payment).to eq pending_payment
|
||||
|
||||
@@ -150,7 +150,7 @@ describe OrderSyncer do
|
||||
let!(:distributor_address) { create(:address, :randomized) }
|
||||
let!(:distributor) { create(:distributor_enterprise, address: distributor_address) }
|
||||
let(:subscription) do
|
||||
create(:subscription, shop: distributor, shipping_method: shipping_method, with_items: true,
|
||||
create(:subscription, shop: distributor, shipping_method:, with_items: true,
|
||||
with_proxy_orders: true)
|
||||
end
|
||||
let!(:order) { subscription.proxy_orders.first.initialise_order! }
|
||||
@@ -258,7 +258,7 @@ describe OrderSyncer do
|
||||
let!(:distributor_address) { create(:address, :randomized) }
|
||||
let!(:distributor) { create(:distributor_enterprise, address: distributor_address) }
|
||||
let!(:subscription) do
|
||||
create(:subscription, shop: distributor, shipping_method: shipping_method, with_items: true,
|
||||
create(:subscription, shop: distributor, shipping_method:, with_items: true,
|
||||
with_proxy_orders: true)
|
||||
end
|
||||
let!(:order) { subscription.proxy_orders.first.initialise_order! }
|
||||
@@ -307,7 +307,7 @@ describe OrderSyncer do
|
||||
let(:subscription) do
|
||||
create(:subscription, shop: distributor, bill_address: original_bill_address,
|
||||
ship_address: original_ship_address,
|
||||
shipping_method: shipping_method, with_items: true,
|
||||
shipping_method:, with_items: true,
|
||||
with_proxy_orders: true)
|
||||
end
|
||||
|
||||
|
||||
@@ -11,31 +11,31 @@ describe OrderTaxAdjustmentsFetcher do
|
||||
create(:tax_rate, included_in_price: true,
|
||||
calculator: Calculator::DefaultTax.new,
|
||||
amount: 0.1,
|
||||
zone: zone)
|
||||
zone:)
|
||||
end
|
||||
let(:tax_rate15) do
|
||||
create(:tax_rate, included_in_price: true,
|
||||
calculator: Calculator::DefaultTax.new,
|
||||
amount: 0.15,
|
||||
zone: zone)
|
||||
zone:)
|
||||
end
|
||||
let(:tax_rate20) do
|
||||
create(:tax_rate, included_in_price: true,
|
||||
calculator: Calculator::DefaultTax.new,
|
||||
amount: 0.2,
|
||||
zone: zone)
|
||||
zone:)
|
||||
end
|
||||
let(:tax_rate25) do
|
||||
create(:tax_rate, included_in_price: true,
|
||||
calculator: Calculator::DefaultTax.new,
|
||||
amount: 0.25,
|
||||
zone: zone)
|
||||
zone:)
|
||||
end
|
||||
let(:tax_rate30) do
|
||||
create(:tax_rate, included_in_price: false,
|
||||
calculator: Calculator::DefaultTax.new,
|
||||
amount: 0.30,
|
||||
zone: zone)
|
||||
zone:)
|
||||
end
|
||||
let(:tax_category10) { create(:tax_category, tax_rates: [tax_rate10]) }
|
||||
let(:tax_category15) { create(:tax_category, tax_rates: [tax_rate15]) }
|
||||
@@ -50,26 +50,26 @@ describe OrderTaxAdjustmentsFetcher do
|
||||
calculator: Calculator::FlatRate.new(preferred_amount: 48.0))
|
||||
end
|
||||
let(:admin_adjustment) do
|
||||
create(:adjustment, order: order, amount: 50.0, tax_category: tax_category25,
|
||||
create(:adjustment, order:, amount: 50.0, tax_category: tax_category25,
|
||||
label: "Admin Adjustment").tap do |adjustment|
|
||||
Spree::TaxRate.adjust(order, [adjustment])
|
||||
end
|
||||
end
|
||||
|
||||
let(:order_cycle) do
|
||||
create(:simple_order_cycle, coordinator: coordinator,
|
||||
create(:simple_order_cycle, coordinator:,
|
||||
coordinator_fees: [enterprise_fee],
|
||||
distributors: [coordinator],
|
||||
variants: [variant])
|
||||
end
|
||||
let(:line_item1) { create(:line_item, variant: variant, price: 44.0) }
|
||||
let(:line_item2) { create(:line_item, variant: variant, price: 44.0) }
|
||||
let(:line_item1) { create(:line_item, variant:, price: 44.0) }
|
||||
let(:line_item2) { create(:line_item, variant:, price: 44.0) }
|
||||
let(:order) do
|
||||
create(
|
||||
:order,
|
||||
line_items: [line_item1, line_item2],
|
||||
bill_address: create(:address),
|
||||
order_cycle: order_cycle,
|
||||
order_cycle:,
|
||||
distributor: coordinator,
|
||||
state: 'payment'
|
||||
)
|
||||
@@ -79,10 +79,10 @@ describe OrderTaxAdjustmentsFetcher do
|
||||
tax_category: tax_category15)
|
||||
end
|
||||
let!(:shipment) do
|
||||
create(:shipment_with, :shipping_method, shipping_method: shipping_method, order: order)
|
||||
create(:shipment_with, :shipping_method, shipping_method:, order:)
|
||||
end
|
||||
let(:legacy_tax_adjustment) do
|
||||
create(:adjustment, order: order, adjustable: order, amount: 1.23, originator: tax_rate30,
|
||||
create(:adjustment, order:, adjustable: order, amount: 1.23, originator: tax_rate30,
|
||||
label: "Additional Tax Adjustment", state: "closed")
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ require "spec_helper"
|
||||
describe OrderWorkflow do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
let!(:order) do
|
||||
create(:order_with_totals_and_distribution, distributor: distributor,
|
||||
create(:order_with_totals_and_distribution, distributor:,
|
||||
bill_address: create(:address),
|
||||
ship_address: create(:address),
|
||||
payments: [create(:payment)])
|
||||
@@ -47,7 +47,7 @@ describe OrderWorkflow do
|
||||
|
||||
context "when order cannot advance to the next state" do
|
||||
let!(:order) do
|
||||
create(:order, distributor: distributor)
|
||||
create(:order, distributor:)
|
||||
end
|
||||
|
||||
it "raises error" do
|
||||
|
||||
@@ -20,40 +20,40 @@ describe PaypalItemsBuilder do
|
||||
|
||||
context "listing adjustments" do
|
||||
let!(:admin_adjustment) {
|
||||
create(:adjustment, label: "Admin Adjustment", order: order, adjustable: order,
|
||||
create(:adjustment, label: "Admin Adjustment", order:, adjustable: order,
|
||||
amount: 12, originator: nil, state: "closed")
|
||||
}
|
||||
let!(:ineligible_adjustment) {
|
||||
create(:adjustment, label: "Ineligible Adjustment", order: order, adjustable: order,
|
||||
create(:adjustment, label: "Ineligible Adjustment", order:, adjustable: order,
|
||||
amount: 34, eligible: false, state: "closed",
|
||||
originator_type: "Spree::PaymentMethod")
|
||||
}
|
||||
let!(:zone) { create(:zone_with_member) }
|
||||
let!(:included_tax_rate) {
|
||||
create(:tax_rate, amount: 12, included_in_price: true, zone: zone,
|
||||
create(:tax_rate, amount: 12, included_in_price: true, zone:,
|
||||
calculator: ::Calculator::DefaultTax.new)
|
||||
}
|
||||
let!(:additional_tax_rate) {
|
||||
create(:tax_rate, amount: 34, included_in_price: false, zone: zone,
|
||||
create(:tax_rate, amount: 34, included_in_price: false, zone:,
|
||||
calculator: ::Calculator::DefaultTax.new)
|
||||
}
|
||||
let!(:included_tax_adjustment) {
|
||||
create(:adjustment, label: "Included Tax Adjustment", order: order,
|
||||
create(:adjustment, label: "Included Tax Adjustment", order:,
|
||||
adjustable: order.line_items.first, amount: 56,
|
||||
originator: included_tax_rate, included: true, state: "closed")
|
||||
}
|
||||
let!(:additional_tax_adjustment) {
|
||||
create(:adjustment, label: "Additional Tax Adjustment", order: order,
|
||||
create(:adjustment, label: "Additional Tax Adjustment", order:,
|
||||
adjustable: order.shipment, amount: 78, originator: additional_tax_rate,
|
||||
state: "closed")
|
||||
}
|
||||
let!(:enterprise_fee) { create(:enterprise_fee) }
|
||||
let!(:line_item_enterprise_fee) {
|
||||
create(:adjustment, label: "Line Item Fee", order: order, adjustable: order.line_items.first,
|
||||
create(:adjustment, label: "Line Item Fee", order:, adjustable: order.line_items.first,
|
||||
amount: 91, originator: enterprise_fee, state: "closed")
|
||||
}
|
||||
let!(:order_enterprise_fee) {
|
||||
create(:adjustment, label: "Order Fee", order: order, adjustable: order,
|
||||
create(:adjustment, label: "Order Fee", order:, adjustable: order,
|
||||
amount: 23, originator: enterprise_fee, state: "closed")
|
||||
}
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@ module Permissions
|
||||
let(:distributor) { create(:distributor_enterprise) }
|
||||
let(:coordinator) { create(:distributor_enterprise) }
|
||||
let(:order_cycle) {
|
||||
create(:simple_order_cycle, coordinator: coordinator, distributors: [distributor])
|
||||
create(:simple_order_cycle, coordinator:, distributors: [distributor])
|
||||
}
|
||||
let(:order_completed) {
|
||||
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor )
|
||||
create(:completed_order_with_totals, order_cycle:, distributor: )
|
||||
}
|
||||
let(:order_cancelled) {
|
||||
create(:order, order_cycle: order_cycle, distributor: distributor, state: 'canceled' )
|
||||
create(:order, order_cycle:, distributor:, state: 'canceled' )
|
||||
}
|
||||
let(:order_cart) {
|
||||
create(:order, order_cycle: order_cycle, distributor: distributor, state: 'cart' )
|
||||
create(:order, order_cycle:, distributor:, state: 'cart' )
|
||||
}
|
||||
let(:order_from_last_year) {
|
||||
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor,
|
||||
create(:completed_order_with_totals, order_cycle:, distributor:,
|
||||
completed_at: 1.year.ago)
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ module Permissions
|
||||
|
||||
describe "finding orders that are visible in reports" do
|
||||
let(:random_enterprise) { create(:distributor_enterprise) }
|
||||
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor ) }
|
||||
let!(:line_item) { create(:line_item, order: order) }
|
||||
let(:order) { create(:order, order_cycle:, distributor: ) }
|
||||
let!(:line_item) { create(:line_item, order:) }
|
||||
let!(:producer) { create(:supplier_enterprise) }
|
||||
|
||||
before do
|
||||
@@ -120,9 +120,9 @@ module Permissions
|
||||
|
||||
describe "finding line items that are visible in reports" do
|
||||
let(:random_enterprise) { create(:distributor_enterprise) }
|
||||
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor ) }
|
||||
let!(:line_item1) { create(:line_item, order: order) }
|
||||
let!(:line_item2) { create(:line_item, order: order) }
|
||||
let(:order) { create(:order, order_cycle:, distributor: ) }
|
||||
let!(:line_item1) { create(:line_item, order:) }
|
||||
let!(:line_item2) { create(:line_item, order:) }
|
||||
let!(:producer) { create(:supplier_enterprise) }
|
||||
|
||||
before do
|
||||
|
||||
@@ -7,7 +7,7 @@ describe PlaceProxyOrder do
|
||||
|
||||
subject { described_class.new(proxy_order, summarizer, logger, stock_changes_loader) }
|
||||
|
||||
let(:proxy_order) { create(:proxy_order, order: order) }
|
||||
let(:proxy_order) { create(:proxy_order, order:) }
|
||||
let(:order) { build(:order, distributor: build(:enterprise)) }
|
||||
let(:summarizer) { OrderManagement::Subscriptions::Summarizer.new }
|
||||
let(:logger) { instance_double(JobLogger.logger.class, info: true) }
|
||||
@@ -16,7 +16,7 @@ describe PlaceProxyOrder do
|
||||
|
||||
describe "#call" do
|
||||
let!(:subscription) { create(:subscription, with_items: true) }
|
||||
let!(:proxy_order) { create(:proxy_order, subscription: subscription, order: order) }
|
||||
let!(:proxy_order) { create(:proxy_order, subscription:, order:) }
|
||||
|
||||
let(:changes) { {} }
|
||||
let(:stock_changes_loader) { instance_double(CapQuantity) }
|
||||
@@ -47,7 +47,7 @@ describe PlaceProxyOrder do
|
||||
instance_double(OrderManagement::Subscriptions::Summarizer, record_order: true)
|
||||
}
|
||||
|
||||
let!(:proxy_order) { create(:proxy_order, subscription: subscription) }
|
||||
let!(:proxy_order) { create(:proxy_order, subscription:) }
|
||||
let(:order) { proxy_order.order }
|
||||
|
||||
before do
|
||||
@@ -68,9 +68,9 @@ describe PlaceProxyOrder do
|
||||
let(:shop) { create(:distributor_enterprise) }
|
||||
let(:shipping_method) { create(:shipping_method, distributors: [shop]) }
|
||||
let!(:subscription) do
|
||||
create(:subscription, shop: shop, shipping_method: shipping_method, with_items: true)
|
||||
create(:subscription, shop:, shipping_method:, with_items: true)
|
||||
end
|
||||
let(:proxy_order) { create(:proxy_order, subscription: subscription) }
|
||||
let(:proxy_order) { create(:proxy_order, subscription:) }
|
||||
|
||||
before do
|
||||
proxy_order.order_cycle.orders_close_at = 1.day.ago
|
||||
|
||||
@@ -8,7 +8,7 @@ describe ProcessPaymentIntent do
|
||||
describe "processing a payment intent" do
|
||||
let(:customer) { create(:customer) }
|
||||
let(:order) {
|
||||
create(:order_with_totals, customer: customer, distributor: customer.enterprise,
|
||||
create(:order_with_totals, customer:, distributor: customer.enterprise,
|
||||
state: "confirmation")
|
||||
}
|
||||
let(:payment_method) { create(:stripe_sca_payment_method) }
|
||||
@@ -16,10 +16,10 @@ describe ProcessPaymentIntent do
|
||||
let!(:payment) {
|
||||
create(
|
||||
:payment,
|
||||
payment_method: payment_method,
|
||||
payment_method:,
|
||||
cvv_response_message: "https://stripe.com/redirect",
|
||||
response_code: "pi_123",
|
||||
order: order,
|
||||
order:,
|
||||
state: "requires_authorization"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ describe ProductTagRulesFilterer do
|
||||
describe "filtering by tag rules" do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
let(:product) { create(:product, supplier: distributor) }
|
||||
let(:v1) { create(:variant, product: product) }
|
||||
let(:v2) { create(:variant, product: product) }
|
||||
let(:v3) { create(:variant, product: product) }
|
||||
let(:v4) { create(:variant, product: product) }
|
||||
let(:v1) { create(:variant, product:) }
|
||||
let(:v2) { create(:variant, product:) }
|
||||
let(:v3) { create(:variant, product:) }
|
||||
let(:v4) { create(:variant, product:) }
|
||||
let(:variant_hidden_by_default) { create(:variant_override, variant: v1, hub: distributor) }
|
||||
let(:variant_hidden_by_rule) { create(:variant_override, variant: v2, hub: distributor) }
|
||||
let(:variant_shown_by_rule) { create(:variant_override, variant: v3, hub: distributor) }
|
||||
|
||||
@@ -169,7 +169,7 @@ describe ProductsRenderer do
|
||||
end
|
||||
|
||||
it "loads tag_list for variants" do
|
||||
VariantOverride.create(variant: variant, hub: distributor, tag_list: 'lalala')
|
||||
VariantOverride.create(variant:, hub: distributor, tag_list: 'lalala')
|
||||
expect(products_renderer.products_json).to include "[\"lalala\"]"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,12 +4,12 @@ require 'spec_helper'
|
||||
|
||||
describe SearchOrders do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
let!(:order1) { create(:order_with_line_items, distributor: distributor, line_items_count: 3) }
|
||||
let!(:order2) { create(:order_with_line_items, distributor: distributor, line_items_count: 2) }
|
||||
let!(:order3) { create(:order_with_line_items, distributor: distributor, line_items_count: 1) }
|
||||
let!(:order_empty) { create(:order, distributor: distributor) }
|
||||
let!(:order_empty_but_complete) { create(:order, distributor: distributor, state: :complete) }
|
||||
let!(:order_empty_but_canceled) { create(:order, distributor: distributor, state: :canceled) }
|
||||
let!(:order1) { create(:order_with_line_items, distributor:, line_items_count: 3) }
|
||||
let!(:order2) { create(:order_with_line_items, distributor:, line_items_count: 2) }
|
||||
let!(:order3) { create(:order_with_line_items, distributor:, line_items_count: 1) }
|
||||
let!(:order_empty) { create(:order, distributor:) }
|
||||
let!(:order_empty_but_complete) { create(:order, distributor:, state: :complete) }
|
||||
let!(:order_empty_but_canceled) { create(:order, distributor:, state: :canceled) }
|
||||
|
||||
let(:enterprise_user) { distributor.owner }
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ describe Sets::ProductSet do
|
||||
end
|
||||
|
||||
context 'and the variant does exist' do
|
||||
let!(:variant) { create(:variant, product: product) }
|
||||
let!(:variant) { create(:variant, product:) }
|
||||
|
||||
before { master_attributes[:id] = variant.id }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user