diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index c6407c1f98..668791f555 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -15,7 +15,7 @@ class AbilityDecorator end can [:admin, :index, :read, :create, :edit, :update, :search, :destroy], Spree::Variant - can [:admin, :index, :read, :create, :edit], Spree::ProductProperty + can [:admin, :index, :read, :create, :edit, :destroy], Spree::ProductProperty can [:admin, :index, :read, :create, :edit], Spree::Image can [:admin, :index, :read, :search], Spree::Taxon diff --git a/spec/features/admin/variants_spec.rb b/spec/features/admin/variants_spec.rb index d05aa75ef8..7202867bd3 100644 --- a/spec/features/admin/variants_spec.rb +++ b/spec/features/admin/variants_spec.rb @@ -83,4 +83,34 @@ feature %q{ page.should_not have_field "variant_unit_value" page.should_not have_field "variant_unit_description" end + + + context "as an enterprise user" do + before(:each) do + @new_user = create_enterprise_user + @supplier = create(:supplier_enterprise) + @new_user.enterprise_roles.build(enterprise: @supplier).save + + login_to_admin_as @new_user + end + + scenario "deleting product properties", js: true do + # Given a product with a property + p = create(:simple_product, supplier: @supplier) + p.set_property('fooprop', 'fooval') + + # When I navigate to the product properties page + visit spree.admin_product_product_properties_path(p) + page.should have_field 'product_product_properties_attributes_0_property_name', with: 'fooprop', visible: true + page.should have_field 'product_product_properties_attributes_0_value', with: 'fooval', visible: true + + # And I delete the property + page.all('a.remove_fields').first.click + + # Then the property should have been deleted + page.should_not have_field 'product_product_properties_attributes_0_property_name', with: 'fooprop', visible: true + page.should_not have_field 'product_product_properties_attributes_0_value', with: 'fooval', visible: true + p.reload.property('fooprop').should be_nil + end + end end diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 35020aede5..193a6c0fd5 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -48,7 +48,7 @@ module Spree end it "should be able to read/write their enterprises' product properties" do - should have_ability([:admin, :index, :read, :create, :edit], for: Spree::ProductProperty) + should have_ability([:admin, :index, :read, :create, :edit, :destroy], for: Spree::ProductProperty) end it "should be able to read/write their enterprises' product images" do