Enterprise user can manage their enterprises' producer properties

This commit is contained in:
Rohan Mitchell
2014-06-18 16:04:41 +10:00
parent cf4e7b18b4
commit 4eee7d4901
3 changed files with 28 additions and 2 deletions

View File

@@ -72,6 +72,8 @@ class AbilityDecorator
can [:admin, :index, :read, :create, :edit, :update], Exchange
can [:admin, :index, :read, :create, :edit, :update], ExchangeFee
can [:admin, :index, :read, :create, :edit, :update_positions, :destroy], ProducerProperty
can [:admin, :index, :create], Enterprise
can [:read, :edit, :update, :bulk_update], Enterprise do |enterprise|
user.enterprises.include? enterprise

View File

@@ -273,7 +273,7 @@ feature %q{
Enterprise.managed_by(@new_user).should include enterprise
end
scenario "can edit enterprises I have permission to" do
scenario "editing enterprises I have permission to" do
click_link 'Enterprises'
within('#listing_enterprises tbody tr:first') { click_link 'Edit Profile' }
@@ -284,11 +284,31 @@ feature %q{
page.should have_field 'enterprise_name', :with => 'Eaterprises'
end
scenario "Editing images for an enterprise" do
scenario "editing images for an enterprise" do
click_link 'Enterprises'
first(".edit").click
page.should have_content "Logo"
page.should have_content "Promo"
end
scenario "managing producer properties", js: true do
click_link 'Enterprises'
within(".enterprise-#{supplier1.id}") { click_link 'Properties' }
# -- Create / update
fill_in 'enterprise_producer_properties_attributes_0_property_name', with: "Certified Organic"
fill_in 'enterprise_producer_properties_attributes_0_value', with: "NASAA 12345"
click_button 'Update'
page.should have_selector '#listing_enterprises a', text: supplier1.name
supplier1.producer_properties(true).count.should == 1
# -- Destroy
pp = supplier1.producer_properties.first
within(".enterprise-#{supplier1.id}") { click_link 'Properties' }
within("#spree_producer_property_#{pp.id}") { page.find('a.remove_fields').click }
page.should_not have_selector '#progress'
supplier1.producer_properties(true).should be_empty
end
end
end

View File

@@ -75,6 +75,10 @@ module Spree
should have_ability([:admin, :index, :read, :create, :edit], for: Spree::Classification)
end
it "should be able to read/write their enterprises' producer properties" do
should have_ability([:admin, :index, :read, :create, :edit, :update_positions, :destroy], for: ProducerProperty)
end
it "should be able to read and create enterprise relationships" do
should have_ability([:admin, :index, :create], for: EnterpriseRelationship)
end