Skip to content

Commit

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

Fix Style/HashSyntax 10/13
  • Loading branch information
mkllnk authored Sep 25, 2023
2 parents aa489d4 + 232ffb1 commit 51f125e
Show file tree
Hide file tree
Showing 31 changed files with 169 additions and 199 deletions.
30 changes: 0 additions & 30 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -875,36 +875,6 @@ Style/HashLikeCase:
# SupportedShorthandSyntax: always, never, either, consistent
Style/HashSyntax:
Exclude:
- 'spec/models/spree/product_spec.rb'
- 'spec/models/spree/return_authorization_spec.rb'
- 'spec/models/spree/shipment_spec.rb'
- 'spec/models/spree/shipping_method_spec.rb'
- 'spec/models/spree/shipping_rate_spec.rb'
- 'spec/models/spree/stock/availability_validator_spec.rb'
- 'spec/models/spree/stock_movement_spec.rb'
- 'spec/models/spree/tax_rate_spec.rb'
- 'spec/models/spree/user_spec.rb'
- 'spec/models/spree/variant_spec.rb'
- 'spec/models/spree/zone_spec.rb'
- 'spec/models/stripe_account_spec.rb'
- 'spec/models/variant_override_spec.rb'
- 'spec/models/voucher_spec.rb'
- 'spec/queries/complete_orders_with_balance_spec.rb'
- 'spec/queries/customers_with_balance_spec.rb'
- 'spec/queries/outstanding_balance_spec.rb'
- 'spec/queries/payments_requiring_action_spec.rb'
- 'spec/requests/api/v1/customers_spec.rb'
- 'spec/requests/checkout/failed_checkout_spec.rb'
- 'spec/requests/checkout/paypal_spec.rb'
- 'spec/requests/checkout/routes_spec.rb'
- 'spec/requests/checkout/stripe_sca_spec.rb'
- 'spec/requests/voucher_adjustments_spec.rb'
- 'spec/serializers/api/admin/customer_serializer_spec.rb'
- 'spec/serializers/api/admin/for_order_cycle/supplied_product_serializer_spec.rb'
- 'spec/serializers/api/admin/index_enterprise_serializer_spec.rb'
- 'spec/serializers/api/admin/order_serializer_spec.rb'
- 'spec/serializers/api/admin/variant_override_serializer_spec.rb'
- 'spec/serializers/api/enterprise_serializer_spec.rb'
- 'spec/serializers/api/order_serializer_spec.rb'
- 'spec/serializers/api/product_serializer_spec.rb'
- 'spec/services/cap_quantity_spec.rb'
Expand Down
44 changes: 22 additions & 22 deletions spec/models/spree/product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Spree

context "product has variants" do
before do
product.reload.variants << create(:variant, product: product)
product.reload.variants << create(:variant, product:)
end

context "#destroy" do
Expand Down Expand Up @@ -148,7 +148,7 @@ module Spree
let(:stock_item) { variant.stock_items.first }

it "doesnt raise ReadOnlyRecord error" do
Spree::StockMovement.create!(stock_item: stock_item, quantity: 1)
Spree::StockMovement.create!(stock_item:, quantity: 1)
expect { product.destroy }.not_to raise_error
end
end
Expand Down Expand Up @@ -195,7 +195,7 @@ module Spree
context "when the product has variants" do
let(:product) do
product = create(:simple_product)
create(:variant, product: product)
create(:variant, product:)
product.reload
end

Expand Down Expand Up @@ -512,7 +512,7 @@ module Spree
it "shows only products for given user" do
user = create(:user)
user.spree_roles = []
@e1.enterprise_roles.build(user: user).save
@e1.enterprise_roles.build(user:).save

product = Product.managed_by user
expect(product.count).to eq(1)
Expand All @@ -535,17 +535,17 @@ module Spree
let!(:hidden_variant) { create(:variant) }

let!(:product) { create(:product) }
let!(:visible_variant1) { create(:variant, product: product) }
let!(:visible_variant2) { create(:variant, product: product) }
let!(:visible_variant1) { create(:variant, product:) }
let!(:visible_variant2) { create(:variant, product:) }

