Fix error when setting stock for new product

This commit is contained in:
Tsara Sudrajat
2020-10-26 11:13:54 +07:00
committed by Andy Brett
parent 65f6f1febf
commit fb769d37f9
2 changed files with 25 additions and 0 deletions

View File

@@ -112,6 +112,27 @@ feature '
variant = product.variants.first
expect(variant.on_demand).to be true
end
scenario "creating product with empty unit value", js: true do
login_as_admin_and_visit spree.admin_products_path
click_link 'New Product'
fill_in 'product_name', with: 'Hot Cakes'
select 'New supplier', from: 'product_supplier_id'
select "Weight (kg)", from: 'product_variant_unit_with_scale'
select taxon.name, from: "product_primary_taxon_id"
fill_in 'product_price', with: '1.99'
fill_in 'product_on_hand', with: 0
check 'product_on_demand'
select 'Test Tax Category', from: 'product_tax_category_id'
page.find("div[id^='taTextElement']").native.send_keys('In demand, and on_demand! The hottest cakes in town.')
click_button 'Create'
expect(current_path).to eq spree.admin_products_path
expect(page).to have_content "Unit value can't be blank"
end
end
context "as an enterprise user" do

View File

@@ -247,6 +247,10 @@ module Spree
expect(build(:simple_product, taxons: [], primary_taxon: nil)).not_to be_valid
end
it "requires a unit value" do
expect(build(:simple_product, unit_value: nil)).not_to be_valid
end
it "requires a supplier" do
expect(build(:simple_product, supplier: nil)).not_to be_valid
end