step "there is an open supplier with a menu" do
  step 'there is a confirmed and open supplier'

  @category_lunch = create :product_category, name: 'Lunch', supplier: @supplier
  @category_beer = create :product_category, name: 'Beer', supplier: @supplier

  @apple_pie= create :product, name: 'Apple pie', supplier: @supplier, price: 4.28, product_category_id: @category_lunch.id
  @heineken_beer = create :product, name: 'Heineken beer', supplier: @supplier, price: 2.34, product_category_id: @category_beer.id
  @australian_beer = create :product, name: 'Australian beer', supplier: @supplier, price: 3.34, product_category_id: @category_beer.id
  create :product_variant, product: @australian_beer, name: 'With foam'
  create :product_variant, product: @australian_beer, name: 'Without foam'
  @product = @heineken_beer # set @product for user order selection
end

step "the supplier is in :time_zone" do |time_zone|
  time_zone = ActiveSupport::TimeZone.zones_map[time_zone]
  raise "time zone #{time_zone} cannot be found" unless time_zone
  @supplier.time_zone = time_zone.name
  @supplier.save
end

step "the supplier has a night offset of :minutes minutes" do |minutes|
  @supplier.night_offset = minutes
  @supplier.save
end

step "the supplier name in the page should be :name" do |name|
  page.find('.top-menu .supplier-name').text.should == name
end
