Acceptance tests for user
This commit is contained in:
@@ -11,6 +11,7 @@ Feature: Joining an occupied table
|
||||
And the original user should see a join request message
|
||||
When the original user approves the other user's join request
|
||||
Then the original user should not see the join request anymore
|
||||
And the original user should see the other user added below the active list
|
||||
And the other user should be added to the active list
|
||||
And the other user should be redirected to active list it just joined
|
||||
|
||||
|
||||
@@ -20,5 +20,5 @@ 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: @other_section, table: @other_table, supplier: @supplier, user_ids: [@user.id]
|
||||
@new_order = @new_list.place_order(product_orders: [ {'product_id' => @product.id, 'quantity' => 3}], user: @user)
|
||||
@new_order = @new_list.place_order(product_orders: [ {'product_id' => @product.id, 'quantity' => 3}], user: @user, first_order: true)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
step "A new order is placed" do
|
||||
@user ||= create :user
|
||||
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
|
||||
@order = @list.place_order product_orders: [{ 'product_id' => @product.id, 'quantity' => 2}], user: @user
|
||||
@order = @list.place_order product_orders: [{ 'product_id' => @product.id, 'quantity' => 2}], user: @user, first_order: true
|
||||
end
|
||||
|
||||
step "an order with :quantity products :product_name should have been created" do |quantity, product_name|
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
step "the user scans a table QR code" do
|
||||
step 'there is a table'
|
||||
page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
||||
when_ember_is_ready do
|
||||
page.execute_script "MozoUser.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
||||
end
|
||||
end
|
||||
|
||||
step "I am on the user homepage" do
|
||||
@@ -8,12 +10,12 @@ step "I am on the user homepage" do
|
||||
end
|
||||
|
||||
step "the user is on the homepage" do
|
||||
visit '/user'
|
||||
user_visit '/'
|
||||
end
|
||||
|
||||
step "the user should be redirected to the user order overview page" do
|
||||
#route_should_be 'user#active_list'
|
||||
ember_route_should_be "/active_list"
|
||||
ember_route_should_be "/active-list"
|
||||
end
|
||||
|
||||
step "the user should be redirected to the archived list path" do
|
||||
|
||||
@@ -9,7 +9,7 @@ step "the order should be marked as delivered" do
|
||||
end
|
||||
|
||||
step "another order is placed" do
|
||||
@new_order = @list.place_order(product_orders: [{ 'product_id' => @product.id, 'quantity' => 5}], user: @user)
|
||||
@new_order = @list.place_order(product_orders: [{ 'product_id' => @product.id, 'quantity' => 5}], user: @user, first_order: false)
|
||||
end
|
||||
|
||||
step "the user order should be created as a new order" do
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
|
||||
step "there is no user information stored in the local storage" do
|
||||
visit '/'
|
||||
user_visit '/'
|
||||
page.execute_script %|Qstorage = window.localStorage|
|
||||
page.execute_script(%|Qstorage.removeItem('user_id')|)
|
||||
page.execute_script(%|Qstorage.removeItem('auth_token')|)
|
||||
end
|
||||
|
||||
step "I visit the user obtain token path" do
|
||||
visit user_root_path # obtain token through ember application
|
||||
end
|
||||
|
||||
step "there is a user" do
|
||||
@user ||= create :user
|
||||
end
|
||||
|
||||
@@ -33,7 +33,9 @@ step "there is another table with an active list of another user" do
|
||||
end
|
||||
|
||||
step "the user scans a QR code of another not occupied table" do
|
||||
page.execute_script %|App.__container__.lookup('controller:select_qrcode').send('selectQr', {_id: "#{@other_table.id}"})|
|
||||
when_ember_is_ready do
|
||||
page.execute_script %|MozoUser.__container__.lookup('route:application').send('selectQr', {_id: "#{@other_table.id}"})|
|
||||
end
|
||||
#page.execute_script "Quser.actions_for_table({table_id: '#{@other_table.id}'})"
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ step "the user clicks on the submit feedback button" do
|
||||
end
|
||||
|
||||
step "the user should see the feedback submitted message" do
|
||||
page.should have_content I18n.t('user.about.feedback.received')
|
||||
page.should have_content 'Thank you for your feedback'
|
||||
end
|
||||
|
||||
step "a user feedback should be created containing the feedback" do
|
||||
|
||||
@@ -16,12 +16,16 @@ end
|
||||
|
||||
step "another user scans the QR code on the table" do
|
||||
step 'there is another signed in user user'
|
||||
visit user_root_path
|
||||
user_visit '/'
|
||||
when_ember_is_ready do
|
||||
page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
||||
page.execute_script "MozoUser.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
||||
end
|
||||
end
|
||||
|
||||
step "the original user should see the other user added below the active list" do
|
||||
page.evaluate_script(%|$('.list-user-total-container').length()|).should eq 2
|
||||
end
|
||||
|
||||
step "the original user approves the other user's join request" do
|
||||
find('.join-request-approve').click
|
||||
end
|
||||
@@ -67,5 +71,5 @@ end
|
||||
|
||||
step "the other user should be redirected to active list it just joined" do
|
||||
Capybara.session_name = :other_user
|
||||
ember_route_should_be '/active_list'
|
||||
ember_route_should_be '/active-list'
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ step "there is another signed in user on the same list" do
|
||||
end
|
||||
|
||||
step 'the other user orders a product :count times' do |count|
|
||||
@list.place_order product_orders: [{'product_id' => @product.id, 'quantity' => count.to_i}], user: @other_user
|
||||
@list.place_order product_orders: [{'product_id' => @product.id, 'quantity' => count.to_i}], user: @other_user, first_order: false
|
||||
end
|
||||
|
||||
step 'the other user is part of the list' do
|
||||
@@ -111,7 +111,7 @@ step "the user should see an empty active order panel" do
|
||||
end
|
||||
|
||||
step 'the user is on the order products page' do
|
||||
visit "/user#/tables/#{@table.id}"
|
||||
user_visit "tables/#{@table.id}"
|
||||
end
|
||||
|
||||
step 'the user should see the products listed for the active list' do
|
||||
|
||||
@@ -4,7 +4,8 @@ FactoryGirl.define do
|
||||
password "secret"
|
||||
|
||||
trait :other_auth do
|
||||
auth_data( {
|
||||
sequence( :email ){|i| "test-other-user#{i}@example.com" }
|
||||
auth_data( {
|
||||
'info' => {
|
||||
'nickname' => "UOther",
|
||||
"name" => "USR Other",
|
||||
|
||||
@@ -10,5 +10,17 @@ describe "persistance" do
|
||||
response.should include %|"ruby_class":"Employee"|
|
||||
response.should_not include %|"id":|
|
||||
end
|
||||
|
||||
it "stores time in UTC iso8601 format" do
|
||||
time = Time.utc(1981, 3, 9, 13, 22, 2).in_time_zone
|
||||
Timecop.travel time do
|
||||
employee_shift = create :employee_shift, start_from: time, end_on: time + 2.hours
|
||||
response = JSON.parse Net::HTTP.get URI(File.join(db_uri, employee_shift.id))
|
||||
response['created_at'].should eq "1981-03-09T13:22:02Z"
|
||||
response['updated_at'].should eq "1981-03-09T13:22:02Z"
|
||||
response['start_from'].should eq "1981-03-09T13:22:02Z"
|
||||
response['end_on'].should eq "1981-03-09T15:22:02Z"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,14 +9,12 @@ describe EmployeeShift do
|
||||
es2 = create :employee_shift, supplier: supplier2, start_from: 9.days.ago, end_on: 5.days.ago
|
||||
es3 = create :employee_shift, supplier: supplier2, start_from: 9.days.ago, end_on: 8.days.ago
|
||||
es4 = create :employee_shift, supplier: supplier2, start_from: 1.day.from_now, end_on: 1.day.from_now + 2.hours
|
||||
es5 = create :employee_shift, supplier: supplier2, end_on: 1.day.from_now
|
||||
|
||||
results = EmployeeShift.for_supplier(supplier2)
|
||||
results.should_not include(es1), 'different supplier'
|
||||
results.should include(es2), 'end day within a week ago'
|
||||
results.should_not include(es3), 'end day more than a week ago'
|
||||
results.should include(es4) , 'Most relevant case'
|
||||
results.should_not include(es5) , 'missing start_from'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ describe List do
|
||||
expect{
|
||||
list.send_table_join_request_for_user! other_user
|
||||
}.to broadcast_to_user(user.id).message('user_join_request').with(
|
||||
hash_including(:users, :join_request)
|
||||
hash_including(:payload)
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -74,14 +74,14 @@ describe List do
|
||||
it "broadcasts the event to the user itself" do
|
||||
joining_user
|
||||
expect{ list.approve_join_request_for_user! joining_user }
|
||||
.to broadcast_to_user(joining_user).message('join_request_approved')
|
||||
.with( hash_including(:user) )
|
||||
.to broadcast_to_user(joining_user).message('join_request_approved')
|
||||
.with( id: "jr-#{joining_user.id}" )
|
||||
end
|
||||
|
||||
it "broadcasts the event to other associated users" do
|
||||
expect{ list.approve_join_request_for_user! joining_user }
|
||||
.to broadcast_to_user(user).message('join_request_approved')
|
||||
.with( hash_including(:user) )
|
||||
.with( id: "jr-#{joining_user.id}" )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ Devise.stretches = 1
|
||||
#Capybara.javascript_driver = :poltergeist
|
||||
Capybara.javascript_driver = :selenium
|
||||
Capybara.default_wait_time = 5 # ember needs more time than the default of 2
|
||||
Capybara.server_port = 62625
|
||||
Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
|
||||
WebMock.disable_net_connect!(allow_localhost: true)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module SpecEmberHelpers
|
||||
def ember_store
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
$s = App.__container__.lookup('store:main');
|
||||
$s = (MozoUser || App).__container__.lookup('store:main');
|
||||
JSON.stringify({
|
||||
lists: $s.all('list').invoke('serialize'),
|
||||
orders: $s.all('order').invoke('serialize'),
|
||||
@@ -85,13 +85,13 @@ module SpecEmberHelpers
|
||||
|
||||
def ember_find(typeKey, id)
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
App.__container__.lookup('store:main').all('#{typeKey}').findBy('id', '#{id}').serialize()
|
||||
(MozoUser || App).__container__.lookup('store:main').all('#{typeKey}').findBy('id', '#{id}').serialize()
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
def ember_all(typeKey)
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
App.__container__.lookup('store:main').all('#{typeKey}').invoke('serialize')
|
||||
(MozoUser || App).__container__.lookup('store:main').all('#{typeKey}').invoke('serialize')
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ module Features
|
||||
|
||||
def user_visit(path)
|
||||
#visit File.join("http://localhost:3/")
|
||||
visit File.join("/user#", path)
|
||||
visit File.join("/user/index.html#", path)
|
||||
end
|
||||
|
||||
def login_employee_as(email)
|
||||
|
||||
@@ -31,7 +31,7 @@ module SpecRouteHelpers
|
||||
# currentRouteName does not include model information: /list/123 => currentRouteName == 'list'
|
||||
# page.evaluate_script %|App.__container__.lookup('controller:application').get('currentRouteName')|
|
||||
# page.evaluate_script %|App.__container__.lookup('router:main').location.lastSetURL| # not working for direct path supplier#/settings
|
||||
route = page.evaluate_script(%{App.__container__ && (window.location.hash || "#/").substr(1)})
|
||||
route = page.evaluate_script(%{(MozoUser || App).__container__ && (window.location.hash || "#/").substr(1)})
|
||||
unless omit_should_raise
|
||||
def route.should(*)
|
||||
raise "Cannot call should on ember route. Use ember_route_should_be instead"
|
||||
|
||||
Reference in New Issue
Block a user