Supplier with specced time zone and night offset support

This commit is contained in:
2014-01-14 17:33:58 -03:00
parent c6f0976d11
commit 6c00604b83
13 changed files with 5972 additions and 3897 deletions
+11
View File
@@ -8,3 +8,14 @@ step "There is an open supplier with a menu" do
@apple_pie.add_product_category @category_lunch
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
@@ -53,3 +53,34 @@ end
step "there are :count supplier product categories" do |count|
@product_categories = create_list :product_category, count.to_i, supplier: @supplier
end
step "there is a product category with product available on :day between :category_start_time and :category_end_time" do |day, category_start_time, category_end_time|
step 'there is a product'
start_minute = (Time.parse(category_start_time).seconds_since_midnight / 60).round
end_minute = (Time.parse(category_end_time).seconds_since_midnight / 60).round
end_minute += 1440 if end_minute < start_minute #night offset option
@product_category = create :product_category,
supplier: @supplier,
week_days: [0,0,0,0,0,1,0],
product_ids: [@product.id],
start_from: start_minute,
end_on: end_minute
end
step "the product category should not be visible on :week_day :time" do |week_day, time|
timestamp = Time.parse(time)
needed_wday = Date::DAYNAMES.index{|d| d == week_day}
raise "cannot find day of week for #{week_day}" unless needed_wday.is_a?(Integer)
timestamp = timestamp + (needed_wday - timestamp.wday).days unless timestamp.wday == needed_wday
product_categories = ProductCategory.for_supplier_in_time(@supplier, timestamp)
product_categories.should be_empty
end
step "the product category should be visible on :week_day :time" do |week_day, time|
timestamp = Time.parse(time)
needed_wday = Date::DAYNAMES.index{|d| d == week_day}
raise "cannot find day of week for #{week_day}" unless needed_wday.is_a?(Integer)
timestamp = timestamp + (needed_wday - timestamp.wday).days unless timestamp.wday == needed_wday
product_categories = ProductCategory.for_supplier_in_time(@supplier, timestamp)
product_categories.should include @product_category
end
@@ -7,6 +7,10 @@ step "there are :count supplier products" do |count|
@products = create_list :product, count.to_i, supplier: @supplier
end
step 'there is a product' do
@product = create :product, supplier: @supplier
end
step "the supplier fills in the new product form selecting the first product category" do
find('#product_name').set 'New product'
find('#product_code').set 'NL0487'
@@ -39,3 +39,12 @@ step "the supplier email is the new email and the unconfirmed email is empty" do
@supplier.email.should == 'new-supplier-mail@qwaiter.com'
@supplier.unconfirmed_email.should be_blank
end
step "the supplier selects :time_zone as Time Zone" do |visual_time_zone|
page.select visual_time_zone, from: 'supplier_time_zone'
end
step "the supplier timezone should be :time_zone" do |time_zone|
@supplier.reload
@supplier.time_zone.should == time_zone
end