require 'acceptance/acceptance_helper' feature 'Supplier main board spec.rb', %q{ In order to manage active lists and orders As a confirmed supplier I want to have control over lists and orders from the main activity panel } do background do CouchPotato.couchrest_database.recreate! create_confirmed_supplier 'supplier@qwaiter.com' create_user 'user@qwaiter.com' end def create_active_list(options = {}) @table = create :table, supplier: @supplier @list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id] end context "having javascript activated", js: true do scenario 'the active list should be present and contained in row having its id' do create_active_list login_supplier_as 'supplier@qwaiter.com' visit '/supplier' page.should have_selector "#list-row-#{@list.id}" end scenario 'an order is added to the list before visiting the page' do create_active_list login_supplier_as 'supplier@qwaiter.com' product = create :product, supplier: @supplier sleep 0.1 @list.place_order @user, {product.id => 369} visit '/supplier' page.should have_selector ".of-list-#{@list.id}" end scenario 'an order is added to the list after visiting the page' do create_active_list login_supplier_as 'supplier@qwaiter.com' product = create :product, supplier: @supplier visit '/supplier' @list.place_order @user, {product.id => 369} page.should have_selector ".of-list-#{@list.id}" end end end