From ffda639629aa5f2e1a2208672b011cef042fc456 Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Mon, 24 Jul 2023 23:39:43 +0900 Subject: [PATCH 1/6] Regenerate Rubocop's TODO file --- .rubocop_todo.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ec3f4df4ec..16ce5f1f97 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -69,7 +69,7 @@ Layout/TrailingEmptyLines: Exclude: - 'Rakefile' -# Offense count: 80 +# Offense count: 79 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: @@ -92,7 +92,6 @@ Layout/TrailingWhitespace: - 'spec/system/admin/order_cycles/list_spec.rb' - 'spec/system/admin/order_cycles/simple_spec.rb' - 'spec/system/admin/order_spec.rb' - - 'spec/system/admin/product_import_spec.rb' - 'spec/system/admin/shipping_methods_spec.rb' # Offense count: 7 @@ -240,14 +239,6 @@ Lint/UselessMethodDefinition: Exclude: - 'app/models/spree/gateway.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: CheckForMethodsWithNoSideEffects. -Lint/Void: - Exclude: - - 'spec/system/admin/order_cycles/complex_updating_specific_time_spec.rb' - - 'spec/system/admin/order_cycles/simple_spec.rb' - # Offense count: 26 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: @@ -1234,7 +1225,7 @@ Style/HashLikeCase: Exclude: - 'app/models/enterprise.rb' -# Offense count: 1783 +# Offense count: 1781 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -1491,7 +1482,6 @@ Style/HashSyntax: - 'spec/models/enterprise_relationship_spec.rb' - 'spec/models/enterprise_spec.rb' - 'spec/models/exchange_spec.rb' - - 'spec/models/invoice_spec.rb' - 'spec/models/order_cycle_spec.rb' - 'spec/models/product_import/entry_validator_spec.rb' - 'spec/models/product_import/inventory_reset_strategy_spec.rb' From a97e2088817421dd39ef468b24953733e81e555d Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Mon, 24 Jul 2023 23:41:03 +0900 Subject: [PATCH 2/6] Safely autocorrect Layout/MultilineBlockLayout Inspecting 1479 files ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. Offenses: engines/order_management/app/services/order_management/subscriptions/validator.rb:101:9: C: [Corrected] Layout/IndentationWidth: Use 2 (not 12) spaces for indentation. sli.quantity > 0 && !sli.marked_for_destruction? ^^^^^^^^^^^^ engines/order_management/app/services/order_management/subscriptions/validator.rb:101:11: C: [Corrected] Layout/MultilineBlockLayout: Block argument expression is not on the same line as the block start. |sli| sli.quantity > 0 && !sli.marked_for_destruction? ^^^^^ 1479 files inspected, 2 offenses detected, 2 offenses corrected --- .rubocop_todo.yml | 6 ------ .../services/order_management/subscriptions/validator.rb | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 16ce5f1f97..4bdd854b43 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,12 +34,6 @@ Layout/LineLength: - 'spec/system/consumer/shopping/cart_spec.rb' - 'spec/system/consumer/shopping/products_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/MultilineBlockLayout: - Exclude: - - 'engines/order_management/app/services/order_management/subscriptions/validator.rb' - # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/engines/order_management/app/services/order_management/subscriptions/validator.rb b/engines/order_management/app/services/order_management/subscriptions/validator.rb index cd5bfd774f..e9eab98a6e 100644 --- a/engines/order_management/app/services/order_management/subscriptions/validator.rb +++ b/engines/order_management/app/services/order_management/subscriptions/validator.rb @@ -97,8 +97,8 @@ module OrderManagement end def subscription_line_items_present? - return if subscription_line_items.any? { - |sli| sli.quantity > 0 && !sli.marked_for_destruction? + return if subscription_line_items.any? { |sli| + sli.quantity > 0 && !sli.marked_for_destruction? } errors.add(:subscription_line_items, :at_least_one_product) From 164385ad13b7eb66aa615f4095fde484210e55f6 Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Mon, 24 Jul 2023 23:43:36 +0900 Subject: [PATCH 3/6] Safely autocorrect Layout/MultilineMethodCallBraceLayout Inspecting 1479 files ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.....C..................................................................... Offenses: spec/system/admin/orders_spec.rb:485:80: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument. "#listing_orders tbody tr td:first-child input[type=checkbox]") ^ spec/system/admin/orders_spec.rb:486:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 15 (not 0) )).to be_checked ^ spec/system/admin/orders_spec.rb:486:15: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument. ).to be_checked ^ spec/system/admin/orders_spec.rb:493:80: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument. "#listing_orders tbody tr td:first-child input[type=checkbox]") ^ spec/system/admin/orders_spec.rb:494:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 15 (not 0) )).to_not be_checked ^ spec/system/admin/orders_spec.rb:494:15: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the same line as the last argument when opening brace is on the same line as the first argument. ).to_not be_checked ^ spec/system/admin/products_spec.rb:346:54: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument. product.id, filter))) ^ spec/system/admin/products_spec.rb:347:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 33 (not 0) ))) ^ spec/system/admin/products_spec.rb:352:54: C: [Corrected] Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument. product.id, filter))) ^ spec/system/admin/products_spec.rb:354:1: C: [Corrected] Layout/ClosingParenthesisIndentation: Indent ) to column 33 (not 0) ))) ^ 1479 files inspected, 10 offenses detected, 10 offenses corrected --- .rubocop_todo.yml | 9 --------- spec/system/admin/orders_spec.rb | 8 ++++---- spec/system/admin/products_spec.rb | 6 ++++-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4bdd854b43..36c0baf13e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,15 +34,6 @@ Layout/LineLength: - 'spec/system/consumer/shopping/cart_spec.rb' - 'spec/system/consumer/shopping/products_spec.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'spec/system/admin/orders_spec.rb' - - 'spec/system/admin/products_spec.rb' - # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index f6a0883953..2696a84687 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -482,16 +482,16 @@ describe ' # select all orders page.find("#listing_orders thead th:first-child input[type=checkbox]").click expect(page.find( - "#listing_orders tbody tr td:first-child input[type=checkbox]") - ).to be_checked + "#listing_orders tbody tr td:first-child input[type=checkbox]" + )).to be_checked # enables print invoices button page.find("span.icon-reorder", text: "ACTIONS").click expect(page).to have_content "Print Invoices" # unselect all orders page.find("#listing_orders thead th:first-child input[type=checkbox]").trigger("click") expect(page.find( - "#listing_orders tbody tr td:first-child input[type=checkbox]") - ).to_not be_checked + "#listing_orders tbody tr td:first-child input[type=checkbox]" + )).to_not be_checked # disables print invoices button page.find("span.icon-reorder", text: "ACTIONS").click expect(page).to_not have_content "Print Invoices" diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index 102464e5f1..88703215fc 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -343,13 +343,15 @@ describe ' expected_product_properties_url = Regexp.new(Regexp.escape(spree.admin_product_product_properties_path( - product.id, filter))) + product.id, filter + ))) expect(page).to have_link('Product Properties', href: expected_product_properties_url) expected_product_group_buy_option_url = Regexp.new(Regexp.escape(spree.group_buy_options_admin_product_path( - product.id, filter))) + product.id, filter + ))) expect(page).to have_link('Group Buy Options', href: expected_product_group_buy_option_url) From 2dbaa7f89d269c768a9f3abbd0ac251a3ac9d92d Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Mon, 24 Jul 2023 23:44:52 +0900 Subject: [PATCH 4/6] Safely autocorrect Layout/MultilineMethodCallIndentation Inspecting 1479 files ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.......CC......................C.................................................. Offenses: spec/controllers/api/v0/orders_controller_spec.rb:150:13: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. .map{ |o| o["id"] } ^^^^ spec/system/admin/order_cycles/complex_editing_spec.rb:30:9: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. .to eq(oc.orders_open_at.strftime("%Y-%m-%d %H:%M")) ^^^ spec/system/admin/order_cycles/complex_editing_spec.rb:32:9: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 4) spaces for indenting an expression spanning multiple lines. .to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M")) ^^^ spec/system/admin/overview_spec.rb:16:62: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 55) spaces for indenting an expression spanning multiple lines. .and_return @enterprise_user ^^^^^^^^^^^ spec/system/admin/payment_method_spec.rb:62:22: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 13) spaces for indenting an expression spanning multiple lines. .to_return(body: JSON.generate(stripe_account_mock)) ^^^^^^^^^^ spec/system/admin/variant_overrides_spec.rb:214:64: C: [Corrected] Layout/MultilineMethodCallIndentation: Use 2 (not 51) spaces for indenting an expression spanning multiple lines. .and_return(build(:user)) ^^^^^^^^^^^ 1479 files inspected, 6 offenses detected, 6 offenses corrected --- .rubocop_todo.yml | 12 ------------ spec/controllers/api/v0/orders_controller_spec.rb | 2 +- .../admin/order_cycles/complex_editing_spec.rb | 4 ++-- spec/system/admin/overview_spec.rb | 2 +- spec/system/admin/payment_method_spec.rb | 2 +- spec/system/admin/variant_overrides_spec.rb | 2 +- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 36c0baf13e..798ac90d52 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,18 +34,6 @@ Layout/LineLength: - 'spec/system/consumer/shopping/cart_spec.rb' - 'spec/system/consumer/shopping/products_spec.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'spec/controllers/api/v0/orders_controller_spec.rb' - - 'spec/system/admin/order_cycles/complex_editing_spec.rb' - - 'spec/system/admin/overview_spec.rb' - - 'spec/system/admin/payment_method_spec.rb' - - 'spec/system/admin/variant_overrides_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/spec/controllers/api/v0/orders_controller_spec.rb b/spec/controllers/api/v0/orders_controller_spec.rb index af31a7f45c..9f29e41b9b 100644 --- a/spec/controllers/api/v0/orders_controller_spec.rb +++ b/spec/controllers/api/v0/orders_controller_spec.rb @@ -147,7 +147,7 @@ module Api expect(json_response['orders'] .map{ |o| o[:id] }).to eq serialized_orders([order2, order3, order1, order4]) - .map{ |o| o["id"] } + .map{ |o| o["id"] } end end diff --git a/spec/system/admin/order_cycles/complex_editing_spec.rb b/spec/system/admin/order_cycles/complex_editing_spec.rb index 6a4d474c8f..6ab4782513 100644 --- a/spec/system/admin/order_cycles/complex_editing_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_spec.rb @@ -27,9 +27,9 @@ describe ' # Then I should see the basic settings expect(page.find('#order_cycle_name').value).to eq(oc.name) expect(page.find('#order_cycle_orders_open_at').value) - .to eq(oc.orders_open_at.strftime("%Y-%m-%d %H:%M")) + .to eq(oc.orders_open_at.strftime("%Y-%m-%d %H:%M")) expect(page.find('#order_cycle_orders_close_at').value) - .to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M")) + .to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M")) expect(page).to have_content "COORDINATOR #{oc.coordinator.name}" click_button 'Next' diff --git a/spec/system/admin/overview_spec.rb b/spec/system/admin/overview_spec.rb index c457bc56c0..055ef9d6e5 100644 --- a/spec/system/admin/overview_spec.rb +++ b/spec/system/admin/overview_spec.rb @@ -13,7 +13,7 @@ describe ' before do @enterprise_user = create(:user) allow_any_instance_of(Spree::Admin::OverviewController).to receive(:spree_current_user) - .and_return @enterprise_user + .and_return @enterprise_user login_as @enterprise_user end diff --git a/spec/system/admin/payment_method_spec.rb b/spec/system/admin/payment_method_spec.rb index ef2611ac49..c7173c5d23 100644 --- a/spec/system/admin/payment_method_spec.rb +++ b/spec/system/admin/payment_method_spec.rb @@ -59,7 +59,7 @@ describe ' Stripe.api_key = "sk_test_12345" stub_request(:get, "https://api.stripe.com/v1/accounts/acc_connected123") - .to_return(body: JSON.generate(stripe_account_mock)) + .to_return(body: JSON.generate(stripe_account_mock)) stub_request(:get, "https://api.stripe.com/v1/accounts/acc_revoked123").to_return(status: 404) end diff --git a/spec/system/admin/variant_overrides_spec.rb b/spec/system/admin/variant_overrides_spec.rb index ad96a6a51a..e392a65eeb 100644 --- a/spec/system/admin/variant_overrides_spec.rb +++ b/spec/system/admin/variant_overrides_spec.rb @@ -211,7 +211,7 @@ describe " # Set a user without suficient permissions allow_any_instance_of(Spree::Admin::BaseController).to receive(:current_spree_user) - .and_return(build(:user)) + .and_return(build(:user)) expect do click_button 'Save Changes' From e0206a0be607a189468c9fe0b0d031ae31a38779 Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Mon, 24 Jul 2023 23:46:11 +0900 Subject: [PATCH 5/6] Safely autocorrect Layout/TrailingEmptyLines Inspecting 1479 files ..C.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Offenses: Rakefile:10:1: C: [Corrected] Layout/TrailingEmptyLines: 1 trailing blank lines detected. 1479 files inspected, 1 offense detected, 1 offense corrected --- .rubocop_todo.yml | 8 -------- Rakefile | 1 - 2 files changed, 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 798ac90d52..bef7010579 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,14 +34,6 @@ Layout/LineLength: - 'spec/system/consumer/shopping/cart_spec.rb' - 'spec/system/consumer/shopping/products_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Exclude: - - 'Rakefile' - # Offense count: 79 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. diff --git a/Rakefile b/Rakefile index 3a8f4a342c..c0443f147f 100755 --- a/Rakefile +++ b/Rakefile @@ -7,4 +7,3 @@ require_relative 'config/application' Openfoodnetwork::Application.load_tasks - From e923defd5574ad07e50f258b59ee12f1385c46a3 Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Mon, 24 Jul 2023 23:47:43 +0900 Subject: [PATCH 6/6] Safely autocorrect Layout/TrailingWhitespace Inspecting 1479 files ...................................................................................................................................................C..C.......................................................................................................C.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.....C..................C.............................................................................................C...................................................................C.......................................................................................................................................................................C....................................................C.............C...........CC.........C......C.CC.C....................C........................................................ Offenses: app/controllers/spree/users_controller.rb:36:37: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. partial("layouts/alert", ^ app/controllers/spree/users_controller.rb:51:35: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. partial("layouts/alert", ^ app/controllers/user_confirmations_controller.rb:27:33: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. partial("layouts/alert", ^ app/models/enterprise.rb:117:24: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. validates :instagram, ^ spec/controllers/spree/credit_cards_controller_spec.rb:250:64: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. create(:stored_credit_card, user_id: user.id, ^ spec/controllers/user_confirmations_controller_spec.rb:45:44: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. session[:confirmation_return_url] = ^ spec/factories/order_factory.rb:40:67: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. order.payments << build(:payment, amount: order.total, ^ spec/lib/reports/packing/packing_report_spec.rb:59:40: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. build(:line_item_with_shipment, ^ spec/lib/reports/packing/packing_report_spec.rb:63:40: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. build(:line_item_with_shipment, ^ spec/models/enterprise_spec.rb:521:67: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(Enterprise.supplying_variant_in([p1.variants.first, ^ spec/models/enterprise_spec.rb:906:77: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. create(:enterprise_relationship, parent: distributor, child: supplier, ^ spec/services/products_renderer_spec.rb:22:73: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. create(:product, name: "banana bread", primary_taxon_id: cakes.id, ^ spec/services/products_renderer_spec.rb:88:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. product_apples.product_properties.create!({ property_id: property_organic.id, ^ spec/services/products_renderer_spec.rb:90:87: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, ^ spec/services/products_renderer_spec.rb:97:90: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. fruits_supplier.producer_properties.create!({ property_id: property_organic.id, ^ spec/services/products_renderer_spec.rb:99:87: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, ^ spec/services/products_renderer_spec.rb:109:93: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. product_apples.product_properties.create!({ property_id: property_conventional.id, ^ spec/services/products_renderer_spec.rb:111:94: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. product_banana_bread.product_properties.create!({ property_id: property_organic.id, ^ spec/services/products_renderer_spec.rb:113:90: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. product_cherries.product_properties.create!({ property_id: property_organic.id, ^ spec/services/products_renderer_spec.rb:115:91: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. product_doughnuts.product_properties.create!({ property_id: property_organic.id, ^ spec/services/products_renderer_spec.rb:117:87: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, ^ spec/support/request/stripe_stubs.rb:17:81: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. def stub_payment_intent_get_request(response: {}, stripe_account_header: true, ^ spec/support/request/stripe_stubs.rb:172:6: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. { ^ spec/support/request/stripe_stubs.rb:175:24: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. object: "list", ^ spec/support/request/stripe_stubs.rb:176:25: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. has_more: false, ^ spec/system/admin/bulk_order_management_spec.rb:792:99: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. it "displays only line items whose orders meet the date restriction criteria, when changed", ^ spec/system/admin/bulk_order_management_spec.rb:1071:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/bulk_order_management_spec.rb:1121:82: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. shared_examples "display only group by information for selected variant" do ^^^^^^^^^^ spec/system/admin/bulk_order_management_spec.rb:1143:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/bulk_order_management_spec.rb:1166:12: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. end ^ spec/system/admin/customers_spec.rb:18:98: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. create(:customer, first_name: 'John', last_name: 'Doe', enterprise: managed_distributor1, ^ spec/system/admin/enterprise_fees_spec.rb:102:37: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. select 'Inherit From Product', ^ spec/system/admin/enterprise_fees_spec.rb:128:38: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. select 'Weight (per kg or lb)', ^ spec/system/admin/enterprise_fees_spec.rb:132:37: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. select 'Flat Rate (per item)', ^ spec/system/admin/enterprise_fees_spec.rb:153:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning. spec/system/admin/enterprise_fees_spec.rb:153:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/enterprise_fees_spec.rb:157:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/enterprise_fees_spec.rb:159:38: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. select 'Flat Rate (per order)', ^ spec/system/admin/enterprise_fees_spec.rb:222:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/flatpickr_spec.rb:22:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/flatpickr_spec.rb:27:32: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. find("#admin-menu").click ^^^^^^^ spec/system/admin/flatpickr_spec.rb:32:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/flatpickr_spec.rb:34:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/flatpickr_spec.rb:41:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_cycles/complex_editing_spec.rb:74:33: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(page).to have_select( ^ spec/system/admin/order_cycles/complex_editing_spec.rb:110:33: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(page).to have_select( ^ spec/system/admin/order_cycles/list_spec.rb:147:46: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(find('input.datetimepicker', ^ spec/system/admin/order_cycles/list_spec.rb:160:46: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(find('input.datetimepicker', ^ spec/system/admin/order_cycles/list_spec.rb:188:46: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(find('input.datetimepicker', ^ spec/system/admin/order_cycles/simple_spec.rb:447:43: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(page).not_to have_selector( ^ spec/system/admin/order_spec.rb:92:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:207:30: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. within(".modal") do ^ spec/system/admin/order_spec.rb:235:21: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. login_as_admin ^^ spec/system/admin/order_spec.rb:240:16: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. before do ^ spec/system/admin/order_spec.rb:247:62: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. context "when using the cancel option in the dropdown" do ^^ spec/system/admin/order_spec.rb:248:16: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. before do ^ spec/system/admin/order_spec.rb:299:53: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(page).to have_content "Are you sure?" ^^^^^^^^ spec/system/admin/order_spec.rb:327:36: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. find("a.delete-item").click ^ spec/system/admin/order_spec.rb:401:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:405:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:598:59: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(page).to have_link "Resend Confirmation", ^ spec/system/admin/order_spec.rb:617:52: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. expect(page).to have_link "Cancel Order", ^ spec/system/admin/order_spec.rb:633:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:635:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning. spec/system/admin/order_spec.rb:635:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:674:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:735:35: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. within "#order-total" do ^ spec/system/admin/order_spec.rb:762:39: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. within "#order-total" do ^ spec/system/admin/order_spec.rb:778:41: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. within "#order-total" do ^ spec/system/admin/order_spec.rb:780:20: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. end ^^ spec/system/admin/order_spec.rb:796:39: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. within "#order-total" do ^ spec/system/admin/order_spec.rb:807:88: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. # Since the order is completed, the price is not supposed to be updated ^ spec/system/admin/order_spec.rb:813:41: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. within "#order-total" do ^ spec/system/admin/order_spec.rb:815:20: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. end ^^ spec/system/admin/order_spec.rb:924:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:959:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/order_spec.rb:981:16: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. before do ^^ spec/system/admin/order_spec.rb:992:8: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. end ^^ spec/system/admin/order_spec.rb:1002:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/shipping_methods_spec.rb:50:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. spec/system/admin/shipping_methods_spec.rb:92:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. 1479 files inspected, 81 offenses detected, 81 offenses corrected --- .rubocop_todo.yml | 25 --------- app/controllers/spree/users_controller.rb | 4 +- .../user_confirmations_controller.rb | 2 +- app/models/enterprise.rb | 2 +- .../spree/credit_cards_controller_spec.rb | 2 +- .../user_confirmations_controller_spec.rb | 2 +- spec/factories/order_factory.rb | 2 +- .../reports/packing/packing_report_spec.rb | 4 +- spec/models/enterprise_spec.rb | 4 +- spec/services/products_renderer_spec.rb | 20 +++---- spec/support/request/stripe_stubs.rb | 8 +-- .../admin/bulk_order_management_spec.rb | 10 ++-- spec/system/admin/customers_spec.rb | 2 +- spec/system/admin/enterprise_fees_spec.rb | 7 +-- spec/system/admin/flatpickr_spec.rb | 10 ++-- .../order_cycles/complex_editing_spec.rb | 4 +- spec/system/admin/order_cycles/list_spec.rb | 6 +- spec/system/admin/order_cycles/simple_spec.rb | 2 +- spec/system/admin/order_spec.rb | 55 +++++++++---------- spec/system/admin/shipping_methods_spec.rb | 4 +- 20 files changed, 74 insertions(+), 101 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bef7010579..bedff16039 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,31 +34,6 @@ Layout/LineLength: - 'spec/system/consumer/shopping/cart_spec.rb' - 'spec/system/consumer/shopping/products_spec.rb' -# Offense count: 79 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'app/controllers/spree/users_controller.rb' - - 'app/controllers/user_confirmations_controller.rb' - - 'app/models/enterprise.rb' - - 'spec/controllers/spree/credit_cards_controller_spec.rb' - - 'spec/controllers/user_confirmations_controller_spec.rb' - - 'spec/factories/order_factory.rb' - - 'spec/lib/reports/packing/packing_report_spec.rb' - - 'spec/models/enterprise_spec.rb' - - 'spec/services/products_renderer_spec.rb' - - 'spec/support/request/stripe_stubs.rb' - - 'spec/system/admin/bulk_order_management_spec.rb' - - 'spec/system/admin/customers_spec.rb' - - 'spec/system/admin/enterprise_fees_spec.rb' - - 'spec/system/admin/flatpickr_spec.rb' - - 'spec/system/admin/order_cycles/complex_editing_spec.rb' - - 'spec/system/admin/order_cycles/list_spec.rb' - - 'spec/system/admin/order_cycles/simple_spec.rb' - - 'spec/system/admin/order_spec.rb' - - 'spec/system/admin/shipping_methods_spec.rb' - # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: diff --git a/app/controllers/spree/users_controller.rb b/app/controllers/spree/users_controller.rb index 4637dc5b12..dc60c31d24 100644 --- a/app/controllers/spree/users_controller.rb +++ b/app/controllers/spree/users_controller.rb @@ -33,7 +33,7 @@ module Spree render status: :ok, cable_ready: cable_car. inner_html( "#login-feedback", - partial("layouts/alert", + partial("layouts/alert", locals: { type: "alert", message: t('devise.failure.already_registered') }) ). dispatch_event(name: "login:modal:open") @@ -48,7 +48,7 @@ module Spree if @user.save render cable_ready: cable_car.inner_html( "#signup-feedback", - partial("layouts/alert", + partial("layouts/alert", locals: { type: "success", message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') }) ) diff --git a/app/controllers/user_confirmations_controller.rb b/app/controllers/user_confirmations_controller.rb index dd07d9d299..c0634d49e7 100644 --- a/app/controllers/user_confirmations_controller.rb +++ b/app/controllers/user_confirmations_controller.rb @@ -24,7 +24,7 @@ class UserConfirmationsController < DeviseController else render cable_ready: cable_car.inner_html( "##{params[:tab] || 'forgot'}-feedback", - partial("layouts/alert", + partial("layouts/alert", locals: { type: "success", message: t("devise.confirmations.send_instructions") }) ) return diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index a35eadf9fd..494d40fead 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -114,7 +114,7 @@ class Enterprise < ApplicationRecord validate :shopfront_taxons validate :shopfront_producers validate :enforce_ownership_limit, if: lambda { owner_id_changed? && !owner_id.nil? } - validates :instagram, + validates :instagram, format: { with: VALID_INSTAGRAM_REGEX, message: Spree.t('errors.messages.invalid_instagram_url') diff --git a/spec/controllers/spree/credit_cards_controller_spec.rb b/spec/controllers/spree/credit_cards_controller_spec.rb index df065d1d1b..eb8432411b 100644 --- a/spec/controllers/spree/credit_cards_controller_spec.rb +++ b/spec/controllers/spree/credit_cards_controller_spec.rb @@ -247,7 +247,7 @@ describe Spree::CreditCardsController, type: :controller do context "when has any other saved cards" do let!(:second_card) { - create(:stored_credit_card, user_id: user.id, + create(:stored_credit_card, user_id: user.id, gateway_customer_profile_id: 'cus_AZNMJ') } diff --git a/spec/controllers/user_confirmations_controller_spec.rb b/spec/controllers/user_confirmations_controller_spec.rb index 3fbbf72a95..40be9eebb1 100644 --- a/spec/controllers/user_confirmations_controller_spec.rb +++ b/spec/controllers/user_confirmations_controller_spec.rb @@ -42,7 +42,7 @@ describe UserConfirmationsController, type: :controller do end it "redirects to previous url on /register path" do - session[:confirmation_return_url] = + session[:confirmation_return_url] = registration_path(anchor: "#/signup", after_login: "/register") spree_get :show, confirmation_token: unconfirmed_user.confirmation_token expect(response). diff --git a/spec/factories/order_factory.rb b/spec/factories/order_factory.rb index 311c2043d8..979b820044 100644 --- a/spec/factories/order_factory.rb +++ b/spec/factories/order_factory.rb @@ -37,7 +37,7 @@ FactoryBot.define do end after(:create) do |order, evaluator| - order.payments << build(:payment, amount: order.total, + order.payments << build(:payment, amount: order.total, payment_method: evaluator.payment_method) order.next! end diff --git a/spec/lib/reports/packing/packing_report_spec.rb b/spec/lib/reports/packing/packing_report_spec.rb index 087788bffc..7de9141c2c 100644 --- a/spec/lib/reports/packing/packing_report_spec.rb +++ b/spec/lib/reports/packing/packing_report_spec.rb @@ -56,11 +56,11 @@ describe "Packing Reports" do ship_address: create(:address)) } let(:line_item2) { - build(:line_item_with_shipment, + build(:line_item_with_shipment, product: create(:simple_product, name: "visible", supplier: supplier1)) } let(:line_item3) { - build(:line_item_with_shipment, + build(:line_item_with_shipment, product: create(:simple_product, name: "not visible", supplier: supplier2)) } diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 75f402a77b..940abeecd9 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -518,7 +518,7 @@ describe Enterprise do p1 = create(:simple_product, supplier: s1) p2 = create(:simple_product, supplier: s2) - expect(Enterprise.supplying_variant_in([p1.variants.first, + expect(Enterprise.supplying_variant_in([p1.variants.first, p2.variants.first])).to match_array [s1, s2] end @@ -903,7 +903,7 @@ describe Enterprise do sender = create(:supplier_enterprise) distributor = create(:distributor_enterprise, is_primary_producer: false) permission = EnterpriseRelationshipPermission.create(name: "add_to_order_cycle") - create(:enterprise_relationship, parent: distributor, child: supplier, + create(:enterprise_relationship, parent: distributor, child: supplier, permissions: [permission]) product = create(:product) order_cycle = create( diff --git a/spec/services/products_renderer_spec.rb b/spec/services/products_renderer_spec.rb index 9cbf7dc3f5..913c04c7ee 100644 --- a/spec/services/products_renderer_spec.rb +++ b/spec/services/products_renderer_spec.rb @@ -19,7 +19,7 @@ describe ProductsRenderer do supplier_id: fruits_supplier.id) } let!(:product_banana_bread) { - create(:product, name: "banana bread", primary_taxon_id: cakes.id, + create(:product, name: "banana bread", primary_taxon_id: cakes.id, supplier_id: cakes_supplier.id) } let!(:product_cherries) { @@ -85,18 +85,18 @@ describe ProductsRenderer do } it "filters products with a product property" do - product_apples.product_properties.create!({ property_id: property_organic.id, + product_apples.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) - products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, + products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, { q: { with_properties: [property_organic.id] } }) products = products_renderer.send(:products) expect(products).to eq([product_apples]) end it "filters products with a producer property" do - fruits_supplier.producer_properties.create!({ property_id: property_organic.id, + fruits_supplier.producer_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) - products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, + products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, { q: { with_properties: [property_organic.id] } }) products = products_renderer.send(:products) expect(products).to eq([product_apples, product_cherries]) @@ -106,15 +106,15 @@ describe ProductsRenderer do allow(distributor).to receive(:preferred_shopfront_taxon_order) { "#{fruits.id},#{cakes.id}" } - product_apples.product_properties.create!({ property_id: property_conventional.id, + product_apples.product_properties.create!({ property_id: property_conventional.id, value: '1', position: 1 }) - product_banana_bread.product_properties.create!({ property_id: property_organic.id, + product_banana_bread.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) - product_cherries.product_properties.create!({ property_id: property_organic.id, + product_cherries.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) - product_doughnuts.product_properties.create!({ property_id: property_organic.id, + product_doughnuts.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) - products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, + products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, { q: { with_properties: [property_organic.id] } }) products = products_renderer.send(:products) expect(products).to eq([product_cherries, product_banana_bread, product_doughnuts]) diff --git a/spec/support/request/stripe_stubs.rb b/spec/support/request/stripe_stubs.rb index 79d0efb25a..4907a3b56f 100644 --- a/spec/support/request/stripe_stubs.rb +++ b/spec/support/request/stripe_stubs.rb @@ -14,7 +14,7 @@ module StripeStubs .to_return(payment_intent_redirect_response_mock(redirect_url)) end - def stub_payment_intent_get_request(response: {}, stripe_account_header: true, + def stub_payment_intent_get_request(response: {}, stripe_account_header: true, payment_intent_id: "pi_123") stub = stub_request(:get, "https://api.stripe.com/v1/payment_intents/#{payment_intent_id}") stub = stub.with(headers: { 'Stripe-Account' => 'abc123' }) if stripe_account_header @@ -169,11 +169,11 @@ module StripeStubs def get_customer_payment_methods_response_mock(options) payment_method = options[:payment_method] || "pm_456" fingerprint = options[:fingerprint] || "7890" - { + { status: options[:code] || 200, body: JSON.generate( - object: "list", - has_more: false, + object: "list", + has_more: false, data: [{ id: payment_method, card: { fingerprint: fingerprint } }], ), } diff --git a/spec/system/admin/bulk_order_management_spec.rb b/spec/system/admin/bulk_order_management_spec.rb index 4006c03f15..3abeaa61ed 100644 --- a/spec/system/admin/bulk_order_management_spec.rb +++ b/spec/system/admin/bulk_order_management_spec.rb @@ -789,7 +789,7 @@ describe ' expect(page).to have_selector "tr#li_#{li4.id}" end - it "displays only line items whose orders meet the date restriction criteria, when changed", + it "displays only line items whose orders meet the date restriction criteria, when changed", retry: 3 do from = today - 8.days to = today + 1.day @@ -1068,7 +1068,7 @@ describe ' expect(o2.reload.state).to eq("canceled") end.to have_enqueued_mail(Spree::OrderMailer, :cancel_email) end - + it "the user can confirm + uncheck the restock option: line item is then deleted and order is canceled without retocking" do expect_any_instance_of(Spree::StockLocation).to_not receive(:restock) expect do @@ -1118,7 +1118,7 @@ describe ' end end - shared_examples "display only group by information for selected variant" do + shared_examples "display only group by information for selected variant" do it "displays group buy calc box" do expect(page).to have_selector "div#group_buy_calculation" @@ -1140,7 +1140,7 @@ describe ' end end end - + it "all line items of the same variant" do expect(page).to have_no_selector "tr#li_#{li1.id}" expect(page).to have_no_selector "tr#li_#{li2.id}" @@ -1163,7 +1163,7 @@ describe ' expect(page).to have_selector "tr#li_#{li2.id}" expect(page).to have_selector "tr#li_#{li3.id}" expect(page).to have_selector "tr#li_#{li4.id}" - end + end end context "when filtering" do diff --git a/spec/system/admin/customers_spec.rb b/spec/system/admin/customers_spec.rb index 94599e3e57..c5616866cf 100644 --- a/spec/system/admin/customers_spec.rb +++ b/spec/system/admin/customers_spec.rb @@ -15,7 +15,7 @@ describe 'Customers' do describe "using the customers index" do let!(:customer1) { - create(:customer, first_name: 'John', last_name: 'Doe', enterprise: managed_distributor1, + create(:customer, first_name: 'John', last_name: 'Doe', enterprise: managed_distributor1, code: nil, created_manually: true) } let!(:customer2) { diff --git a/spec/system/admin/enterprise_fees_spec.rb b/spec/system/admin/enterprise_fees_spec.rb index 91dae2324d..22860c5083 100644 --- a/spec/system/admin/enterprise_fees_spec.rb +++ b/spec/system/admin/enterprise_fees_spec.rb @@ -147,11 +147,10 @@ describe ' end it "does not allow editing to an invalid combination" do - # starting with a valid tax category / calculator combination expect(page).to have_select "#{prefix}_tax_category_id", selected: 'Inherit From Product' expect(page).to have_selector "option[selected]", text: 'Flat Percent (per item)' - + # editing to an invalid combination select 'Flat Rate (per order)', from: "#{prefix}_calculator_type" expect{ click_button 'Update' }.to_not change { fee.reload.calculator_type } @@ -178,7 +177,7 @@ describe ' fill_in "#{prefix1}_calculator_attributes_preferred_amount", with: 1.5 click_button 'Update' end - + it "handles updating two enterprise fees" do # Then I should see the updated fields for my fees expect(page).to have_select "#{prefix}_fee_type", selected: 'Fundraising fee' @@ -273,7 +272,7 @@ describe ' expect(page). not_to have_select 'sets_enterprise_fee_set_collection_attributes_1_enterprise_id', selected: 'Second Distributor' - + # A new enterprise fee is created expect(EnterpriseFee.count).to eq(fee_count) end diff --git a/spec/system/admin/flatpickr_spec.rb b/spec/system/admin/flatpickr_spec.rb index 2c94aceb5e..901566a0eb 100644 --- a/spec/system/admin/flatpickr_spec.rb +++ b/spec/system/admin/flatpickr_spec.rb @@ -19,26 +19,26 @@ describe "Test Flatpickr" do # Should no more have opened flatpickr expect(page).not_to have_selector '.flatpickr-calendar.open' end - + it "opens the datepicker and closes it by clicking outside" do login_as_admin visit 'admin/orders' open_datepicker('.datepicker') - find("#admin-menu").click + find("#admin-menu").click # Should no more have opened flatpickr expect(page).not_to have_selector '.flatpickr-calendar.open' end end - + private - + def open_datepicker(field) # Opens a datepicker find(field).click # Should have opened flatpickr expect(page).to have_selector '.flatpickr-calendar.open' end - + def check_fielddate(field, date) # Check the value is correct expect(find(field, match: :first).value).to eq date.to_datetime.strftime("%Y-%m-%d") diff --git a/spec/system/admin/order_cycles/complex_editing_spec.rb b/spec/system/admin/order_cycles/complex_editing_spec.rb index 6ab4782513..1438de2510 100644 --- a/spec/system/admin/order_cycles/complex_editing_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_spec.rb @@ -71,7 +71,7 @@ describe ' 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_id', selected: supplier.name ) - expect(page).to have_select( + expect(page).to have_select( 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: supplier.enterprise_fees.first.name ) @@ -107,7 +107,7 @@ describe ' 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_id', selected: distributor.name ) - expect(page).to have_select( + expect(page).to have_select( 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_fee_id', selected: distributor.enterprise_fees.first.name ) diff --git a/spec/system/admin/order_cycles/list_spec.rb b/spec/system/admin/order_cycles/list_spec.rb index 1f52ca973a..0db9266341 100644 --- a/spec/system/admin/order_cycles/list_spec.rb +++ b/spec/system/admin/order_cycles/list_spec.rb @@ -144,7 +144,7 @@ describe ' visit admin_order_cycles_path within("tr.order-cycle-#{oc_pt.id}") do - expect(find('input.datetimepicker', + expect(find('input.datetimepicker', match: :first).value).to start_with oc_open_at.strftime("%Y-%m-%d %H:%M") find('input.datetimepicker', match: :first).click end @@ -157,7 +157,7 @@ describe ' end within("tr.order-cycle-#{oc_pt.id}") do - expect(find('input.datetimepicker', + expect(find('input.datetimepicker', match: :first).value).to eq oc_open_at.strftime("%Y-%m-13 %H:%M") end end @@ -185,7 +185,7 @@ describe ' # Check the value is correct within("tr.order-cycle-#{oc_pt.id}") do - expect(find('input.datetimepicker', + expect(find('input.datetimepicker', match: :first).value).to eq test_value.to_datetime.strftime("%Y-%m-%d %H:%M") end end diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index 4e64e005ad..ab29ba8292 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -444,7 +444,7 @@ describe ' expect(page).to have_checked_field("order_cycle_outgoing_exchange_0_variants_#{v2.id}", disabled: true) - expect(page).not_to have_selector( + expect(page).not_to have_selector( "table.exchanges tr.distributor-#{distributor_managed.id} td.tags" ) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index ea62c5e119..526a3429ac 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -89,7 +89,7 @@ describe ' visit spree.admin_orders_path click_link 'New Order' end - + it 'shows error when distributor is not selected' do click_button 'Next' @@ -204,7 +204,7 @@ describe ' it "and then the order is cancelled and email is not sent when unchecked" do expect_any_instance_of(Spree::StockLocation).to receive(:restock).at_least(1).times expect do - within(".modal") do + within(".modal") do uncheck("send_cancellation_email") click_on("OK") end @@ -232,20 +232,20 @@ describe ' before do order.line_items << line_item - login_as_admin + login_as_admin visit spree.edit_admin_order_path(order) end context "when using the cancel button" do - before do + before do find("#cancel_order_form").click end it_should_behave_like "Cancelling the order" end - context "when using the cancel option in the dropdown" do - before do + context "when using the cancel option in the dropdown" do + before do find("#links-dropdown .ofn-drop-down").click find('a[href$="cancel"]').click end @@ -296,7 +296,7 @@ describe ' login_as_admin visit spree.edit_admin_order_path(order) find("a.delete-item").click - expect(page).to have_content "Are you sure?" + expect(page).to have_content "Are you sure?" end it "show a modal 'Are you sure?' that the user can close and then nothing change" do @@ -324,7 +324,7 @@ describe ' order.line_items = [order.line_items.first] login_as_admin visit spree.edit_admin_order_path(order) - find("a.delete-item").click + find("a.delete-item").click end it_should_behave_like "Cancelling the order" @@ -398,11 +398,11 @@ describe ' it "creates order and shipment successfully and allows proceeding to payment" do fill_in "order_email", with: "test@test.com" - + expect(page).to have_selector('#order_ship_address_attributes_firstname') check "order_use_billing" expect(page).not_to have_selector('#order_ship_address_attributes_firstname') - + fill_in "order_bill_address_attributes_firstname", with: "Clark" fill_in "order_bill_address_attributes_lastname", with: "Kent" fill_in "order_bill_address_attributes_address1", with: "Smallville" @@ -595,7 +595,7 @@ describe ' end it "shows the link" do - expect(page).to have_link "Resend Confirmation", + expect(page).to have_link "Resend Confirmation", href: spree.resend_admin_order_path(order) end @@ -614,7 +614,7 @@ describe ' end it "shows the link" do - expect(page).to have_link "Cancel Order", + expect(page).to have_link "Cancel Order", href: spree.fire_admin_order_path(order, e: 'cancel') end @@ -630,9 +630,8 @@ describe ' end end end - + context "Check send/print invoice links" do - shared_examples_for 'can send/print invoices' do before do visit spree.edit_admin_order_path(order) @@ -671,7 +670,7 @@ describe ' before do distributor1.update_attribute(:abn, '12345678') end - + it_should_behave_like 'can send/print invoices' end @@ -732,7 +731,7 @@ describe ' "Shipping: #{different_shipping_method_for_distributor1.name}" ) - within "#order-total" do + within "#order-total" do expect(page).to have_content "$175.00" end end @@ -759,7 +758,7 @@ describe ' "Shipping: #{different_shipping_method_for_distributor1.name} $15.00" ) - within "#order-total" do + within "#order-total" do expect(page).to have_content "$160.00" end end @@ -775,9 +774,9 @@ describe ' "Shipping: #{different_shipping_method_for_distributor1.name} $15.00" ) - within "#order-total" do + within "#order-total" do expect(page).to have_content "$160.00" - end + end end end end @@ -793,7 +792,7 @@ describe ' "Shipping: #{different_shipping_method_for_distributor1.name} $15.00" ) - within "#order-total" do + within "#order-total" do expect(page).to have_content "$160.00" end end @@ -804,15 +803,15 @@ describe ' end it "should not update the shipping cost" do - # Since the order is completed, the price is not supposed to be updated + # Since the order is completed, the price is not supposed to be updated visit spree.edit_admin_order_path(order) expect(page).to have_content( "Shipping: #{different_shipping_method_for_distributor1.name} $15.00" ) - within "#order-total" do + within "#order-total" do expect(page).to have_content "$160.00" - end + end end end end @@ -921,7 +920,7 @@ describe ' end expect(page).to_not have_content incomplete_order.products.first.name end - + # updates the order and verifies the warning disappears click_button 'Update And Recalculate Fees' expect(page).to_not have_content "Out of Stock".upcase @@ -956,7 +955,7 @@ describe ' expect(o.order_cycle).to eq order_cycle1 end end - + describe "searching customers" do def serching_for_customers # opens the customer dropdown @@ -978,7 +977,7 @@ describe ' end context "as the enterprise owner" do - before do + before do product.variants.first.update(on_demand: false, on_hand: 0) login_as user @@ -989,7 +988,7 @@ describe ' it "finds a customer by name" do serching_for_customers end - end + end context "as superadmin" do before do @@ -999,7 +998,7 @@ describe ' new_order_with_distribution(distributor, order_cycle) expect(page).to have_selector 'h1', text: "Customer Details" end - + it "finds a customer by name" do serching_for_customers end diff --git a/spec/system/admin/shipping_methods_spec.rb b/spec/system/admin/shipping_methods_spec.rb index bb21736057..6b05c91085 100644 --- a/spec/system/admin/shipping_methods_spec.rb +++ b/spec/system/admin/shipping_methods_spec.rb @@ -47,7 +47,7 @@ describe 'shipping methods' do it "deleting a shipping method" do visit spree.admin_shipping_methods_path - + accept_alert 'Are you sure?' do page.find('a.delete-resource').click end @@ -89,7 +89,7 @@ describe 'shipping methods' do select2_select 'None', from: 'calc_type' click_button 'Update' - + expect(@shipping_method.reload.calculator_type).to eq "Calculator::None" end end