let!(:hidden_inventory_item) {
create(:inventory_item, enterprise: enterprise, variant: hidden_variant, visible: false )
create(:inventory_item, enterprise:, variant: hidden_variant, visible: false )
}
let!(:visible_inventory_item1) {
create(:inventory_item, enterprise: enterprise, variant: visible_variant1, visible: true )
create(:inventory_item, enterprise:, variant: visible_variant1, visible: true )
}
let!(:visible_inventory_item2) {
create(:inventory_item, enterprise: enterprise, variant: visible_variant2, visible: true )
create(:inventory_item, enterprise:, variant: visible_variant2, visible: true )
}

let!(:products) { Spree::Product.visible_for(enterprise) }
Expand Down Expand Up @@ -604,7 +604,7 @@ module Spree

it "returns producer properties as a hash" do
supplier = create(:supplier_enterprise)
product = create(:simple_product, supplier: supplier)
product = create(:simple_product, supplier:)

supplier.set_producer_property 'Organic Certified', 'NASAA 54321'
property = supplier.properties.last
Expand All @@ -616,7 +616,7 @@ module Spree

it "overrides producer properties with product properties" do
supplier = create(:supplier_enterprise)
product = create(:simple_product, supplier: supplier)
product = create(:simple_product, supplier:)

product.set_property 'Organic Certified', 'NASAA 12345'
supplier.set_producer_property 'Organic Certified', 'NASAA 54321'
Expand All @@ -629,7 +629,7 @@ module Spree

context "when product has an inherit_properties value set to true" do
let(:supplier) { create(:supplier_enterprise) }
let(:product) { create(:simple_product, supplier: supplier, inherits_properties: true) }
let(:product) { create(:simple_product, supplier:, inherits_properties: true) }

it "inherits producer properties" do
supplier.set_producer_property 'Organic Certified', 'NASAA 54321'
Expand All @@ -643,7 +643,7 @@ module Spree

context "when product has an inherit_properties value set to false" do
let(:supplier) { create(:supplier_enterprise) }
let(:product) { create(:simple_product, supplier: supplier, inherits_properties: false) }
let(:product) { create(:simple_product, supplier:, inherits_properties: false) }

it "does not inherit producer properties" do
supplier.set_producer_property 'Organic Certified', 'NASAA 54321'
Expand All @@ -654,7 +654,7 @@ module Spree

it "sorts by position" do
supplier = create(:supplier_enterprise)
product = create(:simple_product, supplier: supplier)
product = create(:simple_product, supplier:)

pa = Spree::Property.create! name: 'A', presentation: 'A'
pb = Spree::Property.create! name: 'B', presentation: 'B'
Expand Down Expand Up @@ -748,21 +748,21 @@ module Spree
end

context "when the variants do not have an import date" do
let!(:variant_a) { create(:variant, product: product, import_date: nil) }
let!(:variant_b) { create(:variant, product: product, import_date: nil) }
let!(:variant_a) { create(:variant, product:, import_date: nil) }
let!(:variant_b) { create(:variant, product:, import_date: nil) }

it "returns nil" do
expect(product.import_date).to be_nil
end
end

context "when some variants have import date and some do not" do
let!(:variant_a) { create(:variant, product: product, import_date: nil) }
let!(:variant_a) { create(:variant, product:, import_date: nil) }
let!(:variant_b) {
create(:variant, product: product, import_date: reference_time - 1.hour)
create(:variant, product:, import_date: reference_time - 1.hour)
}
let!(:variant_c) {
create(:variant, product: product, import_date: reference_time - 2.hours)
create(:variant, product:, import_date: reference_time - 2.hours)
}

it "returns the most recent import date" do
Expand All @@ -772,13 +772,13 @@ module Spree

context "when all variants have import date" do
let!(:variant_a) {
create(:variant, product: product, import_date: reference_time - 2.hours)
create(:variant, product:, import_date: reference_time - 2.hours)
}
let!(:variant_b) {
create(:variant, product: product, import_date: reference_time - 1.hour)
create(:variant, product:, import_date: reference_time - 1.hour)
}
let!(:variant_c) {
create(:variant, product: product, import_date: reference_time - 3.hours)
create(:variant, product:, import_date: reference_time - 3.hours)
}

