Fix Style/HashSyntax

This commit is contained in:
Neal Chambers
2023-09-19 08:25:56 +09:00
parent c6e9a84633
commit 42a6a02353
30 changed files with 202 additions and 202 deletions

View File

@@ -27,7 +27,7 @@ module Api
end
describe "#update" do
let(:customer) { create(:customer, user: user) }
let(:customer) { create(:customer, user:) }
let(:params) { { format: :json, id: customer.id, customer: { code: '123' } } }
context "as a user who is not associated with the customer" do

View File

@@ -78,7 +78,7 @@ describe Api::V0::EnterprisesController, type: :controller do
let(:enterprise_manager) { create(:user) }
before do
enterprise_manager.enterprise_roles.build(enterprise: enterprise).save
enterprise_manager.enterprise_roles.build(enterprise:).save
allow(controller).to receive(:spree_current_user) { enterprise_manager }
end
@@ -90,7 +90,7 @@ describe Api::V0::EnterprisesController, type: :controller do
end
it "I can update enterprise logo image" do
api_post :update_image, logo: logo, id: enterprise.id
api_post :update_image, logo:, id: enterprise.id
expect(response.status).to eq 200
expect(response.content_type).to eq "text/html"
expect(response.body).to match /logo\.png$/

View File

@@ -22,7 +22,7 @@ module Api
let!(:product3) { create(:product, primary_taxon: taxon2) }
let!(:product4) { create(:product, primary_taxon: taxon3, properties: [property3]) }
let!(:user) { create(:user) }
let(:customer) { create(:customer, user: user, enterprise: distributor) }
let(:customer) { create(:customer, user:, enterprise: distributor) }
before do
exchange.variants << product1.variants.first
@@ -95,9 +95,9 @@ module Api
let!(:supplier) { create(:supplier_enterprise, properties: [supplier_property]) }
before do
product1.update!(supplier: supplier)
product2.update!(supplier: supplier)
product3.update!(supplier: supplier, inherits_properties: false)
product1.update!(supplier:)
product2.update!(supplier:)
product3.update!(supplier:, inherits_properties: false)
end
it "filter out the product that don't inherits from supplier properties" do
@@ -248,16 +248,16 @@ module Api
context "with custom taxon ordering applied and duplicate product names in the order cycle" do
let!(:supplier) { create(:supplier_enterprise) }
let!(:product5) {
create(:product, name: "Duplicate name", primary_taxon: taxon3, supplier: supplier)
create(:product, name: "Duplicate name", primary_taxon: taxon3, supplier:)
}
let!(:product6) {
create(:product, name: "Duplicate name", primary_taxon: taxon3, supplier: supplier)
create(:product, name: "Duplicate name", primary_taxon: taxon3, supplier:)
}
let!(:product7) {
create(:product, name: "Duplicate name", primary_taxon: taxon2, supplier: supplier)
create(:product, name: "Duplicate name", primary_taxon: taxon2, supplier:)
}
let!(:product8) {
create(:product, name: "Duplicate name", primary_taxon: taxon2, supplier: supplier)
create(:product, name: "Duplicate name", primary_taxon: taxon2, supplier:)
}
before do

View File

