Add product tests for an enterprise user.

This commit is contained in:
Andrew Spinks
2013-08-02 14:01:45 +10:00
parent 0bb4f676e1
commit 269294612d

View File

@@ -59,5 +59,62 @@ feature %q{
product.group_buy_unit_size.should == 10.0
end
describe 'As an enterprise user' do
before(:each) do
@new_user = create_enterprise_user
@supplier1 = create(:supplier_enterprise, name: 'Another Supplier')
@new_user.enterprise_roles.build(enterprise: @supplier1).save
@new_user.enterprise_roles.build(enterprise: @distributors[0]).save
login_to_admin_as @new_user
end
scenario "create new product" do
click_link 'Products'
click_link 'New Product'
fill_in 'product_name', :with => 'A new product !!!'
fill_in 'product_price', :with => '19.99'
# check suppliers are only ones we have access to ???????????????????????
page.should have_selector('#product_supplier_id')
select 'Another Supplier', :from => 'product_supplier_id'
# check that distributors are only the ones we have access to ?????????????????
check @distributors[0].name
select 'My shipping method', :from => 'product_product_distributions_attributes_0_shipping_method_id'
click_button 'Create'
flash_message.should == 'Product "A new product !!!" has been successfully created!'
product = Spree::Product.find_by_name('A new product !!!')
product.supplier.should == @supplier1
product.distributors.should == [@distributors[0]]
end
describe 'with existing product' do
before(:each) do
@product = create(:product, supplier: @supplier1)
end
scenario "can edit" do
click_link 'Products'
click_link @product.name
page.should_not have_selector('#product_supplier_id')
click_link "Images"
page.should_not have_content 'Authorization Failure'
click_link "Variants"
page.should_not have_content 'Authorization Failure'
click_link "Product Properties"
page.should_not have_content 'Authorization Failure'
end
end
end
end
end