Fix Layout/LineLength

This commit is contained in:
Neal Chambers
2023-08-03 08:48:51 +09:00
parent 32cc776725
commit a4f270bdec
22 changed files with 274 additions and 282 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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])

View File

@@ -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

View File

@@ -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