Time dependant product categories for users

This commit is contained in:
2015-01-22 17:49:32 +01:00
parent f434b53161
commit 36525849bd
24 changed files with 9981 additions and 46 deletions
@@ -53,4 +53,5 @@ Feature: Ordering a product as a user
And the user clicks on the lists link in the side menu
And the user opens the side menu again
And the user clicks on the order products link in the side menu
Then the user should see the products listed for the active list
Then the user page contains the product category beer
And the user should see the products listed for the active list
@@ -0,0 +1,50 @@
Feature:
The product categories are only visible on their specific times
@javascript
Scenario: Product category visibility by day
Given there is an open supplier with a menu
And there is a table
And I am signed in as a user
When the user is on the order products page
Then the user page contains the product category lunch
When the product category lunch is not visible today
And I reload the page
Then the user page contains the product category beer
And the user page does not contain the product category lunch
@javascript
Scenario: Product category visibility by minute when inside the range
Given there is an open supplier with a menu
And there is a table
And I am signed in as a user
When the user is on the order products page
Then the user page contains the product category lunch
When the product category lunch is visible at this time
And I reload the page
Then the user page contains the product category beer
And the user page contains the product category lunch
@javascript
Scenario: Product category visibility by minute when category is visible after now
Given there is an open supplier with a menu
And there is a table
And I am signed in as a user
When the user is on the order products page
Then the user page contains the product category lunch
When the product category lunch is visible later than now
And I reload the page
Then the user page contains the product category beer
And the user page does not contain the product category lunch
@javascript
Scenario: Product category visibility by minute when category is visible before now
Given there is an open supplier with a menu
And there is a table
And I am signed in as a user
When the user is on the order products page
Then the user page contains the product category lunch
When the product category lunch is visible earlyer than now
And I reload the page
Then the user page contains the product category beer
And the user page does not contain the product category lunch
@@ -0,0 +1,21 @@
step "the product category lunch is not visible today" do
@category_lunch.update_attributes "active_on_#{Date.today.day_name}" => false
end
step "the product category lunch is visible at this time" do
@category_lunch.update_attributes full_day: false,
start_from: 10.minutes.ago.getlocal.minute_of_day,
end_on: 10.minutes.from_now.getlocal.minute_of_day
end
step "the product category lunch is visible later than now" do
@category_lunch.update_attributes full_day: false,
start_from: 10.minutes.from_now.getlocal.minute_of_day,
end_on: 1440
end
step "the product category lunch is visible earlyer than now" do
@category_lunch.update_attributes full_day: false,
start_from: 0,
end_on: 10.minutes.ago.getlocal.minute_of_day
end
+4
View File
@@ -31,3 +31,7 @@ end
step "I open the debugger" do
binding.pry
end
step 'I reload the page' do
page.driver.browser.navigate.refresh()
end
+1 -1
View File
@@ -14,7 +14,7 @@ step "I am on the user homepage" do
end
step "the user is on the homepage" do
visit user_root_path
visit '/user'
end
step "the user should be redirected to the user order overview page" do
@@ -130,3 +130,12 @@ step "the user has an active list with a/an :order_status order" do |order_statu
end
end
step "the user page contains the product category lunch" do
js_text("#product-category-#{@category_lunch.id} .product_category-title").should include @category_lunch.name
end
step "the user page contains the product category beer" do
js_text("#product-category-#{@category_beer.id} .product_category-title").should include @category_beer.name
end
step "the user page does not contain the product category lunch" do
page.should_not have_selector "#product-category-#{@category_lunch.id} .product_category-title"
end
@@ -0,0 +1,25 @@
require 'spec_helper'
describe Date do
describe '#day_name' do
it 'returns the proper day name' do
travel_to Date.parse('2015-01-22') do
Date.today.day_name.should eq 'thursday'
end
end
end
end
describe Time do
describe '#minute_of_day' do
it 'returns the proper minute' do
Time.parse('2015-01-22T16:48:12Z').minute_of_day.should eq 1008
end
it 'works for relative time' do
travel_to Time.parse('2015-01-22T16:48:12Z') do
12.minutes.from_now.minute_of_day.should eq 1020
end
end
end
end
+3
View File
@@ -10,6 +10,7 @@ require 'turnip/capybara'
require 'in_memory_q_counter'
require 'capybara-screenshot/rspec'
require 'webmock/rspec'
#require 'capybara/poltergeist'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
@@ -20,6 +21,7 @@ Dir.glob("spec/acceptance_steps/**/*steps.rb") { |f| load f, true }
I18n.locale =I18n.default_locale
Devise.stretches = 1
#Capybara.javascript_driver = :webkit
#Capybara.javascript_driver = :poltergeist
Capybara.javascript_driver = :selenium
Capybara.default_wait_time = 4 # ember needs more time than the default of 2
Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
@@ -86,6 +88,7 @@ RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller
config.include EndWithMatcher
config.include Matchers
config.include ActiveSupport::Testing::TimeHelpers
config.include Features::BasicHelpers, type: :feature
config.include SpecRouteHelpers, type: :feature
config.include SpecEmberHelpers, type: :feature
+5
View File
@@ -37,6 +37,11 @@ module SpecEmberHelpers
page.execute_script "$('#{selector}').click()"
end
def js_text(selector)
find selector
page.evaluate_script("$('#{selector}').text()")
end
def ember_find(typeKey, id)
h = page.evaluate_script <<-SCRIPT
App.__container__.lookup('store:main').all('#{typeKey}').findBy('id', '#{id}').serialize()