it "returns the most recent import date" do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/spree/return_authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Spree::ReturnAuthorization do
let(:order) { create(:shipped_order) }
let(:variant) { order.shipments.first.inventory_units.first.variant }
let(:return_authorization) { Spree::ReturnAuthorization.new(order: order) }
let(:return_authorization) { Spree::ReturnAuthorization.new(order:) }

context "save" do
it "should be invalid when order has no inventory units" do
Expand Down Expand Up @@ -87,7 +87,7 @@
expect(Spree::Adjustment).to receive(:create).with(
amount: -20,
label: 'RMA credit',
order: order,
order:,
adjustable: order,
originator: return_authorization
)
Expand Down
16 changes: 8 additions & 8 deletions spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let(:order) { build(:order) }
let(:shipping_method) { build(:shipping_method, name: "UPS") }
let(:shipment) do
shipment = Spree::Shipment.new order: order
allow(shipment).to receive_messages(shipping_method: shipping_method)
shipment = Spree::Shipment.new(order:)
allow(shipment).to receive_messages(shipping_method:)
shipment.state = 'pending'
shipment
end
Expand Down Expand Up @@ -106,7 +106,7 @@
end

context 'refresh_rates' do
let(:mock_estimator) { double('estimator', shipping_rates: shipping_rates) }
let(:mock_estimator) { double('estimator', shipping_rates:) }

it 'should request new rates, and maintain shipping_method selection' do
expect(OrderManagement::Stock::Estimator).
Expand Down Expand Up @@ -143,13 +143,13 @@
includes: [
build_stubbed(
:inventory_unit,
shipment: shipment,
shipment:,
variant: build_stubbed(:variant),
state: 'on_hand'
),
build_stubbed(
:inventory_unit,
shipment: shipment,
shipment:,
variant: build_stubbed(:variant),
state: 'backordered'
)
Expand Down Expand Up @@ -288,7 +288,7 @@
end

it 'restocks the items' do
unit = double(:inventory_unit, variant: variant)
unit = double(:inventory_unit, variant:)
allow(unit).to receive(:quantity) { 1 }
allow(shipment).to receive_message_chain(:inventory_units,
:group_by,
Expand All @@ -312,7 +312,7 @@
end

it 'unstocks the items' do
unit = create(:inventory_unit, variant: variant)
unit = create(:inventory_unit, variant:)
allow(unit).to receive(:quantity) { 1 }
allow(shipment).to receive_message_chain(:inventory_units,
:group_by,
Expand Down Expand Up @@ -463,7 +463,7 @@
{ variant_id: variant.id, state: 'on_hand', order_id: order.id }
end

before { allow(shipment).to receive_messages inventory_units: inventory_units }
before { allow(shipment).to receive_messages(inventory_units:) }

it "associates variant and order" do
expect(inventory_units).to receive(:create).with(params)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/spree/shipping_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ module Spree
let!(:shipping_method) { create(:shipping_method) }
let!(:shipment) do
shipment = create(:shipment)
shipment.shipping_rates.create!(shipping_method: shipping_method)
shipment.shipping_rates.create!(shipping_method:)
shipment
end

Expand Down
4 changes: 2 additions & 2 deletions spec/models/spree/shipping_rate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
let(:shipment) { create(:shipment) }
let(:shipping_method) { build_stubbed(:shipping_method) }
let(:shipping_rate) {
Spree::ShippingRate.new(shipment: shipment,
shipping_method: shipping_method,
Spree::ShippingRate.new(shipment:,
shipping_method:,
cost: 10.55)
}

Expand Down
2 changes: 1 addition & 1 deletion spec/models/spree/stock/availability_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module Stock
let(:variant) { line_item.variant }
let(:vo_stock) { 999 }
let!(:variant_override) {
create(:variant_override, variant: variant, hub: hub, count_on_hand: vo_stock)
create(:variant_override, variant:, hub:, count_on_hand: vo_stock)
}

context "when the override has stock" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/spree/stock_movement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Spree::StockMovement do
let(:stock_location) { create(:stock_location_with_items) }
let(:stock_item) { stock_location.stock_items.order(:id).first }
subject { build(:stock_movement, stock_item: stock_item) }
subject { build(:stock_movement, stock_item:) }

it 'should belong to a stock item' do
expect(subject).to respond_to(:stock_item)
Expand Down
Loading

0 comments on commit 51f125e

Please sign in to comment.