Enterprise user can delete product properties

This commit is contained in:
Rohan Mitchell
2014-03-05 16:52:06 +11:00
parent 922d817748
commit 07caf99488
3 changed files with 32 additions and 2 deletions

View File

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

View File

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

View File

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