Qwaiter supplier on Ember 1.0
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
Feature: Supplier main board
|
||||
|
||||
@javascript
|
||||
Scenario: the active list should be present and contained in row having its id
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
|
||||
When I visit the supplier root path
|
||||
Then the supplier dashboard should display the active list
|
||||
And the supplier dashboard should display the active order
|
||||
|
||||
When I click on translation 'supplier.order.being_processed'
|
||||
# waiting here only needed in old style implementation
|
||||
And I wait 1 second
|
||||
Then the supplier order row should be marked as active
|
||||
|
||||
When I click on translation 'supplier.order.being_served'
|
||||
And I wait 1 second
|
||||
Then the order in the supplier dashboard should not be displayed anymore
|
||||
And the order should be marked as delivered
|
||||
|
||||
And the list on the supplier dashboard should not be marked as in need of help
|
||||
When the list is marked as in need of help
|
||||
# waiting here only needed in old style implementation
|
||||
And I wait 1 second
|
||||
Then the list on the supplier dashboard should be marked as in need of help
|
||||
|
||||
When I click on the mark list as helped button in the supplier dashboard
|
||||
Then the list on the supplier dashboard should not be marked as in need of help
|
||||
|
||||
When the list is marked as in need of payment
|
||||
Then the list on the supplier dashboard should be marked as in need of payment
|
||||
|
||||
When another order is placed
|
||||
Then the supplier dashboard list should display the updated price
|
||||
And the new order should be present in the supplier dashboard
|
||||
|
||||
When a new order on a table in another section is created
|
||||
And I wait 1 second
|
||||
Then the new list should appear in the supplier dashboard
|
||||
And the new order on a table in another section should be present in the supplier dashboard
|
||||
|
||||
When I click on the close list button in the supplier dashboard
|
||||
And I wait 1 second
|
||||
Then the list in the supplier dashboard should not be displayed anymore
|
||||
And the list should be marked as closed
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
step "there is a fresh database with a user and supplier" do
|
||||
CouchPotato.couchrest_database.recreate!
|
||||
create_confirmed_supplier 'supplier@qwaiter.com'
|
||||
create_user 'user@qwaiter.com'
|
||||
end
|
||||
|
||||
step "I click on translation :translation" do |translation_key|
|
||||
text = I18n.t(translation_key)
|
||||
click_on text
|
||||
end
|
||||
step "I wait :number second/seconds" do |number|
|
||||
sleep number.to_f
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
step "the list is marked as in need of help" do
|
||||
@list.needs_help.should_not be_true
|
||||
@list.needs_help!
|
||||
end
|
||||
|
||||
step "the list is marked as in need of payment" do
|
||||
@list.needs_payment!
|
||||
end
|
||||
|
||||
step "the list should be marked as closed" do
|
||||
@list.reload
|
||||
@list.state.should == 'closed'
|
||||
end
|
||||
|
||||
step 'a new order on a table in another section is created' do
|
||||
@new_section = create :section, title: 'Terrace', supplier: @supplier
|
||||
@new_table = create :table, number: 59, section: @new_section, supplier: @supplier
|
||||
@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}
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
step "the order should be closed" do
|
||||
@order.reload
|
||||
@order.state.should == 'closed'
|
||||
end
|
||||
|
||||
step "the order should be marked as delivered" do
|
||||
@order.reload
|
||||
@order.state.should == 'delivered'
|
||||
end
|
||||
|
||||
step "another order is placed" do
|
||||
@new_order = @list.place_order @user, {@product.id => 5}
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
step "I am signed in as supplier" do
|
||||
step 'visit the supplier sign in path'
|
||||
find('#supplier_email').set @supplier.email
|
||||
find('#supplier_password').set @supplier_password
|
||||
click_on 'Inloggen'
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
step 'there is a confirmed and open supplier' do
|
||||
@supplier_password = 'secret1'
|
||||
@supplier = create :supplier, email: 'supplier@qwaiter.com', password: @supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true
|
||||
@section = create :section, title: 'Room', supplier: @supplier
|
||||
end
|
||||
@@ -0,0 +1,83 @@
|
||||
step "there is an active list and order" do
|
||||
@user ||= create :user
|
||||
step 'there is a confirmed and open supplier'
|
||||
@table = create :table, supplier: @supplier, section: @section
|
||||
@section.should be_present
|
||||
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
|
||||
@product = create :product, price: 2.22, supplier: @supplier
|
||||
@order = create :order, user: @user, list: @list, supplier: @supplier, section: @section
|
||||
@product_order = create :product_order, order: @order, product: @product, quantity: 3, price: 2.11
|
||||
end
|
||||
|
||||
step "the supplier dashboard should display the active list" do
|
||||
el = find(".list-row-#{@list.id}")
|
||||
el['class'].should_not =~ /active/
|
||||
end
|
||||
|
||||
step "the list in the supplier dashboard should not be displayed anymore" do
|
||||
page.should_not have_selector(".list-row-#{@list.id}")
|
||||
end
|
||||
|
||||
step "the supplier dashboard should display the active order" do
|
||||
el = find(".order-row-#{@order.id}")
|
||||
el['class'].should_not =~ /active/
|
||||
end
|
||||
step "the supplier order row should be marked as active" do
|
||||
el = find(".order-row-#{@order.id}")
|
||||
el['class'].should =~ /active/
|
||||
end
|
||||
|
||||
step "the order in the supplier dashboard should not be displayed anymore" do
|
||||
page.should_not have_selector(".order-row-#{@order.id}")
|
||||
end
|
||||
|
||||
step "the list on the supplier dashboard should not be marked as in need of help" do
|
||||
page.should_not have_selector(".list-row-#{@list.id} .list-needs-help-indicator")
|
||||
end
|
||||
|
||||
step "the list on the supplier dashboard should be marked as in need of help" do
|
||||
page.should have_selector(".list-row-#{@list.id} .list-needs-help-indicator")
|
||||
end
|
||||
|
||||
step "the list on the supplier dashboard should not be marked as in need of payment" do
|
||||
page.should_not have_selector(".list-row-#{@list.id} .list-needs-payment-indicator")
|
||||
end
|
||||
|
||||
step "the list on the supplier dashboard should be marked as in need of payment" do
|
||||
page.should have_selector(".list-row-#{@list.id} .list-needs-payment-indicator")
|
||||
end
|
||||
|
||||
step "the supplier dashboard list should display the updated price" do
|
||||
el = find(".list-row-#{@list.id} .total_list_amount")
|
||||
# original order is 3 * 2.11 = 6.33
|
||||
# new order price = 5 * 2.22 = 11.10
|
||||
# therefore the updated price should be 17.43
|
||||
el.text.should =~ /17.43/
|
||||
end
|
||||
|
||||
step "the new order should be present in the supplier dashboard" do
|
||||
el = find(".order-row-#{@new_order.id}")
|
||||
el.find('.table_number').text.should == @table.number.to_s
|
||||
el.find('.section_title').text.should == @section.title
|
||||
end
|
||||
|
||||
step "the new order on a table in another section should be present in the supplier dashboard" do
|
||||
el = find(".order-row-#{@new_order.id}")
|
||||
el.find('.table_number').text.should == @new_table.number.to_s
|
||||
el.find('.section_title').text.should == @new_section.title
|
||||
end
|
||||
|
||||
step "the new list should appear in the supplier dashboard" do
|
||||
el = find(".list-row-#{@new_list.id}")
|
||||
el.find('.total_list_amount').text.should =~ /6.66/
|
||||
el.find('.section_title').text.should == 'Terrace'
|
||||
el.find('.table_number').text.should == @new_table.number.to_s
|
||||
end
|
||||
|
||||
step "I click on the close list button in the supplier dashboard" do
|
||||
find(".list-row-#{@list.id} .close_list").click
|
||||
end
|
||||
|
||||
step "I click on the mark list as helped button in the supplier dashboard" do
|
||||
find(".list-row-#{@list.id} .mark_list_as_helped").click
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
step 'visit the supplier sign in path' do
|
||||
visit '/suppliers/sign_in'
|
||||
end
|
||||
|
||||
step "I visit the supplier root path" do
|
||||
visit '/supplier' unless page.current_path == '/supplier'
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :product_order do
|
||||
association :order
|
||||
association :product
|
||||
end
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
require 'spec_helper'
|
||||
feature 'Supplier product categories spec', %q{
|
||||
In order to manage product categories
|
||||
As a confirmed supplier
|
||||
I want to have control over product categories and associated products
|
||||
} do
|
||||
background do
|
||||
create_confirmed_supplier 'supplier@qwaiter.com'
|
||||
end
|
||||
context "GET #index" do
|
||||
background do
|
||||
@product_category = create :product_category, supplier: @supplier
|
||||
end
|
||||
scenario "I can see a drag handle having class .handle for sorting the product categories" do
|
||||
login_supplier_as 'supplier@qwaiter.com'
|
||||
visit '/supplier/product_categories'
|
||||
page.should have_selector '.handle'
|
||||
end
|
||||
end
|
||||
end
|
||||
+21
-10
@@ -3,10 +3,15 @@ require 'spec_helper'
|
||||
|
||||
describe List do
|
||||
let(:supplier) { create :supplier }
|
||||
let(:supplier_password){'secret1'}
|
||||
let(:supplier) { create :supplier, email: 'supplier@qwaiter.com', password: supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true }
|
||||
let(:user) { create :user }
|
||||
let(:section) { create :section, supplier: supplier}
|
||||
let(:table) { create :table, supplier: supplier}
|
||||
let(:list){ create :list, supplier: supplier, table: table, user_ids: [user.id] }
|
||||
let(:list){ create :list, supplier: supplier, table: table, section: section, user_ids: [user.id] }
|
||||
let(:product){ create :product, price: 2.22, supplier: supplier }
|
||||
let(:order) { create :order, user: user, list: list, supplier: supplier, section: section }
|
||||
let(:product_order ){ create :product_order, order: order, product: product, quantity: 3, price: 2.11 }
|
||||
subject { list }
|
||||
describe :as_json do
|
||||
it 'should include _id in as_json serialization' do
|
||||
@@ -17,16 +22,22 @@ describe List do
|
||||
end
|
||||
end
|
||||
|
||||
describe :mark_as_payed do
|
||||
it "should set payed_at to a time" do
|
||||
list.payed_at.should be_nil
|
||||
list.mark_as_payed
|
||||
list.payed_at.should be_kind_of Time
|
||||
describe :mark_as_paid do
|
||||
it "should set paid_at to a time" do
|
||||
list.paid_at.should be_nil
|
||||
list.is_paid!
|
||||
list.paid_at.should be_kind_of Time
|
||||
end
|
||||
it "should set is_payed to true" do
|
||||
list.is_payed.should be_false
|
||||
list.mark_as_payed
|
||||
list.is_payed.should be_true
|
||||
it "should set is_paid to true" do
|
||||
list.is_paid.should be_false
|
||||
list.is_paid!
|
||||
list.is_paid.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#set_price' do
|
||||
it 'takes the product_order price in stead of the product price' do
|
||||
product_order and list.set_price.should == 6.33
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+11
-7
@@ -2,16 +2,19 @@
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rspec/autorun'
|
||||
require 'rspec/matchers'
|
||||
require 'capybara/rspec'
|
||||
require 'turnip/capybara'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||
#Dir[Rails.root.join("spec/factories/**/*.rb")].each {|f| require f }
|
||||
Dir.glob("spec/acceptance_steps/**/*steps.rb") { |f| load f, true }
|
||||
|
||||
I18n.locale = :en
|
||||
I18n.locale = Rails.configuration.i18n.default_locale
|
||||
Devise.stretches = 1
|
||||
Capybara.javascript_driver = :selenium
|
||||
Capybara.javascript_driver = :webkit
|
||||
#Capybara.default_driver = :selenium
|
||||
|
||||
module FactoryAttributesFor
|
||||
@@ -45,7 +48,7 @@ RSpec.configure do |config|
|
||||
config.tty = true
|
||||
|
||||
# Use the specified formatter
|
||||
config.formatter = :documentation # :progress, :html, :textmate
|
||||
#config.formatter = :documentation # :progress, :html, :textmate
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
#config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
@@ -58,10 +61,11 @@ RSpec.configure do |config|
|
||||
config.before :each do
|
||||
CouchPotato.couchrest_database.recreate!
|
||||
end
|
||||
config.before :each, type: :request do
|
||||
#Capybara.current_driver = :selenium
|
||||
#sign_in_user_through_request
|
||||
|
||||
config.before :each, type: :feature do
|
||||
Supplier.any_instance.stub send_confirmation_instructions: true
|
||||
end
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
|
||||
Reference in New Issue
Block a user