Working user order flow spec

This commit is contained in:
2013-12-02 07:38:02 +01:00
parent 7b9b784ef9
commit afb30556bd
15 changed files with 161 additions and 7 deletions
@@ -0,0 +1,3 @@
step 'there is a section' do
@section ||= create :section, supplier: @supplier
end
@@ -0,0 +1,9 @@
step "the user scans a table QR code" do
step 'there is a table'
page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})"
end
step 'there is a table' do
step 'there is a section'
@table ||= create :table, section: @section, supplier: @supplier
end
@@ -0,0 +1,12 @@
step "I am on the user homepage" do
visit user_root_path
end
step "the user should be redirected to the user order overview page" do
route_should_be 'user#active_list'
end
step "the user should be redirected to the archived list path" do
route_should_be 'user#history_list'
page.should have_selector ".order-row-#{@order.id}"
end
+4
View File
@@ -18,3 +18,7 @@ step 'a new order on a table in another section is created' do
@new_list = create :list, section: @new_section, table: @new_table, supplier: @supplier, user_ids: [@user.id]
@new_order = @new_list.place_order @user, {@product.id => 3}
end
step "I am signed in as a user" do
step "I visit the user obtain token path"
end
+30
View File
@@ -11,3 +11,33 @@ end
step "another order is placed" do
@new_order = @list.place_order @user, {@product.id => 5}
end
step "the user order should be created as a new order" do
@order = Order.last
row = find(".order-row-#{@order.id}")
row['class'].should include 'placed'
page.should have_content 'Apple pie (1), Heineken beer (2)'
page.should have_content '€ 8.96'
end
step "the user order gets marked as being in process" do
@order.is_being_processed!
end
step "the user order should get feedback of being in process" do
row = find(".order-row-#{@order.id}")
row['class'].should include 'active'
end
step "the user order gets marked as being delivered" do
@order.is_delivered!
end
step "the user order should get feedback of being delivered" do
row = find(".order-row-#{@order.id}")
row['class'].should include 'delivered'
end
step "the user orders list gets closed" do
@order.list.close!
end
+10
View File
@@ -0,0 +1,10 @@
step "There is an open supplier with a menu" do
step 'there is a confirmed and open supplier'
@category_beer = create :product_category, name: 'Beer', supplier: @supplier
@category_lunch = create :product_category, name: 'Lunch', supplier: @supplier
@heineken_beer = create :product, name: 'Heineken beer', supplier: @supplier, price: 2.34
@apple_pie= create :product, name: 'Apple pie', supplier: @supplier, price: 4.28
@heineken_beer.add_product_category @category_beer
@apple_pie.add_product_category @category_lunch
end
@@ -0,0 +1,17 @@
step "the user clicks on the order :product_name twice" do |product_name|
@last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@')
button = find ".order-product-#{@last_product.id}"
2.times { button.click }
end
step "the user clicks on the order product button :product_name" do |product_name|
@last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@')
button = find ".order-product-#{@last_product.id}"
button.click
end
step "the user clicks on the user order button" do
find('#active-order-table .btn-primary').click
sleep 1
end