55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
|
|
step "the supplier visits the new product page" do
|
|
visit new_suppliers_product_path
|
|
end
|
|
|
|
step "there are :count supplier products" do |count|
|
|
@products = create_list :product, count.to_i, supplier: @supplier
|
|
end
|
|
|
|
step 'there is a product' do
|
|
@product = create :product, supplier: @supplier
|
|
end
|
|
|
|
step "the supplier fills in the new product form selecting the first product category" do
|
|
find('#product_name').set 'New product'
|
|
find('#product_code').set 'NL0487'
|
|
find('#product_price').set '6.42'
|
|
find("#product-category-checker-#{@product_categories.first.id}").set true
|
|
end
|
|
|
|
step "the supplier submits the product form" do
|
|
find('.form-action-submit').click
|
|
end
|
|
|
|
|
|
step "the new product with proper properties linked to the first product category should have been created" do
|
|
sleep 1
|
|
@product = Product.find_by_name 'New product'
|
|
@product.code.should == 'NL0487'
|
|
@product.price.should == 6.42
|
|
@product_categories.each(&:reload)
|
|
@product.product_categories.should == [@product_categories.first]
|
|
end
|
|
|
|
step "the supplier should be on the product overview path" do
|
|
route_should_be 'suppliers/products#index'
|
|
end
|
|
|
|
step "the supplier clicks on the edit product button" do
|
|
within ".product-row-#{@product.id}" do
|
|
find('.table-edit').click
|
|
end
|
|
end
|
|
|
|
step "the supplier unchecks the first product category and checks the last product category" do
|
|
find("#product-category-checker-#{@product_categories.first.id}").set false
|
|
find("#product-category-checker-#{@product_categories.last.id}").set true
|
|
end
|
|
|
|
step "the supplier product should only be linked to the last product category" do
|
|
@product.reload
|
|
@product_categories.each(&:reload)
|
|
@product.product_categories.should == [@product_categories.last]
|
|
end
|