mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Do not error when creating variant for product without non-unit option type
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
Spree::Admin::VariantsController.class_eval do
|
||||
helper 'spree/products'
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def create_before
|
||||
option_values = params[:new_variant]
|
||||
option_values.andand.each_value {|id| @object.option_values << OptionValue.find(id)}
|
||||
@object.save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,6 +7,27 @@ feature %q{
|
||||
include AuthenticationWorkflow
|
||||
include WebHelper
|
||||
|
||||
scenario "creating a new variant" do
|
||||
# Given a product with a unit-related option type
|
||||
p = create(:simple_product, variant_unit: "weight", variant_unit_scale: "1")
|
||||
|
||||
# When I create a variant on the product
|
||||
login_to_admin_section
|
||||
click_link 'Products'
|
||||
within('#sub_nav') { click_link 'Products' }
|
||||
click_link p.name
|
||||
click_link 'Variants'
|
||||
click_link 'New Variant'
|
||||
|
||||
fill_in 'variant_unit_value', with: '1'
|
||||
fill_in 'variant_unit_description', with: 'foo'
|
||||
click_button 'Create'
|
||||
|
||||
# Then the variant should have been created
|
||||
page.should have_content "Variant \"#{p.name}\" has been successfully created!"
|
||||
end
|
||||
|
||||
|
||||
scenario "editing unit value and description for a variant" do
|
||||
# Given a product with unit-related option types, with a variant
|
||||
p = create(:simple_product, variant_unit: "weight", variant_unit_scale: "1")
|
||||
|
||||
Reference in New Issue
Block a user