Qwaiter supplier on Ember 1.0

This commit is contained in:
2013-09-30 17:49:22 +02:00
parent 6d7647c2c5
commit 8ea2e79dc2
44 changed files with 378 additions and 156 deletions
+13
View File
@@ -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
+20
View File
@@ -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
+13
View File
@@ -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