Fix Style/HashSyntax

This commit is contained in:
Neal Chambers
2023-09-26 09:48:05 +09:00
parent dd0279c983
commit 57d2f04330
30 changed files with 160 additions and 160 deletions

View File

@@ -6,19 +6,19 @@ describe TaxRateFinder do
describe "getting the corresponding tax rate" do
let(:amount) { BigDecimal(120) }
let(:tax_rate) {
create(:tax_rate, amount: 0.2, calculator: Calculator::DefaultTax.new, zone: zone)
create(:tax_rate, amount: 0.2, calculator: Calculator::DefaultTax.new, zone:)
}
let(:tax_rate_shipping) {
create(:tax_rate, amount: 0.05, calculator: Calculator::DefaultTax.new, zone: zone)
create(:tax_rate, amount: 0.05, calculator: Calculator::DefaultTax.new, zone:)
}
let(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) }
let(:tax_category_shipping) { create(:tax_category, tax_rates: [tax_rate_shipping]) }
let(:zone) { create(:zone_with_member) }
let(:shipping_method) { create(:shipping_method, tax_category: tax_category_shipping) }
let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) }
let(:shipment) { create(:shipment_with, :shipping_method, shipping_method:) }
let(:line_item) { create(:line_item) }
let(:enterprise_fee) { create(:enterprise_fee, tax_category: tax_category) }
let(:order) { create(:order_with_taxes, zone: zone) }
let(:enterprise_fee) { create(:enterprise_fee, tax_category:) }
let(:order) { create(:order_with_taxes, zone:) }
subject { TaxRateFinder.new }

View File

@@ -9,7 +9,7 @@ describe UserDefaultAddressSetter do
create(:customer, bill_address: customer_address, ship_address: customer_address)
end
let(:order) do
create(:order, customer: customer, bill_address: order_address, ship_address: order_address)
create(:order, customer:, bill_address: order_address, ship_address: order_address)
end
let(:user) { create(:user) }

View File

@@ -6,7 +6,7 @@ describe VariantsStockLevels do
let(:order) { create(:order) }
let!(:line_item) do
create(:line_item, order: order, variant: variant_in_the_order, quantity: 2, max_quantity: 3)
create(:line_item, order:, variant: variant_in_the_order, quantity: 2, max_quantity: 3)
end
let!(:variant_in_the_order) { create(:variant) }
let!(:variant_not_in_the_order) { create(:variant) }

View File

@@ -8,7 +8,7 @@ describe VoucherAdjustmentsService do
context 'with a flat rate voucher' do
let(:voucher) do
create(:voucher_flat_rate, code: 'new_code', enterprise: enterprise, amount: 10)
create(:voucher_flat_rate, code: 'new_code', enterprise:, amount: 10)
end
context 'when voucher covers the order total' do
@@ -174,7 +174,7 @@ describe VoucherAdjustmentsService do
context 'with a percentage rate voucher' do
let(:voucher) do
create(:voucher_percentage_rate, code: 'new_code', enterprise: enterprise, amount: 10)
create(:voucher_percentage_rate, code: 'new_code', enterprise:, amount: 10)
end
let(:adjustment) { order.voucher_adjustments.first }
let(:tax_adjustment) { order.voucher_adjustments.second }
@@ -183,7 +183,7 @@ describe VoucherAdjustmentsService do
subject { order.voucher_adjustments.first }
let(:voucher) do
create(:voucher_percentage_rate, code: 'new_code', enterprise: enterprise, amount: 100)
create(:voucher_percentage_rate, code: 'new_code', enterprise:, amount: 100)
end
let(:order) { create(:order_with_totals) }

View File

@@ -17,7 +17,7 @@ module OpenFoodNetwork
user = create(:user)
user.spree_roles = []
enterprises.each do |enterprise|
enterprise.enterprise_roles.create!(user: user)
enterprise.enterprise_roles.create!(user:)
end
user
end

View File

@@ -47,9 +47,9 @@ module ControllerRequestsHelper
def process_action_with_route(action, params = {}, session = nil, flash = nil, method = "GET")
process(action,
method: method,
method:,
params: params.reverse_merge!(use_route: :main_app),
session: session,
flash: flash)
session:,
flash:)
end
end

View File

@@ -32,7 +32,7 @@ module StripeStubs
def stub_payment_method_attach_request(payment_method: "pm_123", customer: "cus_A123")
stub_request(:post,
"https://api.stripe.com/v1/payment_methods/#{payment_method}/attach")
.with(body: { customer: customer })
.with(body: { customer: })
.to_return(hub_payment_method_response_mock({ pm_id: payment_method }))
end
@@ -44,7 +44,7 @@ module StripeStubs
# Stubs the customers call to both the main stripe account and the connected account
def stub_customers_post_request(email:, response: {}, stripe_account_header: false)
stub = stub_request(:post, "https://api.stripe.com/v1/customers")
.with(body: { email: email })
.with(body: { email: })
stub = stub.with(headers: { 'Stripe-Account' => 'abc123' }) if stripe_account_header
stub.to_return(customers_response_mock(response))
end
@@ -174,7 +174,7 @@ module StripeStubs
body: JSON.generate(
object: "list",
has_more: false,
data: [{ id: payment_method, card: { fingerprint: fingerprint } }],
data: [{ id: payment_method, card: { fingerprint: } }],
),
}
end

View File

