Start supplier product category speccing
This commit is contained in:
@@ -47,7 +47,7 @@ module Suppliers
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @product_category.save
|
if @product_category.save
|
||||||
format.html { redirect_to [:suppliers, @product_category], notice: t('action.create.successfull', model: ProductCategory.model_name.human) }
|
format.html { redirect_to [:suppliers, :product_categories], notice: t('action.create.successfull', model: ProductCategory.model_name.human) }
|
||||||
format.json { render json: @product_category, status: :created, location: @product_category }
|
format.json { render json: @product_category, status: :created, location: @product_category }
|
||||||
else
|
else
|
||||||
format.html { render action: "new" }
|
format.html { render action: "new" }
|
||||||
@@ -63,7 +63,7 @@ module Suppliers
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @product_category.update_attributes(params[:product_category])
|
if @product_category.update_attributes(params[:product_category])
|
||||||
format.html { redirect_to [:suppliers, @product_category], notice: t('action.update.successfull', model: ProductCategory.model_name.human) }
|
format.html { redirect_to [:suppliers, :product_categories], notice: t('action.update.successfull', model: ProductCategory.model_name.human) }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
format.html { render action: "edit" }
|
format.html { render action: "edit" }
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
span.name= link_to product_category.name, [:suppliers, product_category]
|
span.name= link_to product_category.name, [:suppliers, product_category]
|
||||||
span= product_category.visible_on
|
span= product_category.visible_on
|
||||||
.pull-right.actions
|
.pull-right.actions
|
||||||
= link_to t('helpers.links.edit'), [:edit, :suppliers, product_category], class: 'btn btn-mini'
|
= link_to t('helpers.links.edit'), [:edit, :suppliers, product_category], class: 'btn btn-mini edit-resource-button'
|
||||||
'
|
'
|
||||||
= link_to t("helpers.links.destroy"), [:suppliers, product_category], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
= link_to t("helpers.links.destroy"), [:suppliers, product_category], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger'
|
||||||
- else
|
- else
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
Feature: Adding product category
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Adding a product category
|
||||||
|
Given there is a confirmed and open supplier
|
||||||
|
And I am signed in as supplier
|
||||||
|
And there are 2 supplier products
|
||||||
|
And the supplier visits the new product category page
|
||||||
|
And the supplier fills in the new product category form selecting the first product and available on tuesdays
|
||||||
|
When the supplier submits the product category form
|
||||||
|
Then then new product category with proper properties linked to the first product should have been created
|
||||||
|
And the supplier should be on the product categoy overview path
|
||||||
|
When the supplier clicks on the edit product category button
|
||||||
|
And the supplier unchecks the first product and checks the product
|
||||||
|
And the supplier clicks on the tuesday and wednesday buttons selecting wednesday as active day
|
||||||
|
And the supplier submits the product category form
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
step "the supplier visits the new product category page" do
|
||||||
|
visit new_suppliers_product_category_path
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the supplier fills in the new product category form selecting the first product and available on tuesdays" do
|
||||||
|
find('#product_category_name').set 'New product category'
|
||||||
|
find("#product-checker-#{@products.first.id}").set true
|
||||||
|
page.all('.week-day-toggle').each do |day_toggle|
|
||||||
|
next if day_toggle['data-day'] == 'tuesday'
|
||||||
|
day_toggle.click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
step "the supplier submits the product category form" do
|
||||||
|
submit_form
|
||||||
|
end
|
||||||
|
|
||||||
|
step "then new product category with proper properties linked to the first product should have been created" do
|
||||||
|
sleep 1
|
||||||
|
@product_category = ProductCategory.find_by_name 'New product category'
|
||||||
|
@product_category.week_days.should == [0, 0, 1, 0, 0, 0, 0]
|
||||||
|
@product_category.full_day.should be_true
|
||||||
|
@product_category.product_ids.should == [@products.first.id]
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the supplier should be on the product categoy overview path" do
|
||||||
|
route_should_be "suppliers/product_categories#index"
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the supplier clicks on the edit product category button" do
|
||||||
|
within "#product_category_#{@product_category.id}" do
|
||||||
|
find('.edit-resource-button').click
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
step "there are :count supplier products" do |count|
|
||||||
|
@products = create_list :product, count.to_i, supplier: @supplier
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user