Working user order flow spec
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
source :rubygems
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
gem 'rails', '3.2.13'
|
gem 'rails', '3.2.13'
|
||||||
gem 'rack-cors', :require => 'rack/cors'
|
gem 'rack-cors', :require => 'rack/cors'
|
||||||
|
|||||||
+2
-2
@@ -47,7 +47,7 @@ PATH
|
|||||||
tinymce-rails
|
tinymce-rails
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actionmailer (3.2.13)
|
actionmailer (3.2.13)
|
||||||
actionpack (= 3.2.13)
|
actionpack (= 3.2.13)
|
||||||
@@ -213,7 +213,7 @@ GEM
|
|||||||
railties (>= 3.1.0)
|
railties (>= 3.1.0)
|
||||||
js-routes (0.9.0)
|
js-routes (0.9.0)
|
||||||
rails (>= 3.2)
|
rails (>= 3.2)
|
||||||
json (1.8.0)
|
json (1.8.1)
|
||||||
jwt (0.1.8)
|
jwt (0.1.8)
|
||||||
multi_json (>= 1.5)
|
multi_json (>= 1.5)
|
||||||
kaminari (0.14.1)
|
kaminari (0.14.1)
|
||||||
|
|||||||
@@ -8,6 +8,6 @@
|
|||||||
<span class="btn btn-info btn-mini" onclick="Quser.increment_products_counter('{{_id}}')">+</span>
|
<span class="btn btn-info btn-mini" onclick="Quser.increment_products_counter('{{_id}}')">+</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{#currency}}{{price}}{{/currency}}</td>
|
<td>{{#currency}}{{price}}{{/currency}}</td>
|
||||||
<td><button class="btn order-product-button" onclick="Quser.add_product_to_order('{{_id}}', this)">Add</button></td>
|
<td><button class="btn order-product-button order-product-{{_id}}" onclick="Quser.add_product_to_order('{{_id}}', this)">Add</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/products}}
|
{{/products}}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
Feature: Ordering a product as a user
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Happy flow
|
||||||
|
Given There is an open supplier with a menu
|
||||||
|
And I am signed in as a user
|
||||||
|
And I am on the user homepage
|
||||||
|
When the user scans a table QR code
|
||||||
|
And the user clicks on the order 'Heineken beer' twice
|
||||||
|
And the user clicks on the order product button 'Apple Pie'
|
||||||
|
And the user clicks on the user order button
|
||||||
|
Then the user should be redirected to the user order overview page
|
||||||
|
And the user order should be created as a new order
|
||||||
|
When the user order gets marked as being in process
|
||||||
|
Then the user order should get feedback of being in process
|
||||||
|
When the user order gets marked as being delivered
|
||||||
|
Then the user order should get feedback of being delivered
|
||||||
|
When the user orders list gets closed
|
||||||
|
Then the user should be redirected to the archived list path
|
||||||
|
|
||||||
|
Scenario: Resetting an active order
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
Feature: Sign up as user using facebook
|
Feature: Sign up as user using facebook
|
||||||
|
|
||||||
@javascript @broken
|
@javascript
|
||||||
Scenario: Happy flow
|
Scenario: Happy flow
|
||||||
Given There is no user information stored in the local storage
|
Given There is no user information stored in the local storage
|
||||||
When I visit the user obtain token path
|
When I visit the user obtain token path
|
||||||
@@ -9,7 +9,7 @@ Feature: Sign up as user using facebook
|
|||||||
And I should be redirected to the user home
|
And I should be redirected to the user home
|
||||||
And the newly created user info should be stored in the local storage
|
And the newly created user info should be stored in the local storage
|
||||||
|
|
||||||
@javascript @broken
|
@javascript
|
||||||
Scenario: Already signed in user visits obtain token path
|
Scenario: Already signed in user visits obtain token path
|
||||||
Given I am signed in as a user
|
Given I am signed in as a user
|
||||||
When I visit '/user'
|
When I visit '/user'
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
step 'there is a section' do
|
||||||
|
@section ||= create :section, supplier: @supplier
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
step "the user scans a table QR code" do
|
||||||
|
step 'there is a table'
|
||||||
|
page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})"
|
||||||
|
end
|
||||||
|
|
||||||
|
step 'there is a table' do
|
||||||
|
step 'there is a section'
|
||||||
|
@table ||= create :table, section: @section, supplier: @supplier
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
step "I am on the user homepage" do
|
||||||
|
visit user_root_path
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user should be redirected to the user order overview page" do
|
||||||
|
route_should_be 'user#active_list'
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user should be redirected to the archived list path" do
|
||||||
|
route_should_be 'user#history_list'
|
||||||
|
page.should have_selector ".order-row-#{@order.id}"
|
||||||
|
end
|
||||||
@@ -18,3 +18,7 @@ step 'a new order on a table in another section is created' do
|
|||||||
@new_list = create :list, section: @new_section, table: @new_table, supplier: @supplier, user_ids: [@user.id]
|
@new_list = create :list, section: @new_section, table: @new_table, supplier: @supplier, user_ids: [@user.id]
|
||||||
@new_order = @new_list.place_order @user, {@product.id => 3}
|
@new_order = @new_list.place_order @user, {@product.id => 3}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
step "I am signed in as a user" do
|
||||||
|
step "I visit the user obtain token path"
|
||||||
|
end
|
||||||
|
|||||||
@@ -11,3 +11,33 @@ end
|
|||||||
step "another order is placed" do
|
step "another order is placed" do
|
||||||
@new_order = @list.place_order @user, {@product.id => 5}
|
@new_order = @list.place_order @user, {@product.id => 5}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
step "the user order should be created as a new order" do
|
||||||
|
@order = Order.last
|
||||||
|
row = find(".order-row-#{@order.id}")
|
||||||
|
row['class'].should include 'placed'
|
||||||
|
page.should have_content 'Apple pie (1), Heineken beer (2)'
|
||||||
|
page.should have_content '€ 8.96'
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user order gets marked as being in process" do
|
||||||
|
@order.is_being_processed!
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user order should get feedback of being in process" do
|
||||||
|
row = find(".order-row-#{@order.id}")
|
||||||
|
row['class'].should include 'active'
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user order gets marked as being delivered" do
|
||||||
|
@order.is_delivered!
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user order should get feedback of being delivered" do
|
||||||
|
row = find(".order-row-#{@order.id}")
|
||||||
|
row['class'].should include 'delivered'
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user orders list gets closed" do
|
||||||
|
@order.list.close!
|
||||||
|
end
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
step "There is an open supplier with a menu" do
|
||||||
|
step 'there is a confirmed and open supplier'
|
||||||
|
@category_beer = create :product_category, name: 'Beer', supplier: @supplier
|
||||||
|
@category_lunch = create :product_category, name: 'Lunch', supplier: @supplier
|
||||||
|
@heineken_beer = create :product, name: 'Heineken beer', supplier: @supplier, price: 2.34
|
||||||
|
@apple_pie= create :product, name: 'Apple pie', supplier: @supplier, price: 4.28
|
||||||
|
@heineken_beer.add_product_category @category_beer
|
||||||
|
@apple_pie.add_product_category @category_lunch
|
||||||
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
step "the user clicks on the order :product_name twice" do |product_name|
|
||||||
|
@last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@')
|
||||||
|
button = find ".order-product-#{@last_product.id}"
|
||||||
|
2.times { button.click }
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user clicks on the order product button :product_name" do |product_name|
|
||||||
|
@last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@')
|
||||||
|
button = find ".order-product-#{@last_product.id}"
|
||||||
|
button.click
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user clicks on the user order button" do
|
||||||
|
find('#active-order-table .btn-primary').click
|
||||||
|
sleep 1
|
||||||
|
end
|
||||||
@@ -22,6 +22,38 @@ module FactoryAttributesFor
|
|||||||
super(obj, options).merge(build(obj).attributes.select{|k,v| k =~ /_id$/}).symbolize_keys
|
super(obj, options).merge(build(obj).attributes.select{|k,v| k =~ /_id$/}).symbolize_keys
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
module SpecSelectorHelpers
|
||||||
|
def top_navigation
|
||||||
|
'.navbar-fixed-top'
|
||||||
|
end
|
||||||
|
|
||||||
|
# allows tests like:
|
||||||
|
# route_should_be 'agama_groups#index'
|
||||||
|
def route_should_be(route_def)
|
||||||
|
route_hash = case route_def
|
||||||
|
when String
|
||||||
|
controller_name, action_name = route_def.split('#')
|
||||||
|
#action_name = 'index' unless action_name.present?
|
||||||
|
{controller: controller_name, action: action_name}
|
||||||
|
else
|
||||||
|
route_def
|
||||||
|
end
|
||||||
|
Rails.application.routes.recognize_path(page.current_path).should include route_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# Uses the click_on method for capybara
|
||||||
|
def click_on_translation(key)
|
||||||
|
text = I18n.t(key)
|
||||||
|
text.should_not =~ /missing/
|
||||||
|
click_on text
|
||||||
|
end
|
||||||
|
|
||||||
|
# same as save_and_open_page but with styling
|
||||||
|
def show_page
|
||||||
|
save_page Rails.root.join( 'public', 'capybara.html' )
|
||||||
|
%x(launchy http://localhost:3000/capybara.html)
|
||||||
|
end
|
||||||
|
end
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
# == Mock Framework
|
# == Mock Framework
|
||||||
#
|
#
|
||||||
@@ -36,6 +68,7 @@ RSpec.configure do |config|
|
|||||||
config.include Devise::TestHelpers, type: :controller
|
config.include Devise::TestHelpers, type: :controller
|
||||||
config.include EndWithMatcher
|
config.include EndWithMatcher
|
||||||
config.include Features::BasicHelpers, type: :feature
|
config.include Features::BasicHelpers, type: :feature
|
||||||
|
config.include SpecRouteHelpers, type: :feature
|
||||||
#config.use_transactional_fixtures = true
|
#config.use_transactional_fixtures = true
|
||||||
config.infer_base_class_for_anonymous_controllers = true
|
config.infer_base_class_for_anonymous_controllers = true
|
||||||
config.filter_run_excluding broken: true
|
config.filter_run_excluding broken: true
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
module SpecRouteHelpers
|
||||||
|
# allows tests like:
|
||||||
|
# route_should_be 'agama_groups#index'
|
||||||
|
def route_should_be(route_def)
|
||||||
|
route_hash = case route_def
|
||||||
|
when String
|
||||||
|
controller_name, action_name = route_def.split('#')
|
||||||
|
#action_name = 'index' unless action_name.present?
|
||||||
|
{controller: controller_name, action: action_name}
|
||||||
|
else
|
||||||
|
route_def
|
||||||
|
end
|
||||||
|
Rails.application.routes.recognize_path(page.current_path).should include route_hash
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user