updating part2, far from finished

This commit is contained in:
2013-12-20 19:22:12 +01:00
parent 748944865d
commit b4c4a15e60
22 changed files with 2779 additions and 62 deletions
@@ -49,3 +49,7 @@ step "the the product category is active on wednesday and only linked to the las
@product_category.week_days.should == [0, 0, 0, 1, 0, 0, 0]
@product_category.product_ids.should == [@products.last.id]
end
step "there are :count supplier product categories" do |count|
@product_categories = create_list :product_category, count.to_i, supplier: @supplier
end
@@ -1,4 +1,50 @@
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 "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('.save-product-button').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('.edit-resource-button').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
@@ -0,0 +1,3 @@
step "there are 2 supplier sections" do
@sections = create_list :section, 2, supplier: @supplier
end
@@ -0,0 +1,40 @@
step "the supplier visits the new table page" do
visit new_suppliers_table_path
end
step "the supplier fills in the new table form selecting the first section" do
find('#table_number').set '7'
section_option = find(%|option[value="#{@sections.first.id}"]|)
select section_option.text, from: 'table_section_id'
end
step "the supplier submits the table form" do
find('.save-table-button').click
end
step "the new supplier table with proper properties should have been created" do
@table = Table.find_by_number 7
@table.section_id.should == @sections.first.id
end
step "the supplier should be on the table section page" do
@table.reload
route_should_be 'suppliers/sections#show', id: @table.section_id
end
step "the supplier visits the edit table page" do
visit edit_suppliers_table_path(@table)
end
step "the supplier changes the table number to :number and section to the last section" do |number|
find('#table_number').set number
section_option = find(%|option[value="#{@sections.last.id}"]|)
select section_option.text, from: 'table_section_id'
end
step "the supplier table should have number :number and be linked to the last section" do |number|
@table.reload
@table.number.should == number.to_i
@table.section_id.should == @sections.last.id
end