diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 09ca46100a..2d626253af 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,39 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp` -# using RuboCop version 1.55.0. +# using RuboCop version 1.55.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 67 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. -# URISchemes: http, https -Layout/LineLength: - Exclude: - - '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/spree/admin/orders_controller_spec.rb' - - 'spec/lib/reports/customers_report_spec.rb' - - 'spec/migrations/migrate_customer_names_spec.rb' - - 'spec/models/order_cycle_spec.rb' - - 'spec/models/product_importer_spec.rb' - - 'spec/models/spree/adjustment_spec.rb' - - 'spec/models/spree/line_item_spec.rb' - - 'spec/models/spree/variant_spec.rb' - - 'spec/services/products_renderer_spec.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/orders_spec.rb' - - 'spec/system/admin/product_import_spec.rb' - - 'spec/system/consumer/shopping/cart_spec.rb' - - 'spec/system/consumer/shopping/products_spec.rb' - # Offense count: 17 # Configuration parameters: AllowedMethods. # AllowedMethods: enums @@ -1108,7 +1080,7 @@ Style/HashLikeCase: Exclude: - 'app/models/enterprise.rb' -# Offense count: 1781 +# Offense count: 1792 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys diff --git a/app/controllers/spree/users_controller.rb b/app/controllers/spree/users_controller.rb index dc60c31d24..6fdcebe89b 100644 --- a/app/controllers/spree/users_controller.rb +++ b/app/controllers/spree/users_controller.rb @@ -49,8 +49,10 @@ module Spree render cable_ready: cable_car.inner_html( "#signup-feedback", partial("layouts/alert", - locals: { type: "success", - message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') }) + locals: { + type: "success", + message: t('devise.user_registrations.spree_user.signed_up_but_unconfirmed') + }) ) else render status: :unprocessable_entity, cable_ready: cable_car.morph( diff --git a/app/models/customer.rb b/app/models/customer.rb index 8157681269..35a9994cff 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -41,8 +41,8 @@ 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 - } + 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/app/models/spree/line_item.rb b/app/models/spree/line_item.rb index 27e8a9cd2a..2ecd84f0ba 100644 --- a/app/models/spree/line_item.rb +++ b/app/models/spree/line_item.rb @@ -50,7 +50,8 @@ module Spree delegate :product, :variant_unit, :unit_description, :display_name, :display_as, to: :variant - attr_accessor :skip_stock_check, :target_shipment # Allows manual skipping of Stock::AvailabilityValidator + # Allows manual skipping of Stock::AvailabilityValidator + attr_accessor :skip_stock_check, :target_shipment attribute :restock_item, type: :boolean, default: true diff --git a/spec/controllers/admin/order_cycles_controller_spec.rb b/spec/controllers/admin/order_cycles_controller_spec.rb index eb7683ccf6..ec24281cfb 100644 --- a/spec/controllers/admin/order_cycles_controller_spec.rb +++ b/spec/controllers/admin/order_cycles_controller_spec.rb @@ -35,7 +35,7 @@ module Admin context "json" do context "where ransack conditions are specified" do - it "loads order cycles that closed within the past month, and orders without a close_at date" do + it "loads order cycles closed within past month, and orders w/o a close_at date" do get :index, as: :json expect(assigns(:collection)).to_not include oc1, oc2 expect(assigns(:collection)).to include oc3, oc4 @@ -45,7 +45,7 @@ module Admin context "where q[orders_close_at_gt] is set" do let(:q) { { orders_close_at_gt: 45.days.ago } } - it "loads order cycles that closed after the specified date, and orders without a close_at date" do + it "loads order cycles closed after specified date, and orders w/o a close_at date" do get :index, as: :json, params: { q: q } expect(assigns(:collection)).to_not include oc1 expect(assigns(:collection)).to include oc2, oc3, oc4 @@ -97,7 +97,9 @@ module Admin it "renders the set_coordinator template and sets a flash error" do get :new, params: { coordinator_id: distributor3.id } expect(response).to render_template :set_coordinator - expect(flash[:error]).to eq "You don't have permission to create an order cycle coordinated by that enterprise" + expect(flash[:error]) + .to eq "You don't have permission to create an order cycle " \ + "coordinated by that enterprise" end end end @@ -122,10 +124,10 @@ module Admin let!(:distributor) { create(:distributor_enterprise) } let(:order_cycle) { create(:simple_order_cycle, coordinator: distributor) } before do - order_cycle.exchanges.create! sender: distributor, receiver: distributor, incoming: true, - receival_instructions: 'A', tag_list: "A" - order_cycle.exchanges.create! sender: distributor, receiver: distributor, incoming: false, - pickup_instructions: 'B', tag_list: "B" + order_cycle.exchanges.create! sender: distributor, receiver: distributor, + incoming: true, receival_instructions: 'A', tag_list: "A" + order_cycle.exchanges.create! sender: distributor, receiver: distributor, + incoming: false, pickup_instructions: 'B', tag_list: "B" controller_login_as_enterprise_user([distributor]) end @@ -281,7 +283,9 @@ module Admin allow(form_mock).to receive(:save) { true } spree_put :update, params. - merge(order_cycle: { preferred_product_selection_from_coordinator_inventory_only: true }) + merge(order_cycle: { + preferred_product_selection_from_coordinator_inventory_only: true + }) end it "can update preference automatic_notifications" do @@ -308,15 +312,19 @@ module Admin incoming: true, variants: [v]) } let!(:outgoing_exchange) { - create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: hub, incoming: false, - variants: [v]) + create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: hub, + incoming: false, variants: [v]) } let(:allowed) { { incoming_exchanges: [], outgoing_exchanges: [] } } let(:restricted) { { name: 'some name', orders_open_at: 1.day.from_now.to_s, orders_close_at: 1.day.ago.to_s } } - let(:params) { { format: :json, id: order_cycle.id, order_cycle: allowed.merge(restricted) } } + let(:params) { + { + format: :json, id: order_cycle.id, order_cycle: allowed.merge(restricted) + } + } let(:form_mock) { instance_double(OrderCycleForm, save: true) } before { allow(controller).to receive(:spree_current_user) { user } } @@ -371,7 +379,8 @@ module Admin spree_put :bulk_update, format: :json end.to change(oc, :orders_open_at).by(0) json_response = JSON.parse(response.body) - expect(json_response['errors']).to eq 'Hm, something went wrong. No order cycle data found.' + expect(json_response['errors']) + .to eq 'Hm, something went wrong. No order cycle data found.' end context "when a validation error occurs" do @@ -457,7 +466,9 @@ module Admin it "displays an error message when we attempt to delete it" do get :destroy, params: { id: oc.id } expect(response).to redirect_to admin_order_cycles_path - expect(flash[:error]).to eq 'That order cycle has been selected by a customer and cannot be deleted. To prevent customers from accessing it, please close it instead.' + expect(flash[:error]) + .to eq 'That order cycle has been selected by a customer and cannot be deleted. ' \ + 'To prevent customers from accessing it, please close it instead.' end end @@ -467,7 +478,9 @@ module Admin it "displays an error message when we attempt to delete it" do get :destroy, params: { id: oc.id } expect(response).to redirect_to admin_order_cycles_path - expect(flash[:error]).to eq 'That order cycle is linked to a schedule and cannot be deleted. Please unlink or delete the schedule first.' + expect(flash[:error]) + .to eq 'That order cycle is linked to a schedule and cannot be deleted. ' \ + 'Please unlink or delete the schedule first.' end end diff --git a/spec/controllers/spree/admin/orders_controller_spec.rb b/spec/controllers/spree/admin/orders_controller_spec.rb index ad64e9e395..dd1bd877bf 100644 --- a/spec/controllers/spree/admin/orders_controller_spec.rb +++ b/spec/controllers/spree/admin/orders_controller_spec.rb @@ -249,7 +249,8 @@ describe Spree::Admin::OrdersController, type: :controller do context "and no errors" do it "updates distribution charges and redirects to payments page" do expect_any_instance_of(Spree::Order).to receive(:recreate_all_fees!) - allow_any_instance_of(Spree::Order).to receive(:ensure_available_shipping_rates).and_return(true) + allow_any_instance_of(Spree::Order) + .to receive(:ensure_available_shipping_rates).and_return(true) expect { spree_put :update, params diff --git a/spec/lib/reports/customers_report_spec.rb b/spec/lib/reports/customers_report_spec.rb index 0289a739a1..e42e948f58 100644 --- a/spec/lib/reports/customers_report_spec.rb +++ b/spec/lib/reports/customers_report_spec.rb @@ -91,11 +91,13 @@ module Reporting let!(:sm) { create(:shipping_method, distributors: [d]) } let!(:o1) { create(:order_with_totals_and_distribution, :completed, distributor: d, - bill_address: a, shipping_method: sm) + bill_address: a, + shipping_method: sm) } let!(:o2) { create(:order_with_totals_and_distribution, :completed, distributor: d, - bill_address: a, shipping_method: sm) + bill_address: a, + shipping_method: sm) } before do [o1, o2].each do |order| @@ -106,13 +108,14 @@ module Reporting it "returns only one row per customer" do expect(subject.query_result).to match_array [o1] expect(subject.table_rows.size).to eq(1) - expect(subject.table_rows).to eq([[ - a.firstname, a.lastname, - [a.address1, a.address2, a.city].join(" "), - o1.email, a.phone, d.name, - [d.address.address1, d.address.address2, d.address.city].join(" "), - o1.shipping_method.name - ]]) + expect(subject.table_rows) + .to eq([[ + a.firstname, a.lastname, + [a.address1, a.address2, a.city].join(" "), + o1.email, a.phone, d.name, + [d.address.address1, d.address.address2, d.address.city].join(" "), + o1.shipping_method.name + ]]) end context "orders from different hubs" do @@ -120,25 +123,27 @@ module Reporting let!(:sm2) { create(:shipping_method, distributors: [d2]) } let!(:o2) { create(:order_with_totals_and_distribution, :completed, distributor: d2, - bill_address: a, shipping_method: sm2) + bill_address: a, + shipping_method: sm2) } it "returns one row per customer per hub" do expect(subject.query_result.size).to eq(2) expect(subject.table_rows.size).to eq(2) - expect(subject.table_rows).to eq([[ - a.firstname, a.lastname, - [a.address1, a.address2, a.city].join(" "), - o1.email, a.phone, d.name, - [d.address.address1, d.address.address2, d.address.city].join(" "), - o1.shipping_method.name - ], [ - a.firstname, a.lastname, - [a.address1, a.address2, a.city].join(" "), - o2.email, a.phone, d2.name, - [d2.address.address1, d2.address.address2, d2.address.city].join(" "), - o2.shipping_method.name - ]]) + expect(subject.table_rows) + .to eq([[ + a.firstname, a.lastname, + [a.address1, a.address2, a.city].join(" "), + o1.email, a.phone, d.name, + [d.address.address1, d.address.address2, d.address.city].join(" "), + o1.shipping_method.name + ], [ + a.firstname, a.lastname, + [a.address1, a.address2, a.city].join(" "), + o2.email, a.phone, d2.name, + [d2.address.address1, d2.address.address2, d2.address.city].join(" "), + o2.shipping_method.name + ]]) end end @@ -146,7 +151,8 @@ module Reporting 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) + bill_address: a, + shipping_method: sm2) } before do o2.select_shipping_method(sm2.id) diff --git a/spec/migrations/migrate_customer_names_spec.rb b/spec/migrations/migrate_customer_names_spec.rb index 00f1224d11..2e014efefa 100644 --- a/spec/migrations/migrate_customer_names_spec.rb +++ b/spec/migrations/migrate_customer_names_spec.rb @@ -13,11 +13,14 @@ describe MigrateCustomerNames do before do Spree::Preference.create(value: true, - value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}") + value_type: "boolean", + key: "/enterprise/show_customer_names_to_suppliers/#{enterprise1.id}") Spree::Preference.create(value: false, - value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}") + value_type: "boolean", + key: "/enterprise/show_customer_names_to_suppliers/#{enterprise2.id}") Spree::Preference.create(value: true, - value_type: "boolean", key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}") + value_type: "boolean", + key: "/enterprise/show_customer_names_to_suppliers/#{enterprise4.id}") end describe '#migrate_customer_names_preferences!' do diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index fd90ad7c32..eae8291131 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -204,8 +204,9 @@ describe OrderCycle do end it "reports on the variants exchanged" do - expect(oc.variants).to match_array [p0.variants.first, p1.variants.first, p2.variants.first, p2_v, p1_v_visible, - p1_v_hidden] + expect(oc.variants) + .to match_array [p0.variants.first, p1.variants.first, p2.variants.first, p2_v, + p1_v_visible, p1_v_hidden] end it "returns the correct count of variants" do @@ -217,8 +218,8 @@ describe OrderCycle do end it "reports on the variants distributed" do - expect(oc.distributed_variants).to match_array [p1.variants.first, p2.variants.first, p2_v, p1_v_visible, - p1_v_hidden] + expect(oc.distributed_variants) + .to match_array [p1.variants.first, p2.variants.first, p2_v, p1_v_visible, p1_v_hidden] end it "reports on the products distributed by a particular distributor" do diff --git a/spec/models/product_importer_spec.rb b/spec/models/product_importer_spec.rb index 98fe95bad5..edda720680 100644 --- a/spec/models/product_importer_spec.rb +++ b/spec/models/product_importer_spec.rb @@ -779,8 +779,8 @@ describe ProductImport::ProductImporter do CSV.generate do |csv| csv << [" name ", "\ndisplay_name\n", "\rdistributor\r", "\tproducer\t", " on_hand ", " price ", " units "] - csv << [" Oats ", "\nPorridge Oats\n", "\r#{enterprise2.name}\r", "\t#{enterprise.name}\t", - " 900 ", " 1.0 ", " 500 "] + csv << [" Oats ", "\nPorridge Oats\n", "\r#{enterprise2.name}\r", + "\t#{enterprise.name}\t", " 900 ", " 1.0 ", " 500 "] end } let(:importer) { import_data csv_data, import_into: 'inventories' } diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index b22c31a5c2..5482d03024 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -336,8 +336,8 @@ module Spree describe "EnterpriseFee adjustments" do let(:zone) { create(:zone_with_member) } let(:fee_tax_rate) { - create(:tax_rate, included_in_price: true, calculator: ::Calculator::DefaultTax.new, zone: zone, - amount: 0.1) + create(:tax_rate, included_in_price: true, calculator: ::Calculator::DefaultTax.new, + zone: zone, amount: 0.1) } let(:fee_tax_category) { create(:tax_category, tax_rates: [fee_tax_rate]) } @@ -364,7 +364,9 @@ module Spree context "when enterprise fees are taxed per-order" do let(:enterprise_fee) { create(:enterprise_fee, enterprise: coordinator, tax_category: fee_tax_category, - calculator: ::Calculator::FlatRate.new(preferred_amount: 50.0)) + calculator: ::Calculator::FlatRate.new( + preferred_amount: 50.0 + )) } describe "when the tax rate includes the tax in the price" do @@ -425,7 +427,7 @@ module Spree end end - context "when enterprise fees inherit their tax_category from the product they are applied to" do + context "when enterprise fees inherit tax_category from the product they are applied to" do let(:product_tax_rate) { create(:tax_rate, included_in_price: true, calculator: ::Calculator::DefaultTax.new, zone: zone, amount: 0.2) @@ -440,7 +442,9 @@ module Spree context "when enterprise fees are taxed per-order" do let(:enterprise_fee) { create(:enterprise_fee, enterprise: coordinator, inherits_tax_category: false, - calculator: ::Calculator::FlatRate.new(preferred_amount: 50.0)) + calculator: ::Calculator::FlatRate.new( + preferred_amount: 50.0 + )) } before do diff --git a/spec/models/spree/line_item_spec.rb b/spec/models/spree/line_item_spec.rb index 30af1dde24..e5f3141d54 100644 --- a/spec/models/spree/line_item_spec.rb +++ b/spec/models/spree/line_item_spec.rb @@ -205,7 +205,8 @@ module Spree end it "finds line items from a given order cycle" do - expect(LineItem.from_order_cycle(oc_order.order_cycle).first.id).to eq oc_order.line_items.first.id + expect(LineItem.from_order_cycle(oc_order.order_cycle).first.id) + .to eq oc_order.line_items.first.id end end @@ -338,9 +339,8 @@ module Spree it "draws stock from the variant override" do expect(vo.reload.count_on_hand).to eq 3 - expect{ line_item.increment!(:quantity) }.to_not change{ - Spree::Variant.find(variant.id).on_hand - } + expect{ line_item.increment!(:quantity) } + .to_not change{ Spree::Variant.find(variant.id).on_hand } expect(vo.reload.count_on_hand).to eq 2 end end diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index 93a0e603da..5dc310d167 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -371,7 +371,7 @@ describe Spree::Variant do visible: true ) } - it "lists any variants that are not listed as visible=false only for the relevant enterprise" do + it "lists any variants not listed as visible=false only for the relevant enterprise" do expect(variants).to include new_variant, visible_variant expect(variants).to_not include hidden_variant end @@ -494,9 +494,8 @@ describe Spree::Variant do order_cycle = double(:order_cycle) variant = Spree::Variant.new - expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator).to receive(:fees_for).with(variant) { - 23 - } + expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator) + .to receive(:fees_for).with(variant) { 23 } expect(variant.fees_for(distributor, order_cycle)).to eq(23) end @@ -509,9 +508,8 @@ describe Spree::Variant do variant = Spree::Variant.new fees = double(:fees) - expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator).to receive(:fees_by_type_for).with(variant) { - fees - } + expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator) + .to receive(:fees_by_type_for).with(variant) { fees } expect(variant.fees_by_type_for(distributor, order_cycle)).to eq(fees) end @@ -719,7 +717,8 @@ describe Spree::Variant do } it "requests the new value from OptionValueName" do - expect_any_instance_of(VariantUnits::OptionValueNamer).to receive(:name).exactly(1).times.and_call_original + expect_any_instance_of(VariantUnits::OptionValueNamer) + .to receive(:name).exactly(1).times.and_call_original v.update(unit_value: 10, unit_description: 'foo') expect(v.unit_presentation).to eq "10g foo" end diff --git a/spec/services/products_renderer_spec.rb b/spec/services/products_renderer_spec.rb index 913c04c7ee..1948439e81 100644 --- a/spec/services/products_renderer_spec.rb +++ b/spec/services/products_renderer_spec.rb @@ -88,7 +88,9 @@ describe ProductsRenderer do product_apples.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, - { q: { with_properties: [property_organic.id] } }) + { q: { + with_properties: [property_organic.id] + } }) products = products_renderer.send(:products) expect(products).to eq([product_apples]) end @@ -97,7 +99,9 @@ describe ProductsRenderer do fruits_supplier.producer_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, - { q: { with_properties: [property_organic.id] } }) + { q: { + with_properties: [property_organic.id] + } }) products = products_renderer.send(:products) expect(products).to eq([product_apples, product_cherries]) end @@ -115,7 +119,9 @@ describe ProductsRenderer do product_doughnuts.product_properties.create!({ property_id: property_organic.id, value: '1', position: 1 }) products_renderer = ProductsRenderer.new(distributor, order_cycle, customer, - { q: { with_properties: [property_organic.id] } }) + { q: { + with_properties: [property_organic.id] + } }) products = products_renderer.send(:products) expect(products).to eq([product_cherries, product_banana_bread, product_doughnuts]) end diff --git a/spec/system/admin/adjustments_spec.rb b/spec/system/admin/adjustments_spec.rb index 6494e02bad..89224ac778 100644 --- a/spec/system/admin/adjustments_spec.rb +++ b/spec/system/admin/adjustments_spec.rb @@ -38,7 +38,8 @@ describe ' visit spree.admin_orders_path end - shared_examples "when the enable_localized_number preference" do |adjustment_label, adjustment_amount, tax_category, tax, tax_total| + shared_examples "when the enable_localized_number preference" \ + do |adjustment_label, adjustment_amount, tax_category, tax, tax_total| it "creates the adjustment and calculates taxes" do # When I go to the adjustments page for the order page.find('td.actions a.icon-edit').click diff --git a/spec/system/admin/bulk_order_management_spec.rb b/spec/system/admin/bulk_order_management_spec.rb index 3abeaa61ed..f5912c08d5 100644 --- a/spec/system/admin/bulk_order_management_spec.rb +++ b/spec/system/admin/bulk_order_management_spec.rb @@ -264,8 +264,9 @@ describe ' it "displays a column for user's full name" do expect(page).to have_selector "th.full_name", text: "NAME" - expect(page).to have_selector "td.full_name", - text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}" + expect(page) + .to have_selector "td.full_name", + text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}" expect(page).to have_selector "td.full_name", text: "" end @@ -1033,7 +1034,9 @@ describe ' visit_bulk_order_management expect(page).to have_selector "a.delete-line-item", count: 2 find("tr#li_#{li2.id} a.delete-line-item").click - expect(page).to have_content "This operation will result in one or more empty orders, which will be cancelled. Do you wish to proceed?" + expect(page) + .to have_content "This operation will result in one or more empty orders, " \ + "which will be cancelled. Do you wish to proceed?" expect(page).to have_checked_field "Restock Items: return all items to stock" end @@ -1057,7 +1060,8 @@ describe ' end.to_not have_enqueued_mail(Spree::OrderMailer, :cancel_email) end - it "the user can confirm + wants to send email confirmation : line item is then deleted, order is canceled and email is sent" do + it "the user can confirm + wants to send email confirmation : line item is " \ + "then deleted, order is canceled and email is sent" do expect_any_instance_of(Spree::StockLocation).to receive(:restock).at_least(1).times expect do within(".modal") do @@ -1069,7 +1073,8 @@ describe ' 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 + 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 within(".modal") do diff --git a/spec/system/admin/customers_spec.rb b/spec/system/admin/customers_spec.rb index c5616866cf..fc7172697b 100644 --- a/spec/system/admin/customers_spec.rb +++ b/spec/system/admin/customers_spec.rb @@ -37,7 +37,8 @@ describe 'Customers' do # Prompts for a hub for a list of my managed enterprises expect(page) .to have_select2 "shop_id", with_options: [managed_distributor1.name, - managed_distributor2.name], without_options: [unmanaged_distributor.name] + managed_distributor2.name], + without_options: [unmanaged_distributor.name] select2_select managed_distributor2.name, from: "shop_id" diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index ab29ba8292..a465a36097 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -342,8 +342,9 @@ describe ' expect(page).to have_field 'order_cycle_name', with: oc.name select2_select schedule.name, from: 'schedule_ids' - expect(page).not_to have_select2 'schedule_ids', - with_options: [schedule_of_other_managed_distributor.name] + expect(page) + .not_to have_select2 'schedule_ids', + with_options: [schedule_of_other_managed_distributor.name] click_button 'Save and Next' @@ -619,10 +620,14 @@ describe ' oc = OrderCycle.last expect(page).to have_input "oc#{oc.id}[name]", value: "Plums & Avos" - expect(page).to have_input "oc#{oc.id}[orders_open_at]", - value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false - expect(page).to have_input "oc#{oc.id}[orders_close_at]", - value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false + expect(page) + .to have_input "oc#{oc.id}[orders_open_at]", + value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), + visible: false + expect(page) + .to have_input "oc#{oc.id}[orders_close_at]", + value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), + visible: false # And it should have some variants selected expect(oc.exchanges.incoming.first.variants.count).to eq(2) @@ -729,10 +734,14 @@ describe ' oc = OrderCycle.last expect(page).to have_input "oc#{oc.id}[name]", value: "Plums & Avos" - expect(page).to have_input "oc#{oc.id}[orders_open_at]", - value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), visible: false - expect(page).to have_input "oc#{oc.id}[orders_close_at]", - value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), visible: false + expect(page) + .to have_input "oc#{oc.id}[orders_open_at]", + value: Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0).strftime("%F %T %z"), + visible: false + expect(page) + .to have_input "oc#{oc.id}[orders_close_at]", + value: Time.zone.local(2040, 10, 24, 17, 0o0, 0o0).strftime("%F %T %z"), + visible: false # And it should have a variant selected expect(oc.exchanges.incoming.first.variants).to eq([v2]) diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index e6251d0603..69597a7b49 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -256,7 +256,8 @@ describe ' let!(:order_not_empty_no_address) { create(:order_with_line_items, line_items_count: 1, user: customer2, - distributor: distributor2, bill_address_id: nil, ship_address_id: nil) + distributor: distributor2, bill_address_id: nil, + ship_address_id: nil) } before do diff --git a/spec/system/admin/product_import_spec.rb b/spec/system/admin/product_import_spec.rb index fd2d1559c5..ec0a2d43de 100644 --- a/spec/system/admin/product_import_spec.rb +++ b/spec/system/admin/product_import_spec.rb @@ -62,14 +62,11 @@ describe "Product Import" do it "validates entries and saves them if they are all valid and allows viewing new items " \ "in Bulk Products" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type", - "shipping_category_id"] - csv << ["Carrots", "User Enterprise", "Vegetables", "5", "3.20", "500", "g", - shipping_category_id_str] - csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6.50", "1", "kg", - shipping_category_id_str] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, units, unit_type, shipping_category_id + Carrots, User Enterprise, Vegetables, 5, 3.20, 500, g, #{shipping_category_id_str} + Potatoes, User Enterprise, Vegetables, 6, 6.50, 1, kg, #{shipping_category_id_str} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -108,17 +105,14 @@ describe "Product Import" do end it "displays info about invalid entries but no save button if all items are invalid" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type", - "shipping_category_id"] - csv << ["Carrots", "User Enterprise", "Vegetables", "5", "3.20", "500", "g", - shipping_category_id_str] - csv << ["Carrots", "User Enterprise", "Vegetables", "5", "5.50", "1", "kg", - shipping_category_id_str] - csv << ["Bad Carrots", "Unkown Enterprise", "Mouldy vegetables", "666", "3.20", "", "g", - shipping_category_id_str] - csv << ["Bad Potatoes", "", "Vegetables", "6", "6", "6", ""] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, units, unit_type, shipping_category_id + Carrots, User Enterprise, Vegetables, 5, 3.20, 500, g, #{shipping_category_id_str} + Carrots, User Enterprise, Vegetables, 5, 5.50, 1, kg, #{shipping_category_id_str} + Bad Carrots, Unkown Enterprise, Mouldy vegetables, 666, 3.20, , g, \ + #{shipping_category_id_str} + Bad Potatoes, , Vegetables, 6, 6, 6, , + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -138,14 +132,12 @@ describe "Product Import" do end it "displays info about inconsistent variant unit names, within the same product" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type", - "variant_unit_name", "shipping_category_id"] - csv << ["Carrots", "User Enterprise", "Vegetables", "50", "3.20", "250", "", "Bag", - shipping_category_id_str] - csv << ["Carrots", "User Enterprise", "Vegetables", "50", "6.40", "500", "", "Big-Bag", - shipping_category_id_str] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, units, unit_type, variant_unit_name, \ + shipping_category_id + Carrots, User Enterprise, Vegetables, 50, 3.20, 250, , Bag, #{shipping_category_id_str} + Carrots, User Enterprise, Vegetables, 50, 6.40, 500, , Big-Bag, #{shipping_category_id_str} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -164,12 +156,11 @@ describe "Product Import" do end it "handles saving of named tax and shipping categories" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type", - "tax_category", "shipping_category"] - csv << ["Carrots", "User Enterprise", "Vegetables", "5", "3.20", "500", "g", - tax_category.name, shipping_category.name] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, units, unit_type, tax_category, shipping_category + Carrots, User Enterprise, Vegetables, 5, 3.20, 500, g, #{tax_category.name}, \ + #{shipping_category.name} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -195,14 +186,11 @@ describe "Product Import" do end it "records a timestamp on import that can be viewed and filtered under Bulk Edit Products" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type", - "shipping_category_id"] - csv << ["Carrots", "User Enterprise", "Vegetables", "5", "3.20", "500", "g", - shipping_category_id_str] - csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6.50", "1", "kg", - shipping_category_id_str] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, units, unit_type, shipping_category_id + Carrots, User Enterprise, Vegetables, 5, 3.20, 500, g, #{shipping_category_id_str} + Potatoes, User Enterprise, Vegetables, 6, 6.50, 1, kg, #{shipping_category_id_str} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -244,12 +232,10 @@ describe "Product Import" do end it "can reset product stock to zero for products not present in the CSV" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type", - "shipping_category_id"] - csv << ["Carrots", "User Enterprise", "Vegetables", "500", "3.20", "500", "g", - shipping_category_id_str] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, units, unit_type, shipping_category_id + Carrots, User Enterprise, Vegetables, 500, 3.20, 500, g, #{shipping_category_id_str} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -274,16 +260,15 @@ describe "Product Import" do it "can save a new product and variant of that product at the same time, " \ "add variant to existing product" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type", - "display_name", "shipping_category_id"] - csv << ["Potatoes", "User Enterprise", "Vegetables", "5", "3.50", "500", "g", "Small Bag", - shipping_category_id_str] - csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "5.50", "2000", "g", "Big Bag", - shipping_category_id_str] - csv << ["Beans", "User Enterprise", "Vegetables", "7", "2.50", "250", "g", nil, - shipping_category_id_str] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, units, unit_type, display_name, \ + shipping_category_id + Potatoes, User Enterprise, Vegetables, 5, 3.50, 500, g, Small Bag, \ + #{shipping_category_id_str} + Potatoes, User Enterprise, Vegetables, 6, 5.50, 2000, g, Big Bag, \ + #{shipping_category_id_str} + Beans, User Enterprise, Vegetables, 7, 2.50, 250, g, , #{shipping_category_id_str} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -315,14 +300,12 @@ describe "Product Import" do end it "can import items into inventory" do - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "units"] - csv << ["Beans", "Another Enterprise", "User Enterprise", "Vegetables", "5", "3.20", "500"] - csv << ["Sprouts", "Another Enterprise", "User Enterprise", "Vegetables", "6", "6.50", - "500"] - csv << ["Cabbage", "Another Enterprise", "User Enterprise", "Vegetables", "2001", "1.50", - "500"] - end + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, units + Beans, Another Enterprise, User Enterprise, Vegetables, 5, 3.20, 500 + Sprouts, Another Enterprise, User Enterprise, Vegetables, 6, 6.50, 500 + Cabbage, Another Enterprise, User Enterprise, Vegetables, 2001, 1.50, 500 + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -377,13 +360,10 @@ describe "Product Import" do it "handles a unit of kg for inventory import" do product = create(:simple_product, supplier: enterprise, on_hand: 100, name: 'Beets', unit_value: '1000', variant_unit_scale: 1000) - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "unit_type", - "units", "on_demand"] - csv << ["Beets", "Another Enterprise", "User Enterprise", "Vegetables", nil, "3.20", "kg", - "1", "1"] - end - + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, unit_type, units, on_demand + Beets, Another Enterprise, User Enterprise, Vegetables, , 3.20, kg, 1, 1 + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -421,12 +401,11 @@ describe "Product Import" do variant_unit_name: "Bag") } it "are sucessfully imported to inventory" do - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "unit_type", - "units", "on_demand", "variant_unit_name"] - csv << ["Aubergine", "Another Enterprise", "User Enterprise", "Vegetables", "", "3.3", - "kg", "1", "1", "Bag"] - end + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, unit_type, units, on_demand, \ + variant_unit_name + Aubergine, Another Enterprise, User Enterprise, Vegetables, , 3.3, kg, 1, 1, Bag + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -455,14 +434,12 @@ describe "Product Import" do end it "displays the appropriate error message, when variant unit names are inconsistent" do - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "unit_type", - "units", "on_demand", "variant_unit_name"] - csv << ["Aubergine", "Another Enterprise", "User Enterprise", "Vegetables", "", "3.3", - "kg", "1", "1", "Bag"] - csv << ["Aubergine", "Another Enterprise", "User Enterprise", "Vegetables", "", "6.6", - "kg", "1", "1", "Big-Bag"] - end + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, unit_type, units, on_demand, \ + variant_unit_name + Aubergine, Another Enterprise, User Enterprise, Vegetables, , 3.3, kg, 1, 1, Bag + Aubergine, Another Enterprise, User Enterprise, Vegetables, , 6.6, kg, 1, 1, Big-Bag + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -483,16 +460,13 @@ describe "Product Import" do end it "invalidates units value if 0 or non-numeric" do - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "unit_type", - "units", "on_demand", "variant_unit_name"] - csv << ["Aubergine", "Another Enterprise", "User Enterprise", "Vegetables", "", "3.3", - "kg", "1", "1", "Bag"] - csv << ["Beans", "Another Enterprise", "User Enterprise", "Vegetables", "3", "3.0", - "kg", "0", "1", "Bag"] - csv << ["Cabbage", "Another Enterprise", "User Enterprise", "Vegetables", "1", "4.3", - "kg", "XX", "", "Bag"] - end + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, unit_type, units, on_demand, \ + variant_unit_name + Aubergine, Another Enterprise, User Enterprise, Vegetables, , 3.3, kg, 1, 1, Bag + Beans, Another Enterprise, User Enterprise, Vegetables, 3, 3.0, kg, 0, 1, Bag + Cabbage, Another Enterprise, User Enterprise, Vegetables, 1, 4.3, kg, XX, , Bag + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -513,16 +487,13 @@ describe "Product Import" do end it "Price validation" do - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "unit_type", - "units", "on_demand", "variant_unit_name"] - csv << ["Aubergine", "Another Enterprise", "User Enterprise", "Vegetables", "", "3.3", - "kg", "1", "1", "Bag"] - csv << ["Beans", "Another Enterprise", "User Enterprise", "Vegetables", "3", "", - "kg", "2", "1", "Bag"] - csv << ["Cabbage", "Another Enterprise", "User Enterprise", "Vegetables", "1", "t6", - "kg", "3", "", "Bag"] - end + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, unit_type, units, on_demand, \ + variant_unit_name + Aubergine, Another Enterprise, User Enterprise, Vegetables, , 3.3, kg, 1, 1, Bag + Beans, Another Enterprise, User Enterprise, Vegetables, 3, , kg, 2, 1, Bag + Cabbage, Another Enterprise, User Enterprise, Vegetables, 1, t6, kg, 3, , Bag + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -544,18 +515,13 @@ describe "Product Import" do end it "handles on_demand and on_hand validations with inventory - nill or empty values" do - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "units", - "on_demand"] - csv << ["Beans", "Another Enterprise", "User Enterprise", "Vegetables", nil, "3.20", "500", - "1"] - csv << ["Sprouts", "Another Enterprise", "User Enterprise", "Vegetables", "6", "6.50", - "500", "0"] - csv << ["Cabbage", "Another Enterprise", "User Enterprise", "Vegetables", "", "1.50", - "500", nil] - csv << ["Aubergine", "Another Enterprise", "User Enterprise", "Vegetables", nil, "1.50", - "500", ""] - end + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, units, on_demand + Beans, Another Enterprise, User Enterprise, Vegetables, , 3.20, 500, 1 + Sprouts, Another Enterprise, User Enterprise, Vegetables, 6, 6.50, 500, 0 + Cabbage, Another Enterprise, User Enterprise, Vegetables, , 1.50, 500, + Aubergine, Another Enterprise, User Enterprise, Vegetables, , 1.50, 500, + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -570,8 +536,10 @@ describe "Product Import" do expect(page).to have_selector '.invalid-count', text: "2" find('div.header-description', text: 'Items contain errors').click - expect(page).to have_content "line 4: Cabbage - On_hand incorrect value - On_demand incorrect value" - expect(page).to have_content "line 5: Aubergine - On_hand incorrect value - On_demand incorrect value" + expect(page) + .to have_content "line 4: Cabbage - On_hand incorrect value - On_demand incorrect value" + expect(page) + .to have_content "line 5: Aubergine - On_hand incorrect value - On_demand incorrect value" expect(page).to have_content "Imported file contains invalid entries" expect(page).to have_no_selector 'input[type=submit][value="Save"]' expect(page).not_to have_content "line 2: Beans" @@ -579,18 +547,18 @@ describe "Product Import" do end it "handles on_demand and on_hand validations - non-numeric values" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "on_demand", "units", "unit_type", - "display_name", "shipping_category_id"] - csv << ["Beans", "User Enterprise", "Vegetables", "invalid", "3.50", "1", "0.5", "g", "Small Bag", - shipping_category_id_str] - csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6", "invalid", "5", "kg", "Big Bag", - shipping_category_id_str] - csv << ["Cabbage", "User Enterprise", "Vegetables", "invalid", "1.5", "invalid", "1", "kg", "Bag", - shipping_category_id_str] - csv << ["Aubergine", "User Enterprise", "Vegetables", nil, "1.5", "invalid", "1", "kg", "Bag", - shipping_category_id_str] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, on_demand, units, unit_type, display_name, \ + shipping_category_id + Beans, User Enterprise, Vegetables, invalid, 3.50, 1, 0.5, g, Small Bag, \ + #{shipping_category_id_str} + Potatoes, User Enterprise, Vegetables, 6, 6, invalid, 5, kg, Big Bag, \ + #{shipping_category_id_str} + Cabbage, User Enterprise, Vegetables, invalid, 1.5, invalid, 1, kg, Bag, \ + #{shipping_category_id_str} + Aubergine, User Enterprise, Vegetables, , 1.5, invalid, 1, kg, Bag, \ + #{shipping_category_id_str} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -604,8 +572,10 @@ describe "Product Import" do expect(page).to have_selector '.invalid-count', text: "2" find('div.header-description', text: 'Items contain errors').click - expect(page).to have_content "line 4: Cabbage ( Bag ) - On_hand incorrect value - On_demand incorrect value" - expect(page).to have_content "line 5: Aubergine ( Bag ) - On_hand incorrect value - On_demand incorrect value" + expect(page).to have_content "line 4: Cabbage ( Bag ) - On_hand incorrect value - " \ + "On_demand incorrect value" + expect(page).to have_content "line 5: Aubergine ( Bag ) - On_hand incorrect value - " \ + "On_demand incorrect value" expect(page).to have_content "Imported file contains invalid entries" expect(page).to have_no_selector 'input[type=submit][value="Save"]' expect(page).not_to have_content "line 2: Beans" @@ -613,18 +583,16 @@ describe "Product Import" do end it "handles on_demand and on_hand validations - negative values" do - csv_data = CSV.generate do |csv| - csv << ["name", "producer", "category", "on_hand", "price", "on_demand", "units", "unit_type", - "display_name", "shipping_category_id"] - csv << ["Beans", "User Enterprise", "Vegetables", "-1", "3.50", "1", "500", "g", "Small Bag", - shipping_category_id_str] - csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6", "-1", "500", "g", "Big Bag", - shipping_category_id_str] - csv << ["Cabbage", "User Enterprise", "Vegetables", "-1", "1.5", "-1", "1", "kg", "Bag", - shipping_category_id_str] - csv << ["Aubergine", "User Enterprise", "Vegetables", nil, "1.5", "-1", "1", "kg", "Bag", - shipping_category_id_str] - end + csv_data = <<~CSV + name, producer, category, on_hand, price, on_demand, units, unit_type, display_name, \ + shipping_category_id + Beans, User Enterprise, Vegetables, -1, 3.50, 1, 500, g, Small Bag, \ + #{shipping_category_id_str} + Potatoes, User Enterprise, Vegetables, 6, 6, -1, 500, g, Big Bag, \ + #{shipping_category_id_str} + Cabbage, User Enterprise, Vegetables, -1, 1.5, -1, 1, kg, Bag, #{shipping_category_id_str} + Aubergine, User Enterprise, Vegetables, , 1.5, -1, 1, kg, Bag, #{shipping_category_id_str} + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path @@ -638,8 +606,10 @@ describe "Product Import" do expect(page).to have_selector '.invalid-count', text: "2" find('div.header-description', text: 'Items contain errors').click - expect(page).to have_content "line 4: Cabbage ( Bag ) - On_hand incorrect value - On_demand incorrect value" - expect(page).to have_content "line 5: Aubergine ( Bag ) - On_hand incorrect value - On_demand incorrect value" + expect(page).to have_content "line 4: Cabbage ( Bag ) - On_hand incorrect value - " \ + "On_demand incorrect value" + expect(page).to have_content "line 5: Aubergine ( Bag ) - On_hand incorrect value - " \ + "On_demand incorrect value" expect(page).to have_content "Imported file contains invalid entries" expect(page).to have_no_selector 'input[type=submit][value="Save"]' expect(page).not_to have_content "line 2: Beans" @@ -647,16 +617,12 @@ describe "Product Import" do end it "handles on_demand and on_hand validations with inventory - With both values set" do - csv_data = CSV.generate do |csv| - csv << ["name", "distributor", "producer", "category", "on_hand", "price", "units", - "on_demand"] - csv << ["Beans", "Another Enterprise", "User Enterprise", "Vegetables", "6", "3.20", "500", - "1"] - csv << ["Sprouts", "Another Enterprise", "User Enterprise", "Vegetables", "6", "6.50", - "500", "1"] - csv << ["Cabbage", "Another Enterprise", "User Enterprise", "Vegetables", "0", "1.50", - "500", "1"] - end + csv_data = <<~CSV + name, distributor, producer, category, on_hand, price, units, on_demand + Beans, Another Enterprise, User Enterprise, Vegetables, 6, 3.20, 500, 1 + Sprouts, Another Enterprise, User Enterprise, Vegetables, 6, 6.50, 500, 1 + Cabbage, Another Enterprise, User Enterprise, Vegetables, 0, 1.50, 500, 1 + CSV File.write('/tmp/test.csv', csv_data) visit main_app.admin_product_import_path diff --git a/spec/system/consumer/shopping/cart_spec.rb b/spec/system/consumer/shopping/cart_spec.rb index 6e24698cd7..eb129c4dda 100644 --- a/spec/system/consumer/shopping/cart_spec.rb +++ b/spec/system/consumer/shopping/cart_spec.rb @@ -143,9 +143,9 @@ describe "full-page cart" do describe "admin weight calculated fees" do context "order with 2 line items" do let(:admin_fee) { - create(:enterprise_fee, calculator: Calculator::Weight.new(preferred_per_unit: 1, - preferred_unit_from_list: "kg"), - enterprise: order_cycle.coordinator, fee_type: 'admin') + create(:enterprise_fee, calculator: Calculator::Weight.new( + preferred_per_unit: 1, preferred_unit_from_list: "kg" + ), enterprise: order_cycle.coordinator, fee_type: 'admin') } before do diff --git a/spec/system/consumer/shopping/products_spec.rb b/spec/system/consumer/shopping/products_spec.rb index 5f570358a8..1e75fd7b7c 100644 --- a/spec/system/consumer/shopping/products_spec.rb +++ b/spec/system/consumer/shopping/products_spec.rb @@ -94,8 +94,9 @@ describe "As a consumer I want to view products" do visit shop_path expect(page).to have_content product.name - expect_product_description_html_to_be_displayed(product, "
Safe
", - "", truncate: false) + expect_product_description_html_to_be_displayed( + product, "Safe
", "", truncate: false + ) end end