@@ -37,7 +37,7 @@ module UIComponentHelper
def select_login_tab(text)
within ".login-modal" do
page.find("a", text: text).click
page.find("a", text:).click
end
sleep 0.2
end

View File

@@ -7,10 +7,10 @@ module WebHelper
visible = opts.key?(:visible) ? opts[:visible] : true
element = page.all(selector, visible: visible).first
element = page.all(selector, visible:).first
expect(element.value).to eq(opts[:with]) if element && opts.key?(:with)
have_selector selector, visible: visible
have_selector selector, visible:
end
def select_by_value(value, options = {})

View File

@@ -14,14 +14,14 @@ describe '
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor]) }
let!(:order) {
create(:order_with_totals_and_distribution, user: user, distributor: distributor,
order_cycle: order_cycle, state: 'complete',
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'complete',
payment_state: 'balance_due')
}
let!(:tax_category) { create(:tax_category, name: 'GST') }
let!(:tax_rate) {
create(:tax_rate, name: 'GST', calculator: build(:calculator, preferred_amount: 10),
zone: create(:zone_with_member), tax_category: tax_category)
zone: create(:zone_with_member), tax_category:)
}
let!(:tax_category_included) { create(:tax_category, name: 'TVA 20%', is_default: true) }
@@ -33,7 +33,7 @@ describe '
before do
order.finalize!
create(:check_payment, order: order, amount: order.total)
create(:check_payment, order:, amount: order.total)
login_as_admin
visit spree.admin_orders_path
end
@@ -124,7 +124,7 @@ describe '
it "modifying taxed adjustments on an order" do
# Given a taxed adjustment
adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order,
amount: 110, tax_category: tax_category, order: order)
amount: 110, tax_category:, order:)
# When I go to the adjustments page for the order
page.find('td.actions a.icon-edit').click
@@ -145,7 +145,7 @@ describe '
it "modifying an untaxed adjustment on an order" do
# Given an untaxed adjustment
adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order,
amount: 110, tax_category: nil, order: order)
amount: 110, tax_category: nil, order:)
# When I go to the adjustments page for the order
page.find('td.actions a.icon-edit').click
@@ -167,7 +167,7 @@ describe '
# Given a taxed adjustment
let!(:adjustment) {
create(:adjustment, label: "Extra Adjustment", adjustable: order,
amount: 110, tax_category: tax_category, order: order)
amount: 110, tax_category:, order:)
}
before do
order.cancel!

View File

@@ -171,7 +171,7 @@ describe '
let!(:product) { create(:product) }
let(:variant) { product.variants.first }
let(:hub) { create(:distributor_enterprise) }
let!(:override) { create(:variant_override, variant: variant, hub: hub ) }
let!(:override) { create(:variant_override, variant:, hub: ) }
let(:variant_overrides_tip) {
"This variant has %d override(s)" % 1
}
@@ -269,8 +269,8 @@ describe '
end
context "handle the 'on_demand' variant case creation" do
let(:v1) { create(:variant, product: product, on_hand: 4) }
let(:v2) { create(:variant, product: product, on_demand: true) }
let(:v1) { create(:variant, product:, on_hand: 4) }
let(:v2) { create(:variant, product:, on_demand: true) }
before do
product.variants << v1

View File

@@ -30,7 +30,7 @@ describe "States" do
end
context "admin visiting states listing" do
let!(:state) { Spree::State.create(name: 'Alabama', country: country) }
let!(:state) { Spree::State.create(name: 'Alabama', country:) }
it "should correctly display the states" do
visit spree.admin_country_states_path(country)

View File

@@ -6,7 +6,7 @@ describe "Tax Rates" do
include AuthenticationHelper
let!(:calculator) { create(:calculator_per_item, calculable: create(:order)) }
let!(:tax_rate) { create(:tax_rate, name: "IVA", calculator: calculator) }
let!(:tax_rate) { create(:tax_rate, name: "IVA", calculator:) }
let!(:zone) { create(:zone, name: "Ilhas") }
let!(:tax_category) { create(:tax_category, name: "Full") }

View File

