mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Don't allow save if invalid entries are present
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
%div{ng: {if: 'count((entries | entriesFilterValid:"invalid")) > 0'}}
|
||||
%br
|
||||
%h5= t('admin.product_import.import.some_invalid_entries')
|
||||
%p= t('admin.product_import.import.save_valid?')
|
||||
%p= t('admin.product_import.import.fix_before_import')
|
||||
%div{ng: {show: 'count((entries | entriesFilterValid:"invalid")) == 0'}}
|
||||
%br
|
||||
%h5= t('admin.product_import.import.no_errors')
|
||||
@@ -50,7 +50,7 @@
|
||||
= hidden_field_tag :filepath, @filepath
|
||||
= hidden_field_tag "settings[import_into]", @import_into
|
||||
|
||||
%a.button.proceed{href: '', ng: {click: 'acceptResults()'}}= t('admin.product_import.import.proceed')
|
||||
%a.button.proceed{href: '', ng: {show: 'count((entries | entriesFilterValid:"invalid")) == 0', click: 'acceptResults()'}}= t('admin.product_import.import.proceed')
|
||||
|
||||
%a.button{href: main_app.admin_product_import_path}= t('admin.cancel')
|
||||
|
||||
|
||||
@@ -478,7 +478,8 @@ en:
|
||||
save_imported: Save imported products
|
||||
no_valid_entries: No valid entries found
|
||||
none_to_save: There are no entries that can be saved
|
||||
some_invalid_entries: Imported file contains some invalid entries
|
||||
some_invalid_entries: Imported file contains invalid entries
|
||||
fix_before_import: Please fix these errors and try importing the file again
|
||||
save_valid?: Save valid entries for now and discard the others?
|
||||
no_errors: No errors detected!
|
||||
save_all_imported?: Save all imported products?
|
||||
|
||||
@@ -107,12 +107,10 @@ feature "Product Import", js: true do
|
||||
expect(page).to_not have_selector 'input[type=submit][value="Save"]'
|
||||
end
|
||||
|
||||
it "handles validation and saving of named tax and shipping categories" do
|
||||
it "handles saving of named tax and shipping categories" do
|
||||
csv_data = CSV.generate do |csv|
|
||||
csv << ["name", "supplier", "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]
|
||||
csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6.50", "1", "kg", "Unknown Tax Category", shipping_category.name]
|
||||
csv << ["Peas", "User Enterprise", "Vegetables", "7", "2.50", "1", "kg", tax_category2.name, "Unknown Shipping Category"]
|
||||
end
|
||||
File.write('/tmp/test.csv', csv_data)
|
||||
|
||||
@@ -127,8 +125,7 @@ feature "Product Import", js: true do
|
||||
|
||||
import_data
|
||||
|
||||
expect(page).to have_selector '.item-count', text: "3"
|
||||
expect(page).to have_selector '.invalid-count', text: "2"
|
||||
expect(page).to have_selector '.item-count', text: "1"
|
||||
expect(page).to have_selector '.create-count', text: "1"
|
||||
expect(page).to_not have_selector '.update-count'
|
||||
|
||||
@@ -267,8 +264,6 @@ feature "Product Import", js: true do
|
||||
csv_data = CSV.generate do |csv|
|
||||
csv << ["name", "supplier", "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]
|
||||
csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6.50", "1", "kg", "Unknown Tax Category", shipping_category.name]
|
||||
csv << ["Peas", "User Enterprise", "Vegetables", "7", "2.50", "1", "kg", tax_category2.name, "Unknown Shipping Category"]
|
||||
csv << ["Pumpkin", "User Enterprise", "Vegetables", "3", "3.50", "1", "kg", tax_category.name, ""]
|
||||
csv << ["Spinach", "User Enterprise", "Vegetables", "7", "3.60", "1", "kg", "", shipping_category.name]
|
||||
end
|
||||
@@ -307,8 +302,7 @@ feature "Product Import", js: true do
|
||||
|
||||
import_data
|
||||
|
||||
expect(page).to have_selector '.item-count', text: "5"
|
||||
expect(page).to have_selector '.invalid-count', text: "2"
|
||||
expect(page).to have_selector '.item-count', text: "3"
|
||||
expect(page).to have_selector '.create-count', text: "3"
|
||||
expect(page).to_not have_selector '.update-count'
|
||||
|
||||
@@ -403,16 +397,7 @@ feature "Product Import", js: true do
|
||||
expect(page).to have_selector '.create-count', text: "1"
|
||||
|
||||
expect(page.body).to have_content 'you do not have permission'
|
||||
|
||||
expect(page).to have_selector 'a.button.proceed', visible: true
|
||||
click_link 'Proceed'
|
||||
|
||||
save_data
|
||||
|
||||
expect(page).to have_selector '.created-count', text: '1'
|
||||
|
||||
expect(Spree::Product.find_by_name('My Carrots')).to be_a Spree::Product
|
||||
expect(Spree::Product.find_by_name('Your Potatoes')).to be_nil
|
||||
expect(page).to_not have_selector 'a.button.proceed', visible: true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user