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
+3
View File
@@ -49,6 +49,9 @@ gem 'kaminari'
gem 'rqrcode'
gem 'mini_magick'
#gem 'geokit'
#gem 'iso_country_codes'
#gem "less-rails-bootstrap-devise", :git => 'git://github.com/bigbento/less-rails-bootstrap-devise.git'
# To use ActiveModel has_secure_password
-1
View File
@@ -64,7 +64,6 @@ class ProductCategory
h = {table_number: table.number, table_occupied: table.occupied?, supplier_name: supplier.name, my_list: list.try(:user_ids).to_a.include?(user.id)}
#(products - product_categories.map(&:products).flatten).each{ |p| other.add_product(p) }
h[:categories] = product_categories.map(&:to_client_format).select(&:present?)
h
end
+2 -1
View File
@@ -26,7 +26,8 @@
= f.label :time_zone, class: 'control-label'
.controls
/= f.input :time_zone, collection: ActiveSupport::TimeZone.all, label_method: :to_s, value_method: :name, include_blank: false
= f.collection_select :time_zone, ActiveSupport::TimeZone.all, :name, :to_s
/= f.collection_select :time_zone, ActiveSupport::TimeZone.all, :name, :to_s
= f.time_zone_select :time_zone
/.accordion-group
.accordion-heading
a.accordion-toggle data-toggle="collapse" data-parent="#settings-sections" href="#settings-wifi" data-t="attributes.supplier.offer_wifi"
@@ -0,0 +1,11 @@
Feature: Serving a product category from a different time zone
@javascript
Scenario: Serving a product category from Buenos Aires
Given there is a confirmed and open supplier
And the supplier is in "Buenos Aires"
And the supplier has a night offset of 120 minutes
And there is a product category with product available on Fridays between 11PM and 1AM
Then the product category should not be visible on Thursday "11:30PM"
Then the product category should be visible on Friday "11:30PM"
Then the product category should be visible on Saturday "00:30AM"
@@ -1,4 +1,5 @@
Feature: Manage settings
Scenario: Changing the supplier email
Given there is a confirmed and open supplier
And I am signed in as supplier
@@ -11,3 +12,11 @@ Feature: Manage settings
When the supplier clicks on the new email confirmation link
Then the supplier gets redirected to the supplier settings path
And the supplier email is the new email and the unconfirmed email is empty
Scenario: Setting the timezone
Given there is a confirmed and open supplier
And I am signed in as supplier
When I visit the supplier settings path
And the supplier selects "(GMT-03:00) Buenos Aires" as Time Zone
And the supplier submits the supplier settings form
Then the supplier timezone should be "Buenos Aires"
+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
File diff suppressed because it is too large Load Diff
+3736 -3227
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long