step "there is an active list and order" do @user ||= create :user step 'there is a confirmed and open supplier' @table = create :table, supplier: @supplier, section: @section @section.should be_present @list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id] @product = create :product, price: 2.22, supplier: @supplier @order = create :order, user: @user, list: @list, supplier: @supplier, section: @section @product_order = create :product_order, order: @order, product: @product, quantity: 3, price: 2.11 end step "the supplier dashboard should display the active list" do el = find(".list-row-#{@list.id}") el['class'].should_not =~ /active/ end step "the list in the supplier dashboard should not be displayed anymore" do page.should_not have_selector(".list-row-#{@list.id}") end step "the supplier dashboard should display the active order" do el = find(".order-row-#{@order.id}") el['class'].should_not =~ /active/ end step "the supplier order row should be marked as active" do el = find(".order-row-#{@order.id}") el['class'].should =~ /active/ end step "the order in the supplier dashboard should not be displayed anymore" do page.should_not have_selector(".order-row-#{@order.id}") end step "the list on the supplier dashboard should not be marked as in need of help" do page.should_not have_selector(".list-row-#{@list.id} .list-needs-help-indicator") end step "the list on the supplier dashboard should be marked as in need of help" do page.should have_selector(".list-row-#{@list.id} .list-needs-help-indicator") end step "the list on the supplier dashboard should not be marked as in need of payment" do page.should_not have_selector(".list-row-#{@list.id} .list-needs-payment-indicator") end step "the list on the supplier dashboard should be marked as in need of payment" do page.should have_selector(".list-row-#{@list.id} .list-needs-payment-indicator") end step "the supplier dashboard list should display the updated price" do el = find(".list-row-#{@list.id} .total_list_amount") # original order is 3 * 2.11 = 6.33 # new order price = 5 * 2.22 = 11.10 # therefore the updated price should be 17.43 el.text.should =~ /17.43/ end step "the new order should be present in the supplier dashboard" do el = find(".order-row-#{@new_order.id}") el.find('.table_number').text.should == @table.number.to_s el.find('.section_title').text.should == @section.title end step "the new order on a table in another section should be present in the supplier dashboard" do el = find(".order-row-#{@new_order.id}") el.find('.table_number').text.should == @new_table.number.to_s el.find('.section_title').text.should == @new_section.title end step "the new list should appear in the supplier dashboard" do el = find(".list-row-#{@new_list.id}") el.find('.total_list_amount').text.should =~ /6.66/ el.find('.section_title').text.should == 'Terrace' el.find('.table_number').text.should == @new_table.number.to_s end step "I click on the close list button in the supplier dashboard" do find(".list-row-#{@list.id} .close_list").click end step "I click on the mark list as helped button in the supplier dashboard" do find(".list-row-#{@list.id} .mark_list_as_helped").click end