@@ -132,7 +132,7 @@ describe 'Customers' do
create(:stripe_sca_payment_method, distributors: [managed_distributor1])
}
let!(:payment1) {
create(:payment, :completed, order: order1, payment_method: payment_method,
create(:payment, :completed, order: order1, payment_method:,
response_code: 'pi_123', amount: 88.00)
}
@@ -162,7 +162,7 @@ describe 'Customers' do
context "with an additional negative payment (or refund)" do
let!(:payment2) {
create(:payment, :completed, order: order1, payment_method: payment_method,
create(:payment, :completed, order: order1, payment_method:,
response_code: 'pi_123', amount: -25.00)
}

View File

@@ -801,7 +801,7 @@ describe '
}
before do
distributor1.update(custom_tab: custom_tab)
distributor1.update(custom_tab:)
visit edit_admin_enterprise_path(distributor1)
within(".side_menu") do
click_link "White Label"
@@ -842,7 +842,7 @@ describe '
context "changing package" do
let!(:owner) { create(:user) }
let!(:enterprise) { create(:distributor_enterprise, owner: owner, is_primary_producer: true) }
let!(:enterprise) { create(:distributor_enterprise, owner:, is_primary_producer: true) }
before do
login_as owner
end

View File

@@ -21,8 +21,8 @@ describe '
end
let(:order) do
create(:order_with_totals_and_distribution, user: user, distributor: distributor,
order_cycle: order_cycle, state: 'complete',
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'complete',
payment_state: 'balance_due')
end
@@ -54,7 +54,7 @@ describe '
context "with one payment" do
let!(:payment1) do
create(:payment, :completed, order: order, payment_method: payment_method1)
create(:payment, :completed, order:, payment_method: payment_method1)
end
before do
order.save!
@@ -72,10 +72,10 @@ describe '
context "with two payments, and one that failed" do
before do
order.update payments: []
order.payments << create(:payment, :completed, order: order,
order.payments << create(:payment, :completed, order:,
payment_method: payment_method1,
created_at: 1.day.ago)
order.payments << create(:payment, order: order, state: 'failed',
order.payments << create(:payment, order:, state: 'failed',
payment_method: payment_method2, created_at: 2.days.ago)
order.save!
end
@@ -92,10 +92,10 @@ describe '
context "with two completed payments" do
before do
order.update payments: []
order.payments << create(:payment, :completed, order: order,
order.payments << create(:payment, :completed, order:,
payment_method: payment_method1,
created_at: 2.days.ago)
order.payments << create(:payment, :completed, order: order,
order.payments << create(:payment, :completed, order:,
payment_method: payment_method2,
created_at: 1.day.ago)
order.save!
@@ -113,7 +113,7 @@ describe '
shared_examples "Check display on each invoice: legacy and alternative" do |alternative_invoice|
let!(:completed_order) do
create(:completed_order_with_fees, distributor: distributor, order_cycle: order_cycle,
create(:completed_order_with_fees, distributor:, order_cycle:,
user: create(:user, email: "xxxxxx@example.com"),
bill_address: create(:address, phone: '1234567890'))
end
@@ -141,10 +141,10 @@ describe '
context "included" do
let(:shipping_tax_rate_included) {
create(:tax_rate, amount: 0.1, included_in_price: true, zone: zone)
create(:tax_rate, amount: 0.1, included_in_price: true, zone:)
}
let(:enterprise_fee_rate_included) {
create(:tax_rate, amount: 0.15, included_in_price: true, zone: zone)
create(:tax_rate, amount: 0.15, included_in_price: true, zone:)
}
let(:shipping_tax_category) { create(:tax_category, tax_rates: [shipping_tax_rate_included]) }
let(:fee_tax_category) { create(:tax_category, tax_rates: [enterprise_fee_rate_included]) }
@@ -164,15 +164,15 @@ describe '
}
let!(:order1) {
create(:order, order_cycle: order_cycle, distributor: user1.enterprises.first,
create(:order, order_cycle:, distributor: user1.enterprises.first,
ship_address: address, bill_address: address)
}
let!(:product1) {
create(:taxed_product, zone: zone, price: 12.54, tax_rate_amount: 0,
create(:taxed_product, zone:, price: 12.54, tax_rate_amount: 0,
included_in_price: true)
}
let!(:product2) {
create(:taxed_product, zone: zone, price: 500.15, tax_rate_amount: 0.2,
create(:taxed_product, zone:, price: 500.15, tax_rate_amount: 0.2,
included_in_price: true)
}
@@ -275,10 +275,10 @@ describe '
context "added" do
let(:shipping_tax_rate_added) {
create(:tax_rate, amount: 0.10, included_in_price: false, zone: zone)
create(:tax_rate, amount: 0.10, included_in_price: false, zone:)
}
let(:enterprise_fee_rate_added) {
create(:tax_rate, amount: 0.15, included_in_price: false, zone: zone)
create(:tax_rate, amount: 0.15, included_in_price: false, zone:)
}
let(:shipping_tax_category) { create(:tax_category, tax_rates: [shipping_tax_rate_added]) }
let(:fee_tax_category) { create(:tax_category, tax_rates: [enterprise_fee_rate_added]) }
@@ -302,11 +302,11 @@ describe '
ship_address: address, bill_address: address)
}
let(:product3) {
create(:taxed_product, zone: zone, price: 12.54, tax_rate_amount: 0,
create(:taxed_product, zone:, price: 12.54, tax_rate_amount: 0,
included_in_price: false)
}
let(:product4) {
create(:taxed_product, zone: zone, price: 500.15, tax_rate_amount: 0.2,
create(:taxed_product, zone:, price: 500.15, tax_rate_amount: 0.2,
included_in_price: false)
}

View File

@@ -16,9 +16,9 @@ describe '
# Given coordinating, supplying and distributing enterprises with some products with variants
let!(:coordinator) { create(:distributor_enterprise, name: 'My coordinator') }
let!(:supplier) { create(:supplier_enterprise, name: 'My supplier') }
let!(:product) { create(:product, supplier: supplier) }
let!(:v1) { create(:variant, product: product) }
let!(:v2) { create(:variant, product: product) }
let!(:product) { create(:product, supplier:) }
let!(:v1) { create(:variant, product:) }
let!(:v2) { create(:variant, product:) }
let!(:distributor) {
create(:distributor_enterprise, name: 'My distributor', with_payment_and_shipping: true)
}

View File

@@ -27,9 +27,9 @@ xdescribe '
supplier = create(:supplier_enterprise, name: 'My supplier')
distributor = create(:distributor_enterprise, name: 'My distributor',
with_payment_and_shipping: true)
product = create(:product, supplier: supplier)
v1 = create(:variant, product: product)
v2 = create(:variant, product: product)
product = create(:product, supplier:)
v1 = create(:variant, product:)
v2 = create(:variant, product:)
# Relationships required for interface to work
create(:enterprise_relationship, parent: supplier, child: coordinator,

View File

@@ -376,7 +376,7 @@ describe '
name: 'Order Cycle 1' )
end
let(:product) { create(:product, supplier: supplier_managed) }
let(:v1) { create(:variant, product: product ) }
let(:v1) { create(:variant, product: ) }
let(:inventory_item_v1) {
create(:inventory_item, enterprise: distributor_managed, variant: v1, visible: false)
}
@@ -596,10 +596,10 @@ describe '
let!(:v1) { p1.variants.first }
let!(:v2) { p2.variants.first }
let!(:v3) { p3.variants.first }
let!(:fee) { create(:enterprise_fee, enterprise: enterprise, name: 'Coord fee') }
let!(:fee) { create(:enterprise_fee, enterprise:, name: 'Coord fee') }
before do
user.enterprise_roles.create! enterprise: enterprise
user.enterprise_roles.create!(enterprise:)
login_as user
end
@@ -685,7 +685,7 @@ describe '
it "editing an order cycle" do
# Given an order cycle with pickup time and instructions
fee = create(:enterprise_fee, name: 'my fee', enterprise: enterprise)
fee = create(:enterprise_fee, name: 'my fee', enterprise:)
oc = create(:simple_order_cycle, suppliers: [enterprise], coordinator: enterprise,
distributors: [enterprise], variants: [v1],
coordinator_fees: [fee])
@@ -722,8 +722,8 @@ describe '
it "updating an order cycle" do
# Given an order cycle with pickup time and instructions
fee1 = create(:enterprise_fee, name: 'my fee', enterprise: enterprise)
fee2 = create(:enterprise_fee, name: 'that fee', enterprise: enterprise)
fee1 = create(:enterprise_fee, name: 'my fee', enterprise:)
fee2 = create(:enterprise_fee, name: 'that fee', enterprise:)
oc = create(:simple_order_cycle, suppliers: [enterprise], coordinator: enterprise,
distributors: [enterprise], variants: [v1],
coordinator_fees: [fee1])

View File

@@ -18,8 +18,8 @@ describe '
end
let(:order) do
create(:order_with_totals_and_distribution, user: user, distributor: distributor,
order_cycle: order_cycle, state: 'complete',
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'complete',
payment_state: 'balance_due')
end
let(:customer) { order.customer }
@@ -28,7 +28,7 @@ describe '
# ensure order has a payment to capture
order.finalize!
create :check_payment, order: order, amount: order.total
create :check_payment, order:, amount: order.total
end
def new_order_with_distribution(distributor, order_cycle)
@@ -113,7 +113,7 @@ describe '
end
context "when creating an order with a customer-only" do
let!(:order) { create(:order, distributor: distributor, order_cycle: order_cycle) }
let!(:order) { create(:order, distributor:, order_cycle:) }
let(:customer2) { create(:customer, enterprise: distributor) }
let(:customer3) { create(:customer, enterprise: distributor) }
@@ -922,8 +922,8 @@ describe '
context "when an incomplete order has some line items with insufficient stock" do
let(:incomplete_order) do
create(:order_with_line_items, user: user, distributor: distributor,
order_cycle: order_cycle)
create(:order_with_line_items, user:, distributor:,
order_cycle:)
end
it "displays the out of stock line items and they can be deleted from the order" do
@@ -1034,8 +1034,8 @@ describe '
describe "for order states" do
context "complete" do
let!(:order1) {
create(:order_with_totals_and_distribution, user: user, distributor:,
order_cycle: order_cycle, state: 'complete',
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'complete',
payment_state: 'balance_due',
customer_id: customer.id)
}
@@ -1104,8 +1104,8 @@ describe '
context "resumed" do
let!(:order2) {
create(:order_with_totals_and_distribution, user: user, distributor:,
order_cycle: order_cycle, state: 'resumed',
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'resumed',
payment_state: 'balance_due')
}
before do
@@ -1120,8 +1120,8 @@ describe '
context "canceled" do
let!(:order3) {
create(:order_with_totals_and_distribution, user: user, distributor:,
order_cycle: order_cycle, state: 'canceled',
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'canceled',
payment_state: 'balance_due')
}
before do
@@ -1136,7 +1136,7 @@ describe '
context "cart" do
let!(:order_empty) {
create(:order_with_line_items, user: user, distributor:, order_cycle: order_cycle,
create(:order_with_line_items, user:, distributor:, order_cycle:,
line_items_count: 0)
}
before do
@@ -1151,8 +1151,8 @@ describe '
context "payment" do
let!(:order4) do
create(:order_ready_for_payment, user: user, distributor: distributor,
order_cycle: order_cycle,
create(:order_ready_for_payment, user:, distributor:,
order_cycle:,
payment_state: 'balance_due')
end
before do

View File

@@ -23,16 +23,16 @@ describe '
let(:billing_address5) { create(:address, :randomized) }
let(:product) { create(:simple_product) }
let(:distributor) {
create(:distributor_enterprise, owner: owner, with_payment_and_shipping: true,
create(:distributor_enterprise, owner:, with_payment_and_shipping: true,
charges_sales_tax: true)
}
let(:distributor2) { create(:distributor_enterprise_with_tax, owner: owner) }
let(:distributor2) { create(:distributor_enterprise_with_tax, owner:) }
let(:distributor3) {
create(:distributor_enterprise, owner: owner, with_payment_and_shipping: true,
create(:distributor_enterprise, owner:, with_payment_and_shipping: true,
charges_sales_tax: true)
}
let(:distributor4) {
create(:distributor_enterprise, owner: owner, with_payment_and_shipping: true,
create(:distributor_enterprise, owner:, with_payment_and_shipping: true,
charges_sales_tax: true)
}
let(:distributor5) { create(:distributor_enterprise, owner: owner2, charges_sales_tax: true) }
@@ -52,8 +52,8 @@ describe '
context "with a complete order" do
let(:order) do
create(:order_with_totals_and_distribution, user: customer, distributor: distributor,
order_cycle: order_cycle,
create(:order_with_totals_and_distribution, user: customer, distributor:,
order_cycle:,
state: 'complete', payment_state: 'balance_due',
bill_address_id: billing_address.id)
end
@@ -691,7 +691,7 @@ describe '
context "with a capturable order" do
before do
order.finalize! # ensure order has a payment to capture
order.payments << create(:check_payment, order: order, amount: order.total)
order.payments << create(:check_payment, order:, amount: order.total)
end
it "capture payment" do
@@ -766,8 +766,8 @@ describe '
context "with incomplete order" do
it "can edit order" do
incomplete_order = create(:order_with_line_items, distributor: distributor,
order_cycle: order_cycle,
incomplete_order = create(:order_with_line_items, distributor:,
order_cycle:,
line_items_count: 1)
login_as_admin
@@ -783,13 +783,13 @@ describe '
context "test the 'Only show the complete orders' checkbox" do
it "display or not incomplete order" do
incomplete_order = create(:order_with_line_items, distributor: distributor,
order_cycle: order_cycle,
incomplete_order = create(:order_with_line_items, distributor:,
order_cycle:,
line_items_count: 1)
complete_order = create(
:order_with_line_items,
distributor: distributor,
order_cycle: order_cycle,
distributor:,
order_cycle:,
user: customer,
state: 'complete',
payment_state: 'balance_due',
@@ -799,8 +799,8 @@ describe '
empty_complete_order = create(
:order_with_line_items,
distributor: distributor,
order_cycle: order_cycle,
distributor:,
order_cycle:,
user: customer,
state: 'complete',
payment_state: 'balance_due',
@@ -808,7 +808,7 @@ describe '
line_items_count: 0
)
empty_order = create(:order, distributor: distributor, order_cycle: order_cycle)
empty_order = create(:order, distributor:, order_cycle:)
login_as_admin
visit spree.admin_orders_path
@@ -832,9 +832,9 @@ describe '
let!(:order) do
create(
:order,
distributor: distributor,
order_cycle: order_cycle,
user: user,
distributor:,
order_cycle:,
user:,
number: "R123456",
state: 'complete',
payment_state: 'balance_due',

View File

@@ -33,10 +33,10 @@ describe '
context "for a complete order" do
context "with a card that succeeds on card registration" do
before { stub_payment_intents_post_request order: order, stripe_account_header: true }
before { stub_payment_intents_post_request order:, stripe_account_header: true }
context "and succeeds on payment capture" do
before { stub_successful_capture_request order: order }
before { stub_successful_capture_request order: }
it "adds a payment with state complete" do
login_as_admin
@@ -54,7 +54,7 @@ describe '
context "but fails on payment capture" do
let(:error_message) { "Card was declined: insufficient funds." }
before { stub_failed_capture_request order: order, response: { message: error_message } }
before { stub_failed_capture_request order:, response: { message: error_message } }
it "fails to add a payment due to card error" do
login_as_admin
@@ -73,7 +73,7 @@ describe '
context "with a card that fails on registration because it requires(redirects) extra auth" do
before do
stub_payment_intents_post_request_with_redirect order: order,
stub_payment_intents_post_request_with_redirect order:,
redirect_url: "https://www.stripe.com/authorize"
end
@@ -97,8 +97,8 @@ describe '
let!(:order) { create(:order_with_line_items, distributor: create(:enterprise)) }
before do
stub_payment_intents_post_request order: order, stripe_account_header: true
stub_successful_capture_request order: order
stub_payment_intents_post_request order:, stripe_account_header: true
stub_successful_capture_request(order:)
break unless order.next! while !order.payment?
end
@@ -120,7 +120,7 @@ describe '
context "with a payment using a StripeSCA payment method" do
before do
order.update payments: []
order.payments << create(:payment, payment_method: stripe_payment_method, order: order)
order.payments << create(:payment, payment_method: stripe_payment_method, order:)
end
it "renders the payment details" do

View File

@@ -67,8 +67,8 @@ describe "enterprise fee summaries" do
context "when logged in as enterprise user" do
let!(:order) do
create(:completed_order_with_fees, order_cycle: order_cycle,
distributor: distributor)
create(:completed_order_with_fees, order_cycle:,
distributor:)
end
let(:current_user) { distributor.owner }
@@ -82,8 +82,8 @@ describe "enterprise fee summaries" do
describe "smoke test for generation of report based on permissions" do
context "when logged in as admin" do
let!(:order) do
create(:completed_order_with_fees, order_cycle: order_cycle,
distributor: distributor)
create(:completed_order_with_fees, order_cycle:,
distributor:)
end
let(:current_user) { create(:admin_user) }
@@ -101,8 +101,8 @@ describe "enterprise fee summaries" do
context "when logged in as enterprise user" do
let!(:order) do
create(:completed_order_with_fees, order_cycle: order_cycle,
distributor: distributor)
create(:completed_order_with_fees, order_cycle:,
distributor:)
end
let!(:other_order) do
create(:completed_order_with_fees, order_cycle: other_order_cycle,
@@ -130,8 +130,8 @@ describe "enterprise fee summaries" do
let!(:second_order_cycle) { create(:simple_order_cycle, coordinator: second_distributor) }
let!(:order) do
create(:completed_order_with_fees, order_cycle: order_cycle,
distributor: distributor)
create(:completed_order_with_fees, order_cycle:,
distributor:)
end
let!(:second_order) do
create(:completed_order_with_fees, order_cycle: second_order_cycle,

View File

@@ -36,10 +36,10 @@ describe "Enterprise Summary Fee with Tax Report By Order" do
let!(:country_zone){ create(:zone_with_member) }
let!(:tax_category){ create(:tax_category, name: 'tax_category') }
let!(:state_tax_rate){
create(:tax_rate, zone: state_zone, tax_category: tax_category, name: 'State', amount: 0.015)
create(:tax_rate, zone: state_zone, tax_category:, name: 'State', amount: 0.015)
}
let!(:country_tax_rate){
create(:tax_rate, zone: country_zone, tax_category: tax_category, name: 'Country',
create(:tax_rate, zone: country_zone, tax_category:, name: 'Country',
amount: 0.025)
}
let!(:ship_address){ create(:ship_address) }
@@ -51,7 +51,7 @@ describe "Enterprise Summary Fee with Tax Report By Order" do
let!(:payment_method){ create(:payment_method, :flat_rate) }
let!(:shipping_method){ create(:shipping_method, :flat_rate) }
let!(:order){ create(:order_with_distributor, distributor: distributor, number: order_number) }
let!(:order){ create(:order_with_distributor, distributor:, number: order_number) }
let!(:order_cycle){
create(:simple_order_cycle, name: "oc1", suppliers: [supplier], distributors: [distributor],
variants: [variant])
@@ -63,19 +63,19 @@ describe "Enterprise Summary Fee with Tax Report By Order" do
create(:enterprise_fee, :flat_rate, enterprise: distributor, amount: 20,
name: 'Adminstration',
fee_type: 'admin',
tax_category: tax_category)
tax_category:)
}
let!(:supplier_fees){
create(:enterprise_fee, :flat_rate, enterprise: supplier, amount: 15,
name: 'Transport',
fee_type: 'transport',
tax_category: tax_category)
tax_category:)
}
let!(:distributor_fee){
create(:enterprise_fee, :flat_rate, enterprise: distributor, amount: 10,
name: 'Packing',
fee_type: 'packing',
tax_category: tax_category)
tax_category:)
}
let!(:customer_first_name){ "Customer First Name" }
@@ -100,7 +100,7 @@ describe "Enterprise Summary Fee with Tax Report By Order" do
context 'added tax' do
before do
order.line_items.create({ variant: variant, quantity: 1, price: 100 })
order.line_items.create({ variant:, quantity: 1, price: 100 })
order.update!({
order_cycle_id: order_cycle.id,
ship_address_id: ship_address.id
@@ -183,7 +183,7 @@ describe "Enterprise Summary Fee with Tax Report By Order" do
state_tax_rate.update!({ included_in_price: true })
country_tax_rate.update!({ included_in_price: true })
order.line_items.create({ variant: variant, quantity: 1, price: 100 })
order.line_items.create({ variant:, quantity: 1, price: 100 })
order.update!({
order_cycle_id: order_cycle.id,
ship_address_id: ship_address.id

View File

@@ -25,19 +25,19 @@ describe "Orders And Fulfillment" do
}
let(:order_cycle) { create(:simple_order_cycle, distributors: [distributor]) }
let(:order1) {
create(:completed_order_with_totals, line_items_count: 0, distributor: distributor,
create(:completed_order_with_totals, line_items_count: 0, distributor:,
bill_address: bill_address1,
order_cycle_id: order_cycle.id)
}
let(:order2) {
create(:completed_order_with_totals, line_items_count: 0, distributor: distributor,
create(:completed_order_with_totals, line_items_count: 0, distributor:,
bill_address: bill_address2,
order_cycle_id: order_cycle.id)
}
let(:supplier) { create(:supplier_enterprise, name: "Supplier Name") }
let(:product) { create(:simple_product, name: "Baked Beans", supplier: supplier ) }
let(:variant1) { create(:variant, product: product, unit_description: "Big") }
let(:variant2) { create(:variant, product: product, unit_description: "Small") }
let(:product) { create(:simple_product, name: "Baked Beans", supplier: ) }
let(:variant1) { create(:variant, product:, unit_description: "Big") }
let(:variant2) { create(:variant, product:, unit_description: "Small") }
before do
# order1 has two line items / variants
@@ -153,12 +153,12 @@ describe "Orders And Fulfillment" do
let(:bill_address4) { create(:address, firstname: "Ave", lastname: "Zebu") }
let(:order3) {
create(:completed_order_with_totals, line_items_count: 0,
distributor: distributor,
distributor:,
bill_address: bill_address3)
}
let(:order4) {
create(:completed_order_with_totals, line_items_count: 0,
distributor: distributor,
distributor:,
bill_address: bill_address4)
}
@@ -178,7 +178,7 @@ describe "Orders And Fulfillment" do
end
context "When filtering by product" do
let(:variant1) { create(:variant, product: product, unit_description: "Big") }
let(:variant1) { create(:variant, product:, unit_description: "Big") }
let(:variant3) { create(:variant) }
before do
@@ -212,7 +212,7 @@ describe "Orders And Fulfillment" do
context "for three different orders" do
let(:order3) {
create(:completed_order_with_totals, line_items_count: 0,
distributor: distributor,
distributor:,
bill_address: bill_address1,
order_cycle_id: order_cycle.id)
}
@@ -403,7 +403,7 @@ describe "Orders And Fulfillment" do
let(:product2) { create(:simple_product, name: "Salted Peanuts", supplier: supplier2 ) }
let(:variant3) { create(:variant, product: product2, unit_description: "Bag") }
let(:order4) {
create(:completed_order_with_totals, line_items_count: 0, distributor: distributor,
create(:completed_order_with_totals, line_items_count: 0, distributor:,
bill_address: bill_address1,
order_cycle_id: order_cycle.id)
}

View File

@@ -26,18 +26,18 @@ describe "Packing Reports" do
}
let(:distributor) { create(:distributor_enterprise, address: distributor_address) }
let(:order1) {
create(:completed_order_with_totals, line_items_count: 0, distributor: distributor,
create(:completed_order_with_totals, line_items_count: 0, distributor:,
bill_address: bill_address1)
}
let(:order2) {
create(:completed_order_with_totals, line_items_count: 0, distributor: distributor,
create(:completed_order_with_totals, line_items_count: 0, distributor:,
bill_address: bill_address2)
}
let(:supplier) { create(:supplier_enterprise, name: "Supplier") }
let(:product1) { create(:simple_product, name: "Product 1", supplier: supplier ) }
let(:product1) { create(:simple_product, name: "Product 1", supplier: ) }
let(:variant1) { create(:variant, product: product1, unit_description: "Big") }
let(:variant2) { create(:variant, product: product1, unit_description: "Small") }
let(:product2) { create(:simple_product, name: "Product 2", supplier: supplier) }
let(:product2) { create(:simple_product, name: "Product 2", supplier:) }
before do
order1.finalize!
@@ -115,7 +115,7 @@ describe "Packing Reports" do
let(:oc) { create(:simple_order_cycle) }
let(:order) {
create(:completed_order_with_totals, line_items_count: 0,
order_cycle: oc, distributor: distributor)
order_cycle: oc, distributor:)
}
let(:li1) { build(:line_item_with_shipment) }
let(:li2) { build(:line_item_with_shipment) }

View File

@@ -10,7 +10,7 @@ describe "Payments Reports" do
:order_with_distributor,
state: 'complete',
completed_at: Time.zone.now,
order_cycle: order_cycle
order_cycle:
)
end
let(:other_order) do
@@ -18,17 +18,17 @@ describe "Payments Reports" do
:order_with_distributor,
state: 'complete',
completed_at: Time.zone.now,
order_cycle: order_cycle,
order_cycle:,
distributor: order.distributor
)
end
let(:order_cycle) { create(:simple_order_cycle) }
let(:product) { create(:product, supplier: supplier) }
let(:product) { create(:product, supplier:) }
let(:supplier) { create(:supplier_enterprise) }
before do
create(:line_item_with_shipment, order: order, product: product)
create(:line_item_with_shipment, order: other_order, product: product)
create(:line_item_with_shipment, order:, product:)
create(:line_item_with_shipment, order: other_order, product:)
login_as_admin
visit admin_reports_path
@@ -62,7 +62,7 @@ describe "Payments Reports" do
context 'when choosing payment totals report type' do
let(:paypal) { create(:payment_method, name: "PayPal") }
let!(:paypal_payment) {
create(:payment, order: order, payment_method: paypal, state: "completed", amount: 5)
create(:payment, order:, payment_method: paypal, state: "completed", amount: 5)
}
let(:eft) { create(:payment_method, name: "EFT") }

View File

@@ -9,17 +9,17 @@ describe "Revenues By Hub Reports" do
create(
:completed_order_with_totals,
completed_at: 2.days.ago,
order_cycle: order_cycle,
order_cycle:,
distributor: create(:enterprise, name: "Hub 1",
owner: create(:user, email: "email@email.com")),
)
end
let(:order_cycle) { create(:simple_order_cycle) }
let(:product) { create(:product, supplier: supplier) }
let(:product) { create(:product, supplier:) }
let(:supplier) { create(:supplier_enterprise) }
before do
create(:line_item_with_shipment, order: order, product: product)
create(:line_item_with_shipment, order:, product:)
login_as_admin
visit main_app.admin_report_path(report_type: 'revenues_by_hub')

View File

@@ -32,11 +32,11 @@ describe "Sales Tax Totals By order" do
let!(:country_zone){ create(:zone_with_member) }
let!(:tax_category){ create(:tax_category, name: 'GST Food') }
let!(:state_tax_rate){
create(:tax_rate, zone: state_zone, tax_category: tax_category,
create(:tax_rate, zone: state_zone, tax_category:,
name: 'State', amount: 0.015)
}
let!(:country_tax_rate){
create(:tax_rate, zone: country_zone, tax_category: tax_category,
create(:tax_rate, zone: country_zone, tax_category:,
name: 'Country', amount: 0.025)
}
let!(:ship_address){
@@ -64,7 +64,7 @@ describe "Sales Tax Totals By order" do
create(:shipping_method, :flat_rate, amount: 10, tax_category_id: tax_category.id)
}
let!(:order){ create(:order_with_distributor, distributor: distributor) }
let!(:order){ create(:order_with_distributor, distributor:) }
let!(:order_cycle){
create(:simple_order_cycle, name: 'oc1', suppliers: [supplier], distributors: [distributor],
variants: [variant])
@@ -92,7 +92,7 @@ describe "Sales Tax Totals By order" do
customer_id: customer1.id,
email: 'order1@example.com'
)
order.line_items.create(variant: variant, quantity: 1, price: 100)
order.line_items.create(variant:, quantity: 1, price: 100)
end
context 'added tax' do
@@ -220,7 +220,7 @@ describe "Sales Tax Totals By order" do
end
context 'should filter by customer' do
let!(:order2){ create(:order_with_distributor, distributor: distributor) }
let!(:order2){ create(:order_with_distributor, distributor:) }
let!(:customer2){ create(:customer, enterprise: create(:enterprise), user: create(:user)) }
let!(:customer_email_dropdown_selector){ "#s2id_q_customer_id_in" }
let!(:table_raw_selector){ "table.report__table tbody tr" }
@@ -323,7 +323,7 @@ describe "Sales Tax Totals By order" do
OrderWorkflow.new(order).complete!
customer2.update!({ first_name: 'c2fname', last_name: 'c2lname', code: 'DEF456' })
order2.line_items.create({ variant: variant, quantity: 1, price: 200 })
order2.line_items.create({ variant:, quantity: 1, price: 200 })
order2.update!({
order_cycle_id: order_cycle.id,
ship_address_id: customer2.bill_address_id,

View File

@@ -27,8 +27,8 @@ describe "Sales Tax Totals By Producer" do
let!(:state_zone){ create(:zone_with_state_member) }
let!(:country_zone){ create(:zone_with_member) }
let!(:tax_category){ create(:tax_category) }
let!(:state_tax_rate){ create(:tax_rate, zone: state_zone, tax_category: tax_category) }
let!(:country_tax_rate){ create(:tax_rate, zone: country_zone, tax_category: tax_category) }
let!(:state_tax_rate){ create(:tax_rate, zone: state_zone, tax_category:) }
let!(:country_tax_rate){ create(:tax_rate, zone: country_zone, tax_category:) }
let!(:ship_address){ create(:ship_address) }
let!(:variant){ create(:variant) }
@@ -38,7 +38,7 @@ describe "Sales Tax Totals By Producer" do
let!(:payment_method){ create(:payment_method, :flat_rate) }
let!(:shipping_method){ create(:shipping_method, :flat_rate) }
let!(:order){ create(:order_with_distributor, distributor: distributor) }
let!(:order){ create(:order_with_distributor, distributor:) }
let!(:order_cycle){
create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor],
variants: [variant])
@@ -63,7 +63,7 @@ describe "Sales Tax Totals By Producer" do
context 'added tax' do
before do
order.line_items.create({ variant: variant, quantity: 1, price: 100 })
order.line_items.create({ variant:, quantity: 1, price: 100 })
order.update!({
order_cycle_id: order_cycle.id,
ship_address_id: ship_address.id
@@ -125,7 +125,7 @@ describe "Sales Tax Totals By Producer" do
state_tax_rate.update!({ included_in_price: true })
country_tax_rate.update!({ included_in_price: true })
order.line_items.create({ variant: variant, quantity: 1, price: 100 })
order.line_items.create({ variant:, quantity: 1, price: 100 })
order.update!({
order_cycle_id: order_cycle.id,
ship_address_id: ship_address.id
@@ -182,7 +182,7 @@ describe "Sales Tax Totals By Producer" do
end
context 'should filter by customer' do
let!(:order2){ create(:order_with_distributor, distributor: distributor) }
let!(:order2){ create(:order_with_distributor, distributor:) }
let!(:customer1){ create(:customer, enterprise: create(:enterprise), user: create(:user)) }
let!(:customer2){ create(:customer, enterprise: create(:enterprise), user: create(:user)) }
let!(:customer_email_dropdown_selector){ "#s2id_q_customer_id_in" }
@@ -304,7 +304,7 @@ describe "Sales Tax Totals By Producer" do
}
before do
order.line_items.create({ variant: variant, quantity: 1, price: 100 })
order.line_items.create({ variant:, quantity: 1, price: 100 })
order.update!({
order_cycle_id: order_cycle.id,
ship_address_id: customer1.bill_address_id,
@@ -314,7 +314,7 @@ describe "Sales Tax Totals By Producer" do
break unless order.next!
end
order2.line_items.create({ variant: variant, quantity: 1, price: 200 })
order2.line_items.create({ variant:, quantity: 1, price: 200 })
order2.update!({
order_cycle_id: order_cycle.id,
ship_address_id: customer2.bill_address_id,