@@ -12,7 +12,7 @@ module Api
let!(:distributor) { create(:distributor_enterprise) }
let!(:coordinator) { create(:distributor_enterprise) }
let!(:order_cycle) { create(:simple_order_cycle, coordinator: coordinator) }
let!(:order_cycle) { create(:simple_order_cycle, coordinator:) }
describe '#index' do
let!(:distributor2) { create(:distributor_enterprise) }
@@ -20,18 +20,18 @@ module Api
let!(:supplier) { create(:supplier_enterprise) }
let!(:order_cycle2) { create(:simple_order_cycle, coordinator: coordinator2) }
let!(:order1) do
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
distributor: distributor, billing_address: create(:address, lastname: "c"),
create(:order, order_cycle:, state: 'complete', completed_at: Time.zone.now,
distributor:, billing_address: create(:address, lastname: "c"),
total: 5.0)
end
let!(:order2) do
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
create(:order, order_cycle:, state: 'complete', completed_at: Time.zone.now,
distributor: distributor2, billing_address: create(:address, lastname: "a"),
total: 10.0)
end
let!(:order3) do
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
distributor: distributor, billing_address: create(:address, lastname: "b"),
create(:order, order_cycle:, state: 'complete', completed_at: Time.zone.now,
distributor:, billing_address: create(:address, lastname: "b"),
total: 1.0 )
end
let!(:order4) do
@@ -42,19 +42,19 @@ module Api
let!(:order5) { create(:order, state: 'cart', completed_at: nil) }
let!(:line_item1) do
create(:line_item_with_shipment, order: order1,
product: create(:product, supplier: supplier))
product: create(:product, supplier:))
end
let!(:line_item2) do
create(:line_item_with_shipment, order: order2,
product: create(:product, supplier: supplier))
product: create(:product, supplier:))
end
let!(:line_item3) do
create(:line_item_with_shipment, order: order2,
product: create(:product, supplier: supplier))
product: create(:product, supplier:))
end
let!(:line_item4) do
create(:line_item_with_shipment, order: order3,
product: create(:product, supplier: supplier))
product: create(:product, supplier:))
end
context 'as a regular user' do
@@ -152,8 +152,8 @@ module Api
context "with an order without billing address" do
let!(:order7) {
create(:order_with_line_items, billing_address: nil, order_cycle: order_cycle,
distributor: distributor)
create(:order_with_line_items, billing_address: nil, order_cycle:,
distributor:)
}
it 'can show orders without bill address' do
@@ -200,7 +200,7 @@ module Api
describe "#show" do
let!(:order) {
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor )
create(:completed_order_with_totals, order_cycle:, distributor: )
}
context "Resource not found" do
@@ -253,7 +253,7 @@ module Api
context "as distributor owner" do
let!(:order) {
create(:completed_order_with_fees, order_cycle: order_cycle, distributor: distributor )
create(:completed_order_with_fees, order_cycle:, distributor: )
}
before { allow(controller).to receive(:spree_current_user) { order.distributor.owner } }
@@ -318,13 +318,13 @@ module Api
}
let!(:order) {
create(:order_with_totals_and_distribution,
user: user, distributor: distributor, order_cycle: order_cycle,
user:, distributor:, order_cycle:,
state: 'complete', payment_state: 'balance_due')
}
before do
order.finalize!
order.payments << create(:check_payment, order: order, amount: order.total)
order.payments << create(:check_payment, order:, amount: order.total)
allow(controller).to receive(:spree_current_user) { order.distributor.owner }
end

View File

@@ -8,10 +8,10 @@ describe Api::V0::ProductsController, type: :controller do
let(:supplier) { create(:supplier_enterprise) }
let(:supplier2) { create(:supplier_enterprise) }
let!(:product) { create(:product, supplier: supplier) }
let!(:product) { create(:product, supplier:) }
let!(:other_product) { create(:product) }
let(:product_other_supplier) { create(:product, supplier: supplier2) }
let(:product_with_image) { create(:product_with_image, supplier: supplier) }
let(:product_with_image) { create(:product_with_image, supplier:) }
let(:all_attributes) { ["id", "name", "variants"] }
let(:variants_attributes) {
["id", "options_text", "unit_value", "unit_description", "unit_to_display", "on_demand",
@@ -210,7 +210,7 @@ describe Api::V0::ProductsController, type: :controller do
describe '#bulk_products' do
context "as an enterprise user" do
let!(:taxon) { create(:taxon) }
let!(:product2) { create(:product, supplier: supplier, primary_taxon: taxon) }
let!(:product2) { create(:product, supplier:, primary_taxon: taxon) }
let!(:product3) { create(:product, supplier: supplier2, primary_taxon: taxon) }
let!(:product4) { create(:product, supplier: supplier2) }
let(:current_api_user) { supplier_enterprise_user(supplier) }
@@ -271,7 +271,7 @@ describe Api::V0::ProductsController, type: :controller do
def supplier_enterprise_user(enterprise)
user = create(:user)
user.enterprise_roles.create(enterprise: enterprise)
user.enterprise_roles.create(enterprise:)
user
end

View File

@@ -21,7 +21,7 @@ describe Api::V0::ReportsController, type: :controller do
describe "packing report" do
context "as an enterprise user with full order permissions (distributor)" do
let!(:distributor) { create(:distributor_enterprise) }
let!(:order) { create(:completed_order_with_totals, distributor: distributor) }
let!(:order) { create(:completed_order_with_totals, distributor:) }
let(:current_user) { distributor.owner }
it "renders results" do

View File

@@ -75,7 +75,7 @@ describe Api::V0::ShipmentsController, type: :controller do
hub = create(:distributor_enterprise)
order.update_attribute(:distributor, hub)
shipment.shipping_method.distributors << hub
variant_override = create(:variant_override, hub: hub, variant: variant)
variant_override = create(:variant_override, hub:, variant:)
spree_post :create, params
@@ -202,7 +202,7 @@ describe Api::V0::ShipmentsController, type: :controller do
}
let!(:order_cycle) { create(:order_cycle, distributors: [distributor]) }
let!(:order) {
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor)
create(:completed_order_with_totals, order_cycle:, distributor:)
}
let(:shipping_fee) { order.reload.shipment.adjustments.first }
@@ -240,7 +240,7 @@ describe Api::V0::ShipmentsController, type: :controller do
}
let!(:order_cycle) { create(:order_cycle, distributors: [distributor]) }
let!(:order) {
create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor)
create(:completed_order_with_totals, order_cycle:, distributor:)
}
let(:new_shipping_rate) {
order.shipment.shipping_rates.select{ |sr| sr.shipping_method == shipping_method2 }.first
@@ -341,7 +341,7 @@ describe Api::V0::ShipmentsController, type: :controller do
it 'adds a variant override to the shipment' do
hub = create(:distributor_enterprise)
order.update_attribute(:distributor, hub)
variant_override = create(:variant_override, hub: hub, variant: variant)
variant_override = create(:variant_override, hub:, variant:)
spree_put :add, params

View File

@@ -7,14 +7,14 @@ module Api
render_views
let(:taxonomy) { create(:taxonomy) }
let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) }
let(:taxon) { create(:taxon, name: "Ruby", taxonomy:) }
let(:taxon2) { create(:taxon, name: "Rails", taxonomy:) }
let(:attributes) { [:id, :name] }
before do
allow(controller).to receive(:spree_current_user) { current_api_user }
taxon2.children << create(:taxon, name: "3.2.2", taxonomy: taxonomy)
taxon2.children << create(:taxon, name: "3.2.2", taxonomy:)
taxon.children << taxon2
taxonomy.root.children << taxon
end

View File

@@ -6,8 +6,8 @@ describe Api::V0::TaxonsController do
render_views
let(:taxonomy) { create(:taxonomy) }
let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) }
let(:taxon) { create(:taxon, name: "Ruby", taxonomy:) }
let(:taxon2) { create(:taxon, name: "Rails", taxonomy:) }
let(:attributes) {
["id", "name", "pretty_name", "permalink", "position", "parent_id", "taxonomy_id"]
}
@@ -15,7 +15,7 @@ describe Api::V0::TaxonsController do
before do
allow(controller).to receive(:spree_current_user) { current_api_user }
taxon2.children << create(:taxon, name: "3.2.2", taxonomy: taxonomy)
taxon2.children << create(:taxon, name: "3.2.2", taxonomy:)
taxon.children << taxon2
taxonomy.root.children << taxon
end

View File

@@ -88,7 +88,7 @@ describe Api::V0::VariantsController, type: :controller do
context "as an enterprise user" do
let(:current_api_user) { create(:user, enterprises: [supplier]) }
let(:supplier_other) { create(:supplier_enterprise) }
let!(:product) { create(:product, supplier: supplier) }
let!(:product) { create(:product, supplier:) }
let(:variant) { product.variants.first }
let(:product_other) { create(:product, supplier: supplier_other) }
let(:variant_other) { product_other.variants.first }
@@ -102,7 +102,7 @@ describe Api::V0::VariantsController, type: :controller do
end
context "with more than one variants" do
let(:variant_to_delete) { create(:variant, product: product) }
let(:variant_to_delete) { create(:variant, product:) }
it "deletes a variant" do
api_delete :destroy, id: variant_to_delete.id
@@ -127,7 +127,7 @@ describe Api::V0::VariantsController, type: :controller do
let(:product) { create(:product) }
let(:variant) { product.variants.first }
let!(:variant2) { create(:variant, product: product) }
let!(:variant2) { create(:variant, product:) }
context "deleted variants" do
before do