diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0f7e5b5daa..ec3f4df4ec 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,38 +6,29 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 94 +# Offense count: 67 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: Exclude: - - 'app/components/confirm_modal_component.rb' - - 'app/controllers/admin/product_import_controller.rb' - 'app/controllers/spree/users_controller.rb' - 'app/models/customer.rb' - 'app/models/spree/line_item.rb' - 'spec/controllers/admin/order_cycles_controller_spec.rb' - - 'spec/controllers/api/v0/order_cycles_controller_spec.rb' - 'spec/controllers/spree/admin/orders_controller_spec.rb' - 'spec/lib/reports/customers_report_spec.rb' - 'spec/migrations/migrate_customer_names_spec.rb' - - 'spec/models/enterprise_spec.rb' - 'spec/models/order_cycle_spec.rb' - 'spec/models/product_importer_spec.rb' - - 'spec/models/spree/ability_spec.rb' - 'spec/models/spree/adjustment_spec.rb' - 'spec/models/spree/line_item_spec.rb' - - 'spec/models/spree/product_spec.rb' - 'spec/models/spree/variant_spec.rb' - - 'spec/requests/api/orders_spec.rb' - 'spec/services/products_renderer_spec.rb' - - 'spec/support/request/web_helper.rb' - 'spec/system/admin/adjustments_spec.rb' - 'spec/system/admin/bulk_order_management_spec.rb' - 'spec/system/admin/customers_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/product_import_spec.rb' - 'spec/system/consumer/shopping/cart_spec.rb' @@ -78,7 +69,7 @@ Layout/TrailingEmptyLines: Exclude: - 'Rakefile' -# Offense count: 77 +# Offense count: 80 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: diff --git a/app/components/confirm_modal_component.rb b/app/components/confirm_modal_component.rb index 4fd17dc908..f1419c579c 100644 --- a/app/components/confirm_modal_component.rb +++ b/app/components/confirm_modal_component.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class ConfirmModalComponent < ModalComponent - def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil, confirm_reflexes: nil) + def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil, + confirm_reflexes: nil) super(id: id, close_button: true) @confirm_actions = confirm_actions @reflex = reflex diff --git a/app/controllers/admin/product_import_controller.rb b/app/controllers/admin/product_import_controller.rb index 5802ee1b54..6d342b5cc6 100644 --- a/app/controllers/admin/product_import_controller.rb +++ b/app/controllers/admin/product_import_controller.rb @@ -139,7 +139,8 @@ module Admin end def raise_invalid_file_path - redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice) + redirect_to '/admin/product_import', + notice: I18n.t(:product_import_no_data_in_spreadsheet_notice) raise 'Invalid File Path' end TEMP_FILE_PATH_REGEX = %r{^/tmp/product_import[A-Za-z0-9-]*/import\.csv$} diff --git a/app/models/customer.rb b/app/models/customer.rb index c278d009ed..8157681269 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -40,7 +40,9 @@ class Customer < ApplicationRecord } scope :of, ->(enterprise) { where(enterprise_id: enterprise) } - scope :managed_by, ->(user) { user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none } + scope :managed_by, ->(user) { + user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none + } scope :created_manually, -> { where(created_manually: true) } scope :visible, -> { where(id: Spree::Order.complete.select(:customer_id)).or(created_manually) } diff --git a/spec/controllers/api/v0/order_cycles_controller_spec.rb b/spec/controllers/api/v0/order_cycles_controller_spec.rb index 8953f3cd8f..0eff7e3f2e 100644 --- a/spec/controllers/api/v0/order_cycles_controller_spec.rb +++ b/spec/controllers/api/v0/order_cycles_controller_spec.rb @@ -13,8 +13,12 @@ module Api let!(:property1) { create(:property, presentation: 'Organic') } let!(:property2) { create(:property, presentation: 'Dairy-Free') } let!(:property3) { create(:property, presentation: 'May Contain Nuts') } - let!(:product1) { create(:product, name: "Kangaroo", primary_taxon: taxon1, properties: [property1]) } - let!(:product2) { create(:product, name: "Parsnips", primary_taxon: taxon2, properties: [property2]) } + let!(:product1) { + create(:product, name: "Kangaroo", primary_taxon: taxon1, properties: [property1]) + } + let!(:product2) { + create(:product, name: "Parsnips", primary_taxon: taxon2, properties: [property2]) + } let!(:product3) { create(:product, primary_taxon: taxon2) } let!(:product4) { create(:product, primary_taxon: taxon3, properties: [property3]) } let!(:user) { create(:user) } diff --git a/spec/controllers/spree/admin/orders_controller_spec.rb b/spec/controllers/spree/admin/orders_controller_spec.rb index 739c88ae34..ad64e9e395 100644 --- a/spec/controllers/spree/admin/orders_controller_spec.rb +++ b/spec/controllers/spree/admin/orders_controller_spec.rb @@ -229,7 +229,9 @@ describe Spree::Admin::OrdersController, type: :controller do context "with line items" do let!(:distributor){ create(:distributor_enterprise) } let!(:shipment){ create(:shipment) } - let!(:order_cycle){ create(:simple_order_cycle, distributors: [distributor], variants: [line_item.variant]) } + let!(:order_cycle){ + create(:simple_order_cycle, distributors: [distributor], variants: [line_item.variant]) + } before do line_item.product.supplier = distributor diff --git a/spec/lib/reports/customers_report_spec.rb b/spec/lib/reports/customers_report_spec.rb index aa06cc94b0..0289a739a1 100644 --- a/spec/lib/reports/customers_report_spec.rb +++ b/spec/lib/reports/customers_report_spec.rb @@ -90,10 +90,12 @@ module Reporting let!(:d){ create(:distributor_enterprise) } let!(:sm) { create(:shipping_method, distributors: [d]) } let!(:o1) { - create(:order_with_totals_and_distribution, :completed, distributor: d, bill_address: a, shipping_method: sm) + create(:order_with_totals_and_distribution, :completed, distributor: d, + bill_address: a, shipping_method: sm) } let!(:o2) { - create(:order_with_totals_and_distribution, :completed, distributor: d, bill_address: a, shipping_method: sm) + create(:order_with_totals_and_distribution, :completed, distributor: d, + bill_address: a, shipping_method: sm) } before do [o1, o2].each do |order| @@ -117,7 +119,8 @@ module Reporting let!(:d2) { create(:distributor_enterprise) } let!(:sm2) { create(:shipping_method, distributors: [d2]) } let!(:o2) { - create(:order_with_totals_and_distribution, :completed, distributor: d2, bill_address: a, shipping_method: sm2) + create(:order_with_totals_and_distribution, :completed, distributor: d2, + bill_address: a, shipping_method: sm2) } it "returns one row per customer per hub" do @@ -142,7 +145,8 @@ module Reporting context "orders with different shipping methods" do let!(:sm2) { create(:shipping_method, distributors: [d], name: "Bike") } let!(:o2) { - create(:order_with_totals_and_distribution, :completed, distributor: d, bill_address: a, shipping_method: sm2) + create(:order_with_totals_and_distribution, :completed, distributor: d, + bill_address: a, shipping_method: sm2) } before do o2.select_shipping_method(sm2.id) diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index a53c1b5ff9..75f402a77b 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -518,7 +518,8 @@ describe Enterprise do p1 = create(:simple_product, supplier: s1) p2 = create(:simple_product, supplier: s2) - expect(Enterprise.supplying_variant_in([p1.variants.first, p2.variants.first])).to match_array [s1, s2] + expect(Enterprise.supplying_variant_in([p1.variants.first, + p2.variants.first])).to match_array [s1, s2] end it "does not return duplicates" do diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 379329812d..37072ac513 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -337,7 +337,8 @@ describe Spree::Ability do is_expected.to have_ability([:admin, :read, :update, :bulk_update, :clone, :destroy], for: p1) is_expected.to have_ability( - [:admin, :index, :read, :edit, :update, :search, :destroy, :delete], for: p1.variants.first + [:admin, :index, :read, :edit, :update, :search, :destroy, + :delete], for: p1.variants.first ) end @@ -347,7 +348,8 @@ describe Spree::Ability do is_expected.to have_ability([:admin, :read, :update, :bulk_update, :clone, :destroy], for: p_related) is_expected.to have_ability( - [:admin, :index, :read, :edit, :update, :search, :destroy, :delete], for: p_related.variants.first + [:admin, :index, :read, :edit, :update, :search, :destroy, + :delete], for: p_related.variants.first ) end @@ -376,7 +378,8 @@ describe Spree::Ability do it "should not be able to read/write other enterprises' product variants" do is_expected.not_to have_ability( - [:admin, :index, :read, :create, :edit, :search, :update, :destroy], for: p2.variants.first + [:admin, :index, :read, :create, :edit, :search, :update, + :destroy], for: p2.variants.first ) end diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 9e1c98ceef..e04ef54528 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -406,8 +406,10 @@ module Spree d2 = create(:distributor_enterprise) p1 = create(:product) p2 = create(:product) - create(:simple_order_cycle, suppliers: [s], distributors: [d1], variants: [p1.variants.first]) - create(:simple_order_cycle, suppliers: [s], distributors: [d2], variants: [p2.variants.first]) + create(:simple_order_cycle, suppliers: [s], distributors: [d1], + variants: [p1.variants.first]) + create(:simple_order_cycle, suppliers: [s], distributors: [d2], + variants: [p2.variants.first]) expect(Product.in_distributor(d1)).to eq([p1]) end @@ -483,8 +485,10 @@ module Spree d2 = create(:distributor_enterprise) p1 = create(:product) p2 = create(:product) - create(:simple_order_cycle, suppliers: [s], distributors: [d1], variants: [p1.variants.first]) - create(:simple_order_cycle, suppliers: [s], distributors: [d2], variants: [p2.variants.first]) + create(:simple_order_cycle, suppliers: [s], distributors: [d1], + variants: [p1.variants.first]) + create(:simple_order_cycle, suppliers: [s], distributors: [d2], + variants: [p2.variants.first]) expect(Product.in_supplier_or_distributor(d1)).to eq([p1]) end @@ -492,7 +496,8 @@ module Spree s = create(:supplier_enterprise) d = create(:distributor_enterprise) p = create(:product, supplier: s) - create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.variants.first]) + create(:simple_order_cycle, suppliers: [s], distributors: [d], + variants: [p.variants.first]) [s, d].each { |e| expect(Product.in_supplier_or_distributor(e)).to eq([p]) } end end diff --git a/spec/requests/api/orders_spec.rb b/spec/requests/api/orders_spec.rb index c99bcd3f98..891981ef5e 100644 --- a/spec/requests/api/orders_spec.rb +++ b/spec/requests/api/orders_spec.rb @@ -164,7 +164,8 @@ describe 'api/v0/orders', swagger_doc: 'v0/swagger.yaml', type: :request do } let!(:order_not_empty_no_address) { - create(:order_with_line_items, line_items_count: 1, bill_address_id: nil, ship_address_id: nil) + create(:order_with_line_items, line_items_count: 1, bill_address_id: nil, + ship_address_id: nil) } let(:'q[state_eq]') { "cart" } diff --git a/spec/support/request/web_helper.rb b/spec/support/request/web_helper.rb index c4ebf00118..b592bd728b 100644 --- a/spec/support/request/web_helper.rb +++ b/spec/support/request/web_helper.rb @@ -93,7 +93,8 @@ module WebHelper def tomselect_multiselect(value, options) tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper") tomselect_wrapper.find(".ts-control").click - tomselect_wrapper.find(:css, '.ts-dropdown.multi .ts-dropdown-content .option', text: value).click + tomselect_wrapper.find(:css, '.ts-dropdown.multi .ts-dropdown-content .option', + text: value).click end def tomselect_search_and_select(value, options) diff --git a/spec/system/admin/adjustments_spec.rb b/spec/system/admin/adjustments_spec.rb index b47d8b572d..228fb75c3e 100644 --- a/spec/system/admin/adjustments_spec.rb +++ b/spec/system/admin/adjustments_spec.rb @@ -26,7 +26,10 @@ describe ' let!(:tax_category_included) { create(:tax_category, name: 'TVA 20%', is_default: true) } let!(:default_tax_zone) { create(:zone, default_tax: true) } - let!(:tax_rate2) { create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true, tax_category: tax_category_included, calculator: Calculator::DefaultTax.new ) } + let!(:tax_rate2) { + create(:tax_rate, name: "TVA 20%", amount: 0.2, zone: default_tax_zone, included_in_price: true, + tax_category: tax_category_included, calculator: Calculator::DefaultTax.new ) + } before do order.finalize! @@ -64,21 +67,25 @@ describe ' context "included tax" do context "adding negative, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%", "$0.33", "$-1.67" + it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%", + "$0.33", "$-1.67" end context "adding positive, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Late fee", "100", "TVA 20%", "$-16.67", "$83.33" + it_behaves_like "when the enable_localized_number preference", "Late fee", "100", + "TVA 20%", "$-16.67", "$83.33" end end context "added tax" do context "adding negative, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST", "$10.00", "$8.00" + it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST", + "$10.00", "$8.00" end context "adding positive, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST", "$10.00", "$120" + it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST", + "$10.00", "$120" end end end @@ -90,21 +97,25 @@ describe ' context "included tax" do context "adding negative, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%", "$0.33", "$-1.67" + it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "TVA 20%", + "$0.33", "$-1.67" end context "adding positive, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Late fee", "100", "TVA 20%", "$-16.67", "$83.33" + it_behaves_like "when the enable_localized_number preference", "Late fee", "100", + "TVA 20%", "$-16.67", "$83.33" end end context "added tax" do context "adding negative, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST", "$10.00", "$8.00" + it_behaves_like "when the enable_localized_number preference", "Discount", "-2", "GST", + "$10.00", "$8.00" end context "adding positive, taxed adjustments to an order" do - it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST", "$10.00", "$120" + it_behaves_like "when the enable_localized_number preference", "Late fee", "110", "GST", + "$10.00", "$120" end end end diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 4007224466..ea62c5e119 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -595,7 +595,8 @@ describe ' end it "shows the link" do - expect(page).to have_link "Resend Confirmation", href: spree.resend_admin_order_path(order) + expect(page).to have_link "Resend Confirmation", + href: spree.resend_admin_order_path(order) end it "resends the confirmation email" do @@ -613,7 +614,8 @@ describe ' end it "shows the link" do - expect(page).to have_link "Cancel Order", href: spree.fire_admin_order_path(order, e: 'cancel') + expect(page).to have_link "Cancel Order", + href: spree.fire_admin_order_path(order, e: 'cancel') end it "cancels the order" do