Fix Style/HashSyntax

This commit is contained in:
Neal Chambers
2023-10-24 08:49:34 +09:00
parent a2f8b0db16
commit dc607b654d
29 changed files with 150 additions and 150 deletions

View File

@@ -205,7 +205,7 @@ module Spree
end
def display_payment_total
Spree::Money.new(self.payment_total, currency: currency)
Spree::Money.new(self.payment_total, currency:)
end
def to_param
number.to_s.parameterize.upcase

View File

@@ -283,7 +283,7 @@ describe VoucherAdjustmentsService do
let(:order) { create(:order_with_totals) }
let(:enterprise) { build(:enterprise) }
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
it "returns included tax from voucher adjusment" do
@@ -317,7 +317,7 @@ describe VoucherAdjustmentsService do
end
let(:enterprise) { build(:enterprise) }
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
it "returns the amount from the tax voucher adjustment" do

View File

@@ -270,7 +270,7 @@ describe '
}
let(:user1) { create(:user, enterprises: [distributor1]) }
let(:user2) { create(:user, enterprises: [distributor2]) }
let(:shipping_tax_rate) { create(:tax_rate, amount: 0.20, included_in_price: true, zone: zone) }
let(:shipping_tax_rate) { create(:tax_rate, amount: 0.20, included_in_price: true, zone:) }
let(:shipping_tax_category) { create(:tax_category, tax_rates: [shipping_tax_rate]) }
let!(:shipping_method) {
create(:shipping_method_with, :expensive_name, distributors: [distributor1],
@@ -290,14 +290,14 @@ describe '
let!(:zone) { create(:zone_with_member) }
let(:address) { create(:address) }
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, included_in_price: true)
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)
}
@@ -371,12 +371,12 @@ describe '
let(:supplier) { create(:supplier_enterprise, name: 'Supplier Name') }
let(:taxon) { create(:taxon, name: 'Taxon Name') }
let(:product1) {
create(:simple_product, name: "Product Name", price: 100, supplier: supplier,
create(:simple_product, name: "Product Name", price: 100, supplier:,
primary_taxon: taxon)
}
let(:product2) {
create(:simple_product, name: "Product 2", price: 99.0, variant_unit: 'weight',
variant_unit_scale: 1, unit_value: '100', supplier: supplier,
variant_unit_scale: 1, unit_value: '100', supplier:,
primary_taxon: taxon, sku: "product_sku")
}
let(:variant1) { product1.variants.first }
@@ -566,7 +566,7 @@ describe '
let(:user1) { create(:user, enterprises: [distributor1]) }
let(:user2) { create(:user, enterprises: [distributor2]) }
let(:shipping_method) { create(:shipping_method_with, :expensive_name) }
let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) }
let(:shipment) { create(:shipment_with, :shipping_method, shipping_method:) }
let(:enterprise_fee1) {
create(:enterprise_fee, enterprise: user1.enterprises.first,
@@ -590,14 +590,14 @@ describe '
address2: '', city: 'customer city', zipcode: 1234)
}
let(:order1) {
create(:order, order_cycle: order_cycle, distributor: user1.enterprises.first,
shipments: [shipment], bill_address: bill_address, state: 'payment')
create(:order, order_cycle:, distributor: user1.enterprises.first,
shipments: [shipment], bill_address:, state: 'payment')
}
let(:product1) {
create(:taxed_product, zone: zone, price: 12.54, tax_rate_amount: 0, sku: 'sku1')
create(:taxed_product, zone:, price: 12.54, tax_rate_amount: 0, sku: 'sku1')
}
let(:product2) {
create(:taxed_product, zone: zone, price: 500.15, tax_rate_amount: 0.2, sku: 'sku2')
create(:taxed_product, zone:, price: 500.15, tax_rate_amount: 0.2, sku: 'sku2')
}
describe "with adjustments" do
@@ -611,7 +611,7 @@ describe '
}
let!(:tax_category) { create(:tax_category) }
let!(:tax_rate) { create(:tax_rate, tax_category: tax_category) }
let!(:tax_rate) { create(:tax_rate, tax_category:) }
let!(:adj_shipping) {
create(:adjustment, order: order1, adjustable: order1, label: "Shipping",
originator: shipping_method, amount: 100.55)
@@ -622,7 +622,7 @@ describe '
}
let!(:adj_fee2) {
create(:adjustment, order: order1, adjustable: order1, originator: enterprise_fee2,
label: "Enterprise fee taxed", amount: 20, tax_category: tax_category)
label: "Enterprise fee taxed", amount: 20, tax_category:)
}
let!(:adj_fee2_tax) {
create(:adjustment, order: order1, adjustable: adj_fee2, originator: tax_rate, amount: 3,
@@ -634,7 +634,7 @@ describe '
}
let!(:adj_admin2) {
create(:adjustment, order: order1, adjustable: order1, originator: nil,
label: "Manual adjustment", amount: 40, tax_category: tax_category)
label: "Manual adjustment", amount: 40, tax_category:)
}
before do

View File

@@ -105,31 +105,31 @@ describe 'Tag Rules' do
context "updating" do
let!(:default_fsm_tag_rule) {
create(:filter_shipping_methods_tag_rule, enterprise: enterprise,
create(:filter_shipping_methods_tag_rule, enterprise:,
preferred_matched_shipping_methods_visibility:
"visible", is_default: true,
preferred_shipping_method_tags: "local" )
}
let!(:fp_tag_rule) {
create(:filter_products_tag_rule, enterprise: enterprise,
create(:filter_products_tag_rule, enterprise:,
preferred_matched_variants_visibility:
"visible", preferred_customer_tags: "member",
preferred_variant_tags: "member" )
}
let!(:fpm_tag_rule) {
create(:filter_payment_methods_tag_rule, enterprise: enterprise,
create(:filter_payment_methods_tag_rule, enterprise:,
preferred_matched_payment_methods_visibility:
"hidden", preferred_customer_tags: "trusted",
preferred_payment_method_tags: "trusted" )
}
let!(:foc_tag_rule) {
create(:filter_order_cycles_tag_rule, enterprise: enterprise,
create(:filter_order_cycles_tag_rule, enterprise:,
preferred_matched_order_cycles_visibility:
"visible", preferred_customer_tags: "wholesale",
preferred_exchange_tags: "wholesale" )
}
let!(:fsm_tag_rule) {
create(:filter_shipping_methods_tag_rule, enterprise: enterprise,
create(:filter_shipping_methods_tag_rule, enterprise:,
preferred_matched_shipping_methods_visibility:
"hidden", preferred_customer_tags: "local",
preferred_shipping_method_tags: "local" )
@@ -254,10 +254,10 @@ describe 'Tag Rules' do
context "deleting" do
let!(:tag_rule) {
create(:filter_products_tag_rule, enterprise: enterprise, preferred_customer_tags: "member" )
create(:filter_products_tag_rule, enterprise:, preferred_customer_tags: "member" )
}
let!(:default_rule) {
create(:filter_products_tag_rule, is_default: true, enterprise: enterprise )
create(:filter_products_tag_rule, is_default: true, enterprise: )
}
before do

View File

@@ -50,8 +50,8 @@ describe "
let!(:product) {
create(:simple_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1)
}
let!(:variant) { create(:variant, product: product, unit_value: 1, price: 1.23, on_hand: 12) }
let!(:inventory_item) { create(:inventory_item, enterprise: hub, variant: variant ) }
let!(:variant) { create(:variant, product:, unit_value: 1, price: 1.23, on_hand: 12) }
let!(:inventory_item) { create(:inventory_item, enterprise: hub, variant: ) }
let!(:product_managed) {
create(:simple_product, supplier: producer_managed, variant_unit: 'weight',
@@ -245,12 +245,12 @@ describe "
context "with overrides" do
let!(:vo) {
create(:variant_override, :on_demand, variant: variant, hub: hub, price: 77.77,
create(:variant_override, :on_demand, variant:, hub:, price: 77.77,
default_stock: 1000, resettable: true,
tag_list: ["tag1", "tag2", "tag3"])
}
let!(:vo_no_auth) {
create(:variant_override, variant: variant, hub: hub2, price: 1, count_on_hand: 2)
create(:variant_override, variant:, hub: hub2, price: 1, count_on_hand: 2)
}
let!(:product2) {
create(:simple_product, supplier: producer, variant_unit: 'weight',
@@ -261,14 +261,14 @@ describe "
}
let!(:inventory_item2) { create(:inventory_item, enterprise: hub, variant: variant2) }
let!(:vo_no_reset) {
create(:variant_override, variant: variant2, hub: hub, price: 3.99, count_on_hand: 40,
create(:variant_override, variant: variant2, hub:, price: 3.99, count_on_hand: 40,
default_stock: 100, resettable: false)
}
let!(:variant3) {
create(:variant, product: product, unit_value: 2, price: 5.00, on_hand: 6)
create(:variant, product:, unit_value: 2, price: 5.00, on_hand: 6)
}
let!(:vo3) {
create(:variant_override, variant: variant3, hub: hub, price: 6, count_on_hand: 7,
create(:variant_override, variant: variant3, hub:, price: 6, count_on_hand: 7,
sku: "SOMESKU", default_stock: 100, resettable: false)
}
let!(:inventory_item3) { create(:inventory_item, enterprise: hub, variant: variant3) }
@@ -473,9 +473,9 @@ describe "
create(:simple_product, supplier: producer, variant_unit: 'weight', variant_unit_scale: 1)
}
let!(:variant1) {
create(:variant, product: product, unit_value: 1, price: 1.23, on_hand: 12)
create(:variant, product:, unit_value: 1, price: 1.23, on_hand: 12)
}
let!(:variant2) { create(:variant, product: product, unit_value: 2, price: 4.56, on_hand: 3) }
let!(:variant2) { create(:variant, product:, unit_value: 2, price: 4.56, on_hand: 3) }
context "when a hub is selected" do
before do
@@ -523,7 +523,7 @@ describe "
it "shows more than 100 products in my inventory" do
supplier = create(:supplier_enterprise, sells: "own")
inventory_items = (1..101).map do
product = create(:simple_product, supplier: supplier)
product = create(:simple_product, supplier:)
InventoryItem.create!(
enterprise: supplier,
variant: product.variants.first

View File

@@ -17,13 +17,13 @@ describe '
before do
Flipper.enable(:vouchers, enterprise)
enterprise_user.enterprise_roles.build(enterprise: enterprise).save
enterprise_user.enterprise_roles.build(enterprise:).save
login_as enterprise_user
end
it 'lists enterprise vouchers' do
# Given an enterprise with vouchers
create(:voucher_flat_rate, enterprise: enterprise, code: voucher_code, amount: amount)
create(:voucher_flat_rate, enterprise:, code: voucher_code, amount:)
# When I go to the enterprise voucher tab
visit edit_admin_enterprise_path(enterprise)
@@ -87,7 +87,7 @@ describe '
# Then I should see an error flash message
expect(page).to have_selector '.error', text: "Code can't be blank"
vouchers = Voucher.where(enterprise: enterprise)
vouchers = Voucher.where(enterprise:)
expect(vouchers).to be_empty
end
@@ -101,7 +101,7 @@ describe '
end
def expect_voucher_to_be_created(enterprise, voucher_code)
voucher = Voucher.where(enterprise: enterprise, code: voucher_code).first
voucher = Voucher.where(enterprise:, code: voucher_code).first
expect(voucher).not_to be(nil)
end
end

View File

@@ -9,7 +9,7 @@ describe "Credit Cards" do
describe "as a logged in user" do
let(:user) { create(:user) }
let!(:customer) { create(:customer, user: user, created_manually: true) }
let!(:customer) { create(:customer, user:, created_manually: true) }
let!(:default_card) {
create(:stored_credit_card, user_id: user.id, gateway_customer_profile_id: 'cus_AZNMJ',
is_default: true)

View File

@@ -14,7 +14,7 @@ describe "Developer Settings" do
context "when show_api_key_view is true" do
let(:spree_api_key) { SecureRandom.hex(24) }
let(:user) { create(:user, show_api_key_view: true, spree_api_key: spree_api_key) }
let(:user) { create(:user, show_api_key_view: true, spree_api_key:) }
it "shows the developer settings tab" do
find("a", text: "DEVELOPER SETTINGS").click

View File

@@ -7,7 +7,7 @@ describe "Payments requiring action" do
describe "as a logged in user" do
let(:user) { create(:user) }
let(:order) { create(:order, user: user) }
let(:order) { create(:order, user:) }
before do
login_as user
@@ -16,7 +16,7 @@ describe "Payments requiring action" do
context "there is a payment requiring authorization" do
let!(:payment) do
create(:payment,
order: order,
order:,
cvv_response_message: "https://stripe.com/redirect",
state: "requires_authorization")
end
@@ -31,7 +31,7 @@ describe "Payments requiring action" do
context "there are no payments requiring authorization" do
let!(:payment) do
create(:payment, order: order, cvv_response_message: nil)
create(:payment, order:, cvv_response_message: nil)
end
it "does not show the table of payments requiring authorization" do

View File

@@ -24,16 +24,16 @@ describe '
context "with completed orders" do
let(:order_cycle) { create(:simple_order_cycle) }
let!(:d1o1) {
create(:completed_order_with_totals, distributor: distributor1, user: user, total: 10_000,
order_cycle: order_cycle)
create(:completed_order_with_totals, distributor: distributor1, user:, total: 10_000,
order_cycle:)
}
let!(:d1o2) {
create(:order_without_full_payment, distributor: distributor1, user: user, total: 5000,
order_cycle: order_cycle)
create(:order_without_full_payment, distributor: distributor1, user:, total: 5000,
order_cycle:)
}
let!(:d2o1) { create(:completed_order_with_totals, distributor: distributor2, user: user) }
let!(:d2o1) { create(:completed_order_with_totals, distributor: distributor2, user:) }
let!(:credit_order) {
create(:order_with_credit_payment, distributor: distributor_credit, user: user)
create(:order_with_credit_payment, distributor: distributor_credit, user:)
}
before do

View File

@@ -146,7 +146,7 @@ describe "Authentication" do
context "user with unconfirmed email" do
let(:email) { "test@example.org" }
let!(:user) {
Spree::User.create(email: email, unconfirmed_email: email, password: "secret")
Spree::User.create(email:, unconfirmed_email: email, password: "secret")
}
it "cannot reset password before confirming email" do

View File

@@ -29,7 +29,7 @@ describe "As a consumer, I want to see adjustment breakdown" do
let(:distributor) { create(:distributor_enterprise, charges_sales_tax: true) }
let(:supplier) { create(:supplier_enterprise) }
let!(:product_with_tax) {
create(:simple_product, supplier: supplier, price: 10, tax_category_id: tax_category.id)
create(:simple_product, supplier:, price: 10, tax_category_id: tax_category.id)
}
let!(:variant_with_tax) { product_with_tax.variants.first }
let!(:order_cycle) {
@@ -49,13 +49,13 @@ describe "As a consumer, I want to see adjustment breakdown" do
let!(:order_within_zone) {
create(
:order,
order_cycle: order_cycle, distributor: distributor, user: user_within_zone,
order_cycle:, distributor:, user: user_within_zone,
bill_address: address_within_zone, ship_address: address_within_zone,
state: "cart", line_items: [create(:line_item, variant: variant_with_tax, quantity: 1)]
)
}
let!(:order_outside_zone) {
create(:order, order_cycle: order_cycle, distributor: distributor, user: user_outside_zone,
create(:order, order_cycle:, distributor:, user: user_outside_zone,
bill_address: address_outside_zone, ship_address: address_outside_zone,
state: "cart", line_items: [create(:line_item, variant: variant_with_tax)])
}

View File

@@ -12,7 +12,7 @@ describe "As a consumer, I want to see adjustment breakdown" do
let!(:state) { create(:state, name: "Victoria") }
let!(:zone) { create(:zone_with_state_member, default_tax: false, member: state) }
let!(:address_within_zone) { create(:address, state: state) }
let!(:address_within_zone) { create(:address, state:) }
let!(:address_outside_zone) {
create(:address, state: create(:state, name: "Timbuktu", country: state.country))
}
@@ -27,12 +27,12 @@ describe "As a consumer, I want to see adjustment breakdown" do
let!(:tax_category) { create(:tax_category, name: "Veggies", is_default: false) }
let!(:tax_rate) {
create(:tax_rate, name: "Tax rate - included or not", amount: 0.13,
zone: zone, tax_category: tax_category, included_in_price: false)
zone:, tax_category:, included_in_price: false)
}
let(:distributor) { create(:distributor_enterprise, charges_sales_tax: true) }
let(:supplier) { create(:supplier_enterprise) }
let(:product_with_tax) {
create(:product, supplier: supplier, price: 10, tax_category_id: tax_category.id)
create(:product, supplier:, price: 10, tax_category_id: tax_category.id)
}
let(:variant_with_tax) { product_with_tax.variants.first }
let(:order_cycle) {
@@ -50,12 +50,12 @@ describe "As a consumer, I want to see adjustment breakdown" do
calculator: Calculator::FlatRate.new(preferred_amount: 0.00))
}
let(:order_within_zone) {
create(:order, order_cycle: order_cycle, distributor: distributor, user: user_within_zone,
create(:order, order_cycle:, distributor:, user: user_within_zone,
bill_address: address_within_zone, ship_address: address_within_zone,
state: "cart", line_items: [create(:line_item, variant: variant_with_tax)])
}
let(:order_outside_zone) {
create(:order, order_cycle: order_cycle, distributor: distributor, user: user_outside_zone,
create(:order, order_cycle:, distributor:, user: user_outside_zone,
bill_address: address_outside_zone, ship_address: address_outside_zone,
state: "cart", line_items: [create(:line_item, variant: variant_with_tax)])
}

View File

@@ -48,7 +48,7 @@ describe 'Multilingual' do
create(:simple_order_cycle, distributors: [distributor], variants: [product.variants.first])
}
let(:product) { create(:simple_product) }
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }
let(:order) { create(:order, order_cycle:, distributor:) }
before do
set_order order

View File

@@ -24,13 +24,13 @@ describe "full-page cart" do
create(:enterprise_fee, amount: 11.00, tax_category: product_with_tax.tax_category)
}
let(:product_with_tax) {
create(:taxed_product, supplier: supplier, zone: zone, price: 110.00, tax_rate_amount: 0.1,
create(:taxed_product, supplier:, zone:, price: 110.00, tax_rate_amount: 0.1,
included_in_price: true)
}
let(:product_with_fee) {
create(:simple_product, supplier: supplier, price: 0.86, on_hand: 100)
create(:simple_product, supplier:, price: 0.86, on_hand: 100)
}
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }
let(:order) { create(:order, order_cycle:, distributor:) }
before do
set_order order
@@ -271,12 +271,12 @@ describe "full-page cart" do
let(:address) { create(:address) }
let(:user) { create(:user, bill_address: address, ship_address: address) }
let!(:prev_order1) {
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor,
user: user)
create(:completed_order_with_totals, order_cycle:, distributor:,
user:)
}
let!(:prev_order2) {
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor,
user: user)
create(:completed_order_with_totals, order_cycle:, distributor:,
user:)
}
before do

View File

@@ -17,8 +17,8 @@ describe "As a consumer I want to check out my cart" do
coordinator: create(:distributor_enterprise),
variants: [product.variants.first])
}
let(:product) { create(:simple_product, supplier: supplier) }
let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }
let(:product) { create(:simple_product, supplier:) }
let(:order) { create(:order, order_cycle:, distributor:) }
let(:address) { create(:address, firstname: "Foo", lastname: "Bar") }
let(:user) { create(:user, bill_address: address, ship_address: address) }

View File

@@ -10,7 +10,7 @@ describe "Check out with Paypal" do
let(:distributor) { create(:distributor_enterprise) }
let(:supplier) { create(:supplier_enterprise) }
let(:product) { create(:simple_product, supplier: supplier) }
let(:product) { create(:simple_product, supplier:) }
let(:variant) { product.variants.first }
let(:order_cycle) {
create(
@@ -24,8 +24,8 @@ describe "Check out with Paypal" do
let(:order) {
create(
:order,
order_cycle: order_cycle,
distributor: distributor,
order_cycle:,
distributor:,
bill_address_id: nil,
ship_address_id: nil
)

View File

@@ -18,18 +18,18 @@ describe "As a consumer I want to check out my cart" do
coordinator: create(:distributor_enterprise), variants: [variant])
}
let(:enterprise_fee) { create(:enterprise_fee, amount: 1.23, tax_category: fee_tax_category) }
let(:fee_tax_rate) { create(:tax_rate, amount: 0.10, zone: zone, included_in_price: true) }
let(:fee_tax_rate) { create(:tax_rate, amount: 0.10, zone:, included_in_price: true) }
let(:fee_tax_category) { create(:tax_category, tax_rates: [fee_tax_rate]) }
let(:product) {
create(:taxed_product, supplier: supplier, price: 10, zone: zone, tax_rate_amount: 0.1,
create(:taxed_product, supplier:, price: 10, zone:, tax_rate_amount: 0.1,
included_in_price: true)
}
let(:variant) { product.variants.first }
let(:order) {
create(:order, order_cycle: order_cycle, distributor: distributor, bill_address_id: nil,
create(:order, order_cycle:, distributor:, bill_address_id: nil,
ship_address_id: nil)
}
let(:shipping_tax_rate) { create(:tax_rate, amount: 0.25, zone: zone, included_in_price: true) }
let(:shipping_tax_rate) { create(:tax_rate, amount: 0.25, zone:, included_in_price: true) }
let(:shipping_tax_category) { create(:tax_category, tax_rates: [shipping_tax_rate]) }
let(:free_shipping) {
@@ -185,7 +185,7 @@ describe "As a consumer I want to check out my cart" do
describe "when customer has already accepted T&Cs before" do
before do
customer = create(:customer, enterprise: order.distributor, user: user)
customer = create(:customer, enterprise: order.distributor, user:)
customer.update terms_and_conditions_accepted_at: Time.zone.now
end
@@ -235,7 +235,7 @@ describe "As a consumer I want to check out my cart" do
attachment: pdf_upload,
updated_at: 1.day.ago,
)
customer = create(:customer, enterprise: order.distributor, user: user)
customer = create(:customer, enterprise: order.distributor, user:)
customer.update(terms_and_conditions_accepted_at: Time.zone.now)
end
@@ -287,7 +287,7 @@ describe "As a consumer I want to check out my cart" do
context "with previous orders" do
let!(:prev_order) {
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor,
create(:completed_order_with_totals, order_cycle:, distributor:,
user: order.user)
}
@@ -396,7 +396,7 @@ describe "As a consumer I want to check out my cart" do
context "using FilterShippingMethods" do
let(:user) { create(:user) }
let(:customer) { create(:customer, user: user, enterprise: distributor) }
let(:customer) { create(:customer, user:, enterprise: distributor) }
it "shows shipping methods allowed by the rule" do
# No rules in effect

View File

@@ -16,7 +16,7 @@ describe "Check out with Stripe" do
let(:product) { create(:product, price: 10) }
let(:variant) { product.variants.first }
let(:order) {
create(:order, order_cycle: order_cycle, distributor: distributor, bill_address_id: nil,
create(:order, order_cycle:, distributor:, bill_address_id: nil,
ship_address_id: nil)
}
@@ -63,8 +63,8 @@ describe "Check out with Stripe" do
context "when the card is accepted" do
before do
stub_payment_intents_post_request order: order
stub_successful_capture_request order: order
stub_payment_intents_post_request(order:)
stub_successful_capture_request order:
end
it "completes checkout successfully" do
@@ -78,8 +78,8 @@ describe "Check out with Stripe" do
context "when the card is rejected" do
before do
stub_payment_intents_post_request order: order
stub_failed_capture_request order: order, response: { message: error_message }
stub_payment_intents_post_request(order:)
stub_failed_capture_request order:, response: { message: error_message }
end
it "shows an error message from the Stripe response" do
@@ -94,13 +94,13 @@ describe "Check out with Stripe" do
context "when the card needs extra SCA authorization" do
before do
stripe_redirect_url = checkout_path(payment_intent: "pi_123")
stub_payment_intents_post_request_with_redirect order: order,
stub_payment_intents_post_request_with_redirect order:,
redirect_url: stripe_redirect_url
end
describe "and the authorization succeeds" do
before do
stub_successful_capture_request order: order
stub_successful_capture_request order:
end
it "completes checkout successfully" do
@@ -119,7 +119,7 @@ describe "Check out with Stripe" do
describe "and the authorization fails" do
before do
stub_failed_capture_request order: order, response: { message: error_message }
stub_failed_capture_request order:, response: { message: error_message }
end
it "shows an error message from the Stripe response" do
@@ -137,12 +137,12 @@ describe "Check out with Stripe" do
context "with multiple payment attempts; one failed and one succeeded" do
before do
stub_payment_intents_post_request order: order
stub_payment_intents_post_request order:
end
it "records failed payment attempt and allows order completion" do
# First payment attempt is rejected
stub_failed_capture_request(order: order, response: { message: error_message })
stub_failed_capture_request(order:, response: { message: error_message })
checkout_with_stripe
expect(page).to have_content error_message
@@ -151,7 +151,7 @@ describe "Check out with Stripe" do
expect(order.payments.first.state).to eq "failed"
# Second payment attempt is accepted
stub_successful_capture_request order: order
stub_successful_capture_request(order:)
place_order
expect(page).to have_content "Confirmed"
@@ -180,8 +180,8 @@ describe "Check out with Stripe" do
response: { pm_id: "pm_123" }
)
stub_add_metadata_request(payment_method: "pm_123", response: {})
stub_payment_intents_post_request order: order
stub_successful_capture_request order: order
stub_payment_intents_post_request(order:)
stub_successful_capture_request(order:)
stub_customers_post_request email: "test@test.com" # First checkout with default details
stub_customers_post_request email: user.email # Second checkout with saved user details
stub_payment_method_attach_request
@@ -200,8 +200,8 @@ describe "Check out with Stripe" do
expect(user_credit_card.gateway_customer_profile_id).to eq "cus_A123"
# Prepare a second order
new_order = create(:order, user: user, order_cycle: order_cycle,
distributor: distributor, bill_address_id: nil,
new_order = create(:order, user:, order_cycle:,
distributor:, bill_address_id: nil,
ship_address_id: nil)
set_order(new_order)
add_product_to_cart(new_order, product, quantity: 10)

View File

@@ -7,7 +7,7 @@ describe "Order Management" do
describe "viewing a completed order" do
let!(:distributor) { create(:distributor_enterprise) }
let!(:customer) { create(:customer, user: user, enterprise: distributor) }
let!(:customer) { create(:customer, user:, enterprise: distributor) }
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor]) }
let!(:bill_address) { create(:address) }
@@ -16,18 +16,18 @@ describe "Order Management" do
let!(:order) do
create(:order_with_credit_payment,
customer: customer,
user: user,
distributor: distributor,
order_cycle: order_cycle)
customer:,
user:,
distributor:,
order_cycle:)
end
before do
# For some reason, both bill_address and ship_address are not set
# automatically.
order.update!(
bill_address: bill_address,
ship_address: ship_address
bill_address:,
ship_address:
)
end
@@ -37,8 +37,8 @@ describe "Order Management" do
create(:order_with_credit_payment,
user: nil,
email: "guest@user.com",
distributor: distributor,
order_cycle: order_cycle)
distributor:,
order_cycle:)
end
it "allows the user to see the details" do
@@ -107,16 +107,16 @@ describe "Order Management" do
let(:order) do
create(
:completed_order_with_totals,
order_cycle: order_cycle,
distributor: distributor,
user: user,
order_cycle:,
distributor:,
user:,
bill_address: address,
ship_address: address
)
end
let!(:item1) { order.reload.line_items.first }
let!(:item2) { create(:line_item, order: order) }
let!(:item3) { create(:line_item, order: order) }
let!(:item2) { create(:line_item, order:) }
let!(:item3) { create(:line_item, order:) }
before do
order.shipment.shipping_method.calculator.update(preferred_amount: 5.0)

View File

@@ -25,17 +25,17 @@ describe "As a consumer I want to view products" do
orders_close_at: 2.days.from_now)
}
let(:product) {
create(:simple_product, supplier: supplier, primary_taxon: taxon, properties: [property],
create(:simple_product, supplier:, primary_taxon: taxon, properties: [property],
name: "Beans")
}
let(:product2) {
create(:product, supplier: supplier, primary_taxon: taxon2, properties: [property2],
create(:product, supplier:, primary_taxon: taxon2, properties: [property2],
name: "Chickpeas")
}
let(:variant) { product.variants.first }
let(:variant2) { product2.variants.first }
let(:exchange1) { oc1.exchanges.to_enterprises(distributor).outgoing.first }
let(:order) { create(:order, distributor: distributor) }
let(:order) { create(:order, distributor:) }
before do
set_order order

View File

@@ -22,9 +22,9 @@ describe "As a consumer I want to shop with a distributor" do
coordinator: create(:distributor_enterprise),
orders_close_at: 3.days.from_now)
}
let(:product) { create(:simple_product, supplier: supplier, meta_keywords: "Domestic") }
let(:product) { create(:simple_product, supplier:, meta_keywords: "Domestic") }
let(:variant) { product.variants.first }
let(:order) { create(:order, distributor: distributor) }
let(:order) { create(:order, distributor:) }
before do
set_order order
@@ -91,7 +91,7 @@ describe "As a consumer I want to shop with a distributor" do
let(:custom_tab) { create(:custom_tab, title: "Custom") }
before do
distributor.update(custom_tab: custom_tab)
distributor.update(custom_tab:)
visit shop_path
end
@@ -259,7 +259,7 @@ describe "As a consumer I want to shop with a distributor" do
context "one having 20 products" do
before do
20.times do
product = create(:simple_product, supplier: supplier)
product = create(:simple_product, supplier:)
add_variant_to_order_cycle(exchange1, product.variants.first)
end
end
@@ -274,7 +274,7 @@ describe "As a consumer I want to shop with a distributor" do
context "another having 5 products" do
before do
5.times do
product = create(:simple_product, supplier: supplier)
product = create(:simple_product, supplier:)
add_variant_to_order_cycle(exchange2, product.variants.first)
end
end
@@ -289,10 +289,10 @@ describe "As a consumer I want to shop with a distributor" do
end
describe "after selecting an order cycle with products visible" do
let(:variant1) { create(:variant, product: product, price: 20) }
let(:variant2) { create(:variant, product: product, price: 30, display_name: "Badgers") }
let(:variant1) { create(:variant, product:, price: 20) }
let(:variant2) { create(:variant, product:, price: 30, display_name: "Badgers") }
let(:product2) {
create(:simple_product, supplier: supplier, name: "Meercats", meta_keywords: "Wild")
create(:simple_product, supplier:, name: "Meercats", meta_keywords: "Wild")
}
let(:variant3) { create(:variant, product: product2, price: 40, display_name: "Ferrets") }
let(:exchange) { Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id) }
@@ -350,7 +350,7 @@ describe "As a consumer I want to shop with a distributor" do
end
context "when supplier uses property" do
let(:product3) { create(:simple_product, supplier: supplier, inherits_properties: false) }
let(:product3) { create(:simple_product, supplier:, inherits_properties: false) }
before do
add_variant_to_order_cycle(exchange, product3.variants.first)
@@ -416,7 +416,7 @@ describe "As a consumer I want to shop with a distributor" do
let(:product2) { create(:simple_product, group_buy: false) }
describe "with variants on the product" do
let(:variant) { create(:variant, product: product, on_hand: 10 ) }
let(:variant) { create(:variant, product:, on_hand: 10 ) }
before do
add_variant_to_order_cycle(exchange, variant)
set_order_cycle(order, oc1)
@@ -452,8 +452,8 @@ describe "As a consumer I want to shop with a distributor" do
describe "adding and removing products from cart" do
let(:exchange) { Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id) }
let(:product) { create(:simple_product) }
let(:variant) { create(:variant, product: product) }
let(:variant2) { create(:variant, product: product) }
let(:variant) { create(:variant, product:) }
let(:variant2) { create(:variant, product:) }
before do
add_variant_to_order_cycle(exchange, variant)
@@ -645,7 +645,7 @@ describe "As a consumer I want to shop with a distributor" do
context "when the soft-deleted variant has an associated override" do
describe "adding the soft-deleted variant to the cart" do
let!(:variant_override) {
create(:variant_override, variant: variant, hub: distributor, count_on_hand: 100)
create(:variant_override, variant:, hub: distributor, count_on_hand: 100)
}
it "handles it as if the variant has gone out of stock" do
@@ -687,7 +687,7 @@ describe "As a consumer I want to shop with a distributor" do
context "when shopping requires a customer" do
let(:exchange) { Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id) }
let(:product) { create(:simple_product) }
let(:variant) { create(:variant, product: product) }
let(:variant) { create(:variant, product:) }
let(:unregistered_customer) { create(:customer, user: nil, enterprise: distributor) }
before do
@@ -726,7 +726,7 @@ describe "As a consumer I want to shop with a distributor" do
end
context "as customer" do
let!(:customer) { create(:customer, user: user, enterprise: distributor) }
let!(:customer) { create(:customer, user:, enterprise: distributor) }
it "shows just products" do
visit shop_path
@@ -735,7 +735,7 @@ describe "As a consumer I want to shop with a distributor" do
end
context "as a manager" do
let!(:role) { create(:enterprise_role, user: user, enterprise: distributor) }
let!(:role) { create(:enterprise_role, user:, enterprise: distributor) }
it "shows just products" do
visit shop_path

View File

@@ -15,9 +15,9 @@ describe "As a consumer, I want to check unit price information for a product" d
coordinator: create(:distributor_enterprise),
orders_close_at: 2.days.from_now)
}
let(:product) { create(:simple_product, supplier: supplier) }
let(:product) { create(:simple_product, supplier:) }
let(:variant) { product.variants.first }
let(:order) { create(:order, distributor: distributor) }
let(:order) { create(:order, distributor:) }
let(:exchange1) { oc1.exchanges.to_enterprises(distributor).outgoing.first }
let(:user) { create(:user, password: "password", password_confirmation: "password") }

View File

@@ -33,28 +33,28 @@ describe "shopping with variant overrides defined" do
}
let(:product4_variant1) { create(:variant, product: product4, price: 77.77, unit_value: 7) }
let!(:product1_variant1_override) {
create(:variant_override, :use_producer_stock_settings, hub: hub, variant: product1_variant1,
create(:variant_override, :use_producer_stock_settings, hub:, variant: product1_variant1,
price: 55.55, count_on_hand: nil,
default_stock: nil, resettable: false)
}
let!(:product1_variant2_override) {
create(:variant_override, hub: hub, variant: product1_variant2, count_on_hand: 0,
create(:variant_override, hub:, variant: product1_variant2, count_on_hand: 0,
default_stock: nil, resettable: false)
}
let!(:product2_variant1_override) {
create(:variant_override, hub: hub, variant: product2_variant1, count_on_hand: 0,
create(:variant_override, hub:, variant: product2_variant1, count_on_hand: 0,
default_stock: nil, resettable: false)
}
let!(:product1_variant3_override) {
create(:variant_override, hub: hub, variant: product1_variant3, count_on_hand: 3,
create(:variant_override, hub:, variant: product1_variant3, count_on_hand: 3,
default_stock: nil, resettable: false)
}
let!(:product3_variant1_override) {
create(:variant_override, hub: hub, variant: product3_variant1, count_on_hand: 0,
create(:variant_override, hub:, variant: product3_variant1, count_on_hand: 0,
default_stock: nil, resettable: false)
}
let!(:product3_variant2_override) {
create(:variant_override, hub: hub, variant: product3_variant2, count_on_hand: 6,
create(:variant_override, hub:, variant: product3_variant2, count_on_hand: 6,
default_stock: nil, resettable: false)
}
let(:enterprise_fee) {
@@ -63,7 +63,7 @@ describe "shopping with variant overrides defined" do
Calculator::FlatPercentPerItem.new(preferred_flat_percent: 10))
}
let!(:product4_variant1_override) {
create(:variant_override, hub: hub, variant: product4_variant1, count_on_hand: nil,
create(:variant_override, hub:, variant: product4_variant1, count_on_hand: nil,
on_demand: true, default_stock: nil, resettable: false)
}

View File

@@ -6,7 +6,7 @@ describe "User password confirm/reset page" do
include UIComponentHelper
let(:email) { "test@example.org" }
let(:user) { Spree::User.create(email: email, unconfirmed_email: email, password: "secret") }
let(:user) { Spree::User.create(email:, unconfirmed_email: email, password: "secret") }
describe "can set a password" do
before do
@@ -48,7 +48,7 @@ describe "User password confirm/reset page" do
let(:reset_password_token) { user.regenerate_reset_password_token }
it "has the right error when password aren't the same" do
visit spree.edit_spree_user_password_path(reset_password_token: reset_password_token)
visit spree.edit_spree_user_password_path(reset_password_token:)
expect(page).to have_text "Change my password"
@@ -74,7 +74,7 @@ describe "User password confirm/reset page" do
user.reset_password_sent_at = 2.days.ago
user.save!
visit spree.edit_spree_user_password_path(reset_password_token: reset_password_token)
visit spree.edit_spree_user_password_path(reset_password_token:)
fill_in "Password", with: "my secret"
fill_in "Password Confirmation", with: "my secret"
@@ -84,7 +84,7 @@ describe "User password confirm/reset page" do
end
it "can actually reset its own password" do
visit spree.edit_spree_user_password_path(reset_password_token: reset_password_token)
visit spree.edit_spree_user_password_path(reset_password_token:)
fill_in "Password", with: "my secret"
fill_in "Password Confirmation", with: "my secret"

View File

@@ -19,13 +19,13 @@ describe 'White label setting' do
coordinator: create(:distributor_enterprise),
variants: [product.variants.first])
}
let!(:order) { create(:order, distributor: distributor, order_cycle: order_cycle) }
let!(:order) { create(:order, distributor:, order_cycle:) }
let(:complete_order) {
create(:order_with_credit_payment,
user: nil,
email: "guest@user.com",
distributor: distributor,
order_cycle: order_cycle)
distributor:,
order_cycle:)
}
let(:ofn_navigation) { 'ul.nav-main-menu' }
@@ -435,7 +435,7 @@ describe 'White label setting' do
let(:custom_tab) { create(:custom_tab) }
before do
distributor.update(custom_tab: custom_tab)
distributor.update(custom_tab:)
visit main_app.enterprise_shop_path(distributor)
end

View File

@@ -12,13 +12,13 @@ Capybara.register_driver(:cuprite) do |app|
app,
**{
window_size: [1280, 800],
browser_options: browser_options,
browser_options:,
process_timeout: 60,
timeout: 60,
# Don't load scripts from external sources, like google maps or stripe
url_whitelist: ["http://localhost", "http://0.0.0.0", "http://127.0.0.1"],
inspector: true,
headless: headless,
headless:,
js_errors: true,
}
)

View File

@@ -18,7 +18,7 @@ describe "spree/orders/edit.html.haml" do
assign(:order, order)
assign(:insufficient_stock_lines, [])
allow(view).to receive_messages(
order: order,
order:,
current_order: order,
pickup_time: 'time',
spree_current_user: create(:user),

View File

@@ -13,7 +13,7 @@ describe "spree/shared/_order_details.html.haml" do
before do
assign(:order, order)
allow(view).to receive_messages(
order: order,
order:,
current_order: order
)
end
@@ -38,12 +38,12 @@ describe "spree/shared/_order_details.html.haml" do
first_payment = order.payments.first
second_payment = create(
:payment,
order: order,
order:,
payment_method: create(:payment_method, name: "Cash")
)
third_payment = create(
:payment,
order: order,
order:,
payment_method: create(:payment_method, name: "Credit")
)
first_payment.update_column(:created_at, 3.days.ago)