Skip to content

Commit

Permalink
Merge pull request openfoodfoundation#11586 from macanudo527/fix_styl…
Browse files Browse the repository at this point in the history
…ehash_11

Fix Style/HashSyntax 12/13
  • Loading branch information
mkllnk authored Oct 2, 2023
2 parents 350ca3b + f3382d7 commit b122c93
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 190 deletions.
30 changes: 0 additions & 30 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -879,36 +879,6 @@ Style/HashLikeCase:
# SupportedShorthandSyntax: always, never, either, consistent
Style/HashSyntax:
Exclude:
- 'spec/services/tax_rate_finder_spec.rb'
- 'spec/services/user_default_address_setter_spec.rb'
- 'spec/services/variants_stock_levels_spec.rb'
- 'spec/services/voucher_adjustments_service_spec.rb'
- 'spec/support/controller_helper.rb'
- 'spec/support/controller_requests_helper.rb'
- 'spec/support/request/stripe_stubs.rb'
- 'spec/support/request/ui_component_helper.rb'
- 'spec/support/request/web_helper.rb'
- 'spec/system/admin/adjustments_spec.rb'
- 'spec/system/admin/bulk_product_update_spec.rb'
- 'spec/system/admin/configuration/states_spec.rb'
- 'spec/system/admin/configuration/tax_rates_spec.rb'
- 'spec/system/admin/customers_spec.rb'
- 'spec/system/admin/enterprises_spec.rb'
- 'spec/system/admin/invoice_print_spec.rb'
- 'spec/system/admin/order_cycles/complex_creating_specific_time_spec.rb'
- 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
- 'spec/system/admin/order_spec.rb'
- 'spec/system/admin/orders_spec.rb'
- 'spec/system/admin/payments_stripe_spec.rb'
- 'spec/system/admin/reports/enterprise_fee_summaries_spec.rb'
- 'spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_order_spec.rb'
- 'spec/system/admin/reports/orders_and_fulfillment_spec.rb'
- 'spec/system/admin/reports/packing_report_spec.rb'
- 'spec/system/admin/reports/payments_report_spec.rb'
- 'spec/system/admin/reports/revenues_by_hub_spec.rb'
- 'spec/system/admin/reports/sales_tax/sales_tax_totals_by_order_spec.rb'
- 'spec/system/admin/reports/sales_tax/sales_tax_totals_by_producer_spec.rb'
- 'spec/system/admin/reports_spec.rb'
- 'spec/system/admin/subscriptions_spec.rb'
- 'spec/system/admin/tag_rules_spec.rb'
Expand Down
10 changes: 5 additions & 5 deletions spec/services/tax_rate_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
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 }

Expand Down
2 changes: 1 addition & 1 deletion spec/services/user_default_address_setter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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) }

Expand Down
2 changes: 1 addition & 1 deletion spec/services/variants_stock_levels_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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) }
Expand Down
6 changes: 3 additions & 3 deletions spec/services/voucher_adjustments_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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
Expand Down Expand Up @@ -168,7 +168,7 @@

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 }
Expand All @@ -177,7 +177,7 @@
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) }

Expand Down
2 changes: 1 addition & 1 deletion spec/support/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def controller_login_as_enterprise_user(enterprises)
user = create(:user)
user.spree_roles = []
enterprises.each do |enterprise|
enterprise.enterprise_roles.create!(user: user)
enterprise.enterprise_roles.create!(user:)
end
user
end
Expand Down
6 changes: 3 additions & 3 deletions spec/support/controller_requests_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def process_json_action(action, params = {}, session = nil, flash = nil, method

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
6 changes: 3 additions & 3 deletions spec/support/request/stripe_stubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def stub_payment_methods_post_request(request: { payment_method: "pm_123" }, res
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

Expand All @@ -44,7 +44,7 @@ def stub_retrieve_payment_method_request(payment_method_id = "pm_1234")
# 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
Expand Down Expand Up @@ -174,7 +174,7 @@ def get_customer_payment_methods_response_mock(options)
body: JSON.generate(
object: "list",
has_more: false,
data: [{ id: payment_method, card: { fingerprint: fingerprint } }],
data: [{ id: payment_method, card: { fingerprint: } }],
),
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/request/ui_component_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def click_reset_password_button

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
Expand Down
4 changes: 2 additions & 2 deletions spec/support/request/web_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ def have_input(name, opts = {})

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 = {})
Expand Down
14 changes: 7 additions & 7 deletions spec/system/admin/adjustments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
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) }
Expand All @@ -33,7 +33,7 @@

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
Expand Down Expand Up @@ -124,7 +124,7 @@
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
Expand All @@ -145,7 +145,7 @@
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
Expand All @@ -167,7 +167,7 @@
# 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!
Expand Down
6 changes: 3 additions & 3 deletions spec/system/admin/bulk_product_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
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
}
Expand Down Expand Up @@ -269,8 +269,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/configuration/states_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def go_to_states_page
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)
Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin/configuration/tax_rates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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") }

Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/customers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
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)
}

Expand Down Expand Up @@ -162,7 +162,7 @@

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)
}

Expand Down
4 changes: 2 additions & 2 deletions spec/system/admin/enterprises_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@
}

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"
Expand Down Expand Up @@ -842,7 +842,7 @@

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
Expand Down
Loading

0 comments on commit b122c93

Please sign in to comment.