From cb744943bd82be805d3a10c2f4065c5284890824 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Thu, 17 Sep 2015 17:46:33 +0200 Subject: [PATCH] Acceptance tests for user --- .gitignore | 1 + Gemfile | 3 ++- Gemfile.lock | 10 ++++++++-- app/controllers/admin/users_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- app/controllers/users/lists_controller.rb | 7 ++++++- app/controllers/users/tables_controller.rb | 2 +- app/helpers/users_helper.rb | 5 +++++ app/models/list.rb | 4 ++-- app/models/list/join_requests.rb | 2 +- app/models/user.rb | 4 +++- app/serializers/users/supplier_serializer.rb | 2 +- app/views/admin/users/test_login.html.slim | 2 -- app/views/dashboard/close_window.html.erb | 2 +- bin/test_prepare | 8 ++++++++ config/initializers/devise.rb | 2 +- config/routes.rb | 5 ++--- spec/acceptance/users/join_an_occupied_table.feature | 1 + spec/acceptance_steps/global_list_steps.rb | 2 +- spec/acceptance_steps/global_order_steps.rb | 2 +- spec/acceptance_steps/global_user_steps.rb | 8 +++++--- spec/acceptance_steps/order_steps.rb | 2 +- spec/acceptance_steps/users/authentication_steps.rb | 6 +----- spec/acceptance_steps/users/changing_table_steps.rb | 4 +++- spec/acceptance_steps/users/feedback_steps.rb | 2 +- spec/acceptance_steps/users/join_request_steps.rb | 10 +++++++--- spec/acceptance_steps/users/order_products_steps.rb | 4 ++-- spec/factories/user_factory.rb | 3 ++- spec/integrety/persistance_spec.rb | 12 ++++++++++++ spec/models/employee_shift_spec.rb | 2 -- spec/models/list/join_requests_spec.rb | 8 ++++---- spec/spec_helper.rb | 1 + spec/support/ember_helpers.rb | 6 +++--- spec/support/features/basic_helpers.rb | 2 +- spec/support/route_helpers.rb | 2 +- 35 files changed, 91 insertions(+), 49 deletions(-) create mode 100644 app/helpers/users_helper.rb create mode 100755 bin/test_prepare diff --git a/.gitignore b/.gitignore index 28b4d021..5ef9e2bb 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ erl_crash.dump /*.autosave /db/data /db/config +public/user diff --git a/Gemfile b/Gemfile index c102b574..4ee1c84b 100644 --- a/Gemfile +++ b/Gemfile @@ -99,6 +99,7 @@ end group :development, :test do gem 'rspec-rails' gem 'pry-rails' + gem 'pry-doc' gem 'test_squad' gem 'factory_girl_rails' end @@ -124,7 +125,7 @@ group :test do #gem 'capybara-webkit' #, '~>0.14.2' # version 1.1.0 does not yet compile in mavericks #gem 'selenium-webdriver', '~> 2.45.0.dev3' gem 'selenium-webdriver' - gem 'hashie' + gem 'timecop' #gem 'poltergeist' #gem 'capybara-webkit' gem 'capybara-screenshot' diff --git a/Gemfile.lock b/Gemfile.lock index c3095a50..6dad5bee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,7 +31,7 @@ GIT GIT remote: git://github.com/bterkuile/simply_stored.git - revision: 57773e8d4b3fc3410875576b3257ffa628e8d4ec + revision: 323c11efe7f86b3e156acfa7e53d8f06d8fb73c4 specs: simply_stored (1.0.0) activesupport @@ -313,6 +313,9 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + pry-doc (0.8.0) + pry (~> 0.9) + yard (~> 0.8) pry-rails (0.3.4) pry (>= 0.9.10) puma (2.13.4) @@ -436,6 +439,7 @@ GEM thor (0.19.1) thread_safe (0.3.5) tilt (2.0.1) + timecop (0.8.0) timers (4.0.4) hitimes tinymce-rails (4.2.5) @@ -467,6 +471,7 @@ GEM websocket-extensions (0.1.2) xpath (2.0.0) nokogiri (~> 1.3) + yard (0.8.7.6) PLATFORMS ruby @@ -499,7 +504,6 @@ DEPENDENCIES foreman foundation-rails fuubar - hashie iso_country_codes jquery-rails jquery-ui-rails @@ -514,6 +518,7 @@ DEPENDENCIES omniauth-instagram paperclip (>= 4.2.4, != 4.3.0) pickadate-rails + pry-doc pry-rails puma quiet_assets @@ -534,6 +539,7 @@ DEPENDENCIES sucker_punch test_squad therubyracer + timecop turnip uglifier (>= 1.0.3) web-console (~> 2.0.0) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 0b142de2..ef81330d 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -31,7 +31,7 @@ module Admin sign_in user render layout: false else - render nothing: true + head :not_found end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 16834ce1..217ac332 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -59,7 +59,7 @@ private end def _render_with_renderer_json(resource, options) - return super if resource.is_a?(Hash) + return super if resource.is_a?(Hash) or resource.is_a?(String) options[:serializer] ||= begin if resource.is_a?(SimplyStored::Couch) #infer based on controller path replacing actual controller part with resouce part /lists/:id/table diff --git a/app/controllers/users/lists_controller.rb b/app/controllers/users/lists_controller.rb index 4e3a1a36..e7fc35b2 100644 --- a/app/controllers/users/lists_controller.rb +++ b/app/controllers/users/lists_controller.rb @@ -14,7 +14,7 @@ module Users #EMBER def current @list = current_user.active_list - params[:id] = @list.id # serializer determines collection or not based on the presence of this + params[:id] = @list.try(:id) # serializer determines collection or not based on the presence of this show end @@ -67,6 +67,11 @@ module Users # POST /user/lists/:id/order_products def order_products res = {} + unless active_list.present? + res[:list_closed] = true + render json: res, status: 404 + return + end res[:supplier_closed] = active_list.supplier.closed? unless res[:supplier_closed] # Create new list diff --git a/app/controllers/users/tables_controller.rb b/app/controllers/users/tables_controller.rb index 9e4f287f..fdf7d255 100644 --- a/app/controllers/users/tables_controller.rb +++ b/app/controllers/users/tables_controller.rb @@ -75,7 +75,7 @@ module Users list = List.from_table( table, current_user ) res[:active_list_id] = list.id # used to set the active list in the app order = list.place_order product_orders: product_orders, user: current_user, first_order: true - res[:payload] = JSONAPI::Serializer.serialize(order, serializer: Users::OrderSerializer, include: %w[list product_orders]) + res[:payload] = JSONAPI::Serializer.serialize(order, serializer: Users::OrderSerializer, include: %w[list list.users product_orders]) end render json: res end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 00000000..5a65b17f --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,5 @@ +module UsersHelper + def user_ember_target + "*" + end +end diff --git a/app/models/list.rb b/app/models/list.rb index 953df61e..61aa5a51 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -163,7 +163,7 @@ class List for user in users user.active_list_id = nil user.save - broadcast_user user.id, 'list_closed', broadcast_info + #broadcast_user user.id, 'list_closed', broadcast_info end broadcast_supplier supplier_id, 'list_closed', broadcast_info end @@ -333,7 +333,7 @@ class List user product_orders ]) - broadcast_users 'new_order', user_payload + broadcast_users 'new_order', supplier_orders_placed_count: orders_placed_count, payload: user_payload broadcast_supplier supplier.id, 'new_order', supplier_orders_placed_count: orders_placed_count, payload: supplier_payload end #broadcast_supplier supplier.id, 'orders_placed_count', count: orders_placed_count # done inside new order payload diff --git a/app/models/list/join_requests.rb b/app/models/list/join_requests.rb index b2643db2..a9e352e3 100644 --- a/app/models/list/join_requests.rb +++ b/app/models/list/join_requests.rb @@ -20,7 +20,7 @@ class List self.join_request_user_ids |= [requester.id] self.is_dirty if save - broadcast_users 'user_join_request', payload: JSONAPI::Serializer.serialize( join_request_for_user(requester), serializer: Users::JoinRequestSerializer, include: %w[list user]) + broadcast_users 'user_join_request', payload: Users::JoinRequestSerializer.serialize(join_request_for_user(requester), include: %w[list user]) end end end diff --git a/app/models/user.rb b/app/models/user.rb index f87ec27a..d2da760f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -13,7 +13,9 @@ class User property :oauth_expires_at property :auth_data - devise :database_authenticatable, :recoverable, :rememberable, :trackable, :omniauthable, :omniauth_providers => [:facebook, :instagram] #, :token_authenticatable , :registerable + devise_plugins = [:database_authenticatable, :recoverable, :rememberable, :trackable, :omniauthable, {omniauth_providers: [:facebook, :instagram]}] #, :token_authenticatable , :registerable + devise_plugins -= [:trackable] if Rails.env.test? # creates conflicts + devise *devise_plugins property :authentication_token diff --git a/app/serializers/users/supplier_serializer.rb b/app/serializers/users/supplier_serializer.rb index 813e441e..395caf9c 100644 --- a/app/serializers/users/supplier_serializer.rb +++ b/app/serializers/users/supplier_serializer.rb @@ -1,5 +1,5 @@ class Users::SupplierSerializer include Qwaiter::UserBaseSerializer - attributes :open, :name + attributes :open, :name, :orders_placed_count, :orders_in_process_count has_many :product_categories, serializer: Users::ProductCategorySerializer end diff --git a/app/views/admin/users/test_login.html.slim b/app/views/admin/users/test_login.html.slim index cf10fb94..e3caf3a8 100644 --- a/app/views/admin/users/test_login.html.slim +++ b/app/views/admin/users/test_login.html.slim @@ -5,8 +5,6 @@ html localStorage.setItem('auth_token', '#{current_user.authentication_token}'); localStorage.setItem('user_id', '#{current_user.id}'); localStorage.setItem('locale', '#{I18n.default_locale}'); - - body p Test login page p= "Signed in as: #{current_user.email}" diff --git a/app/views/dashboard/close_window.html.erb b/app/views/dashboard/close_window.html.erb index 28d4fc82..71582eee 100644 --- a/app/views/dashboard/close_window.html.erb +++ b/app/views/dashboard/close_window.html.erb @@ -3,7 +3,7 @@ diff --git a/bin/test_prepare b/bin/test_prepare new file mode 100755 index 00000000..7d1eca53 --- /dev/null +++ b/bin/test_prepare @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'active_support/all' +mozo_user_path = ENV['MOZO_USER_PATH'] || Pathname.new(File.expand_path('../../../mozo-user', __FILE__)) +Dir.chdir mozo_user_path do + `ember build --output-path=../mozo/public/user/ --environment=testexport` # not production, because then the production servers will be queried +end + diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 67c07481..693f34aa 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -236,7 +236,7 @@ Devise.setup do |config| # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' if Rails.env.production? # config.omniauth :facebook, "505160086210072", "fcc474a3fb13c6bcc0f7c83a92ad1b17", - # scope: 'email,user_birthday,publish_stream' + # scope: 'email,user_birthday,publish_actions' config.omniauth :facebook, "653729178057509", "d4cea86f70803f1b75ed03c506a4d78e", scope: 'email,user_birthday,publish_actions' config.omniauth :instagram, "cd7bdfbee825499b94fb3783d1bc143b", "6b4f9ecf251c462993a696eebc0189be" diff --git a/config/routes.rb b/config/routes.rb index dc6cc751..0d662103 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,11 +73,10 @@ Qwaiter::Application.routes.draw do #post '/user/approve_join_request' => 'user#approve_join_request' - post '/user/check_table_join_status' => 'user#check_table_join_status' + #post '/user/check_table_join_status' => 'user#check_table_join_status' get '/user/obtain_token' => 'user#obtain_token', as: :user_obtain_token - post '/user/obtain_token' => 'user#obtain_token', constraints: {format: :json} + #post '/user/obtain_token' => 'user#obtain_token', constraints: {format: :json} get '/close_window' => 'dashboard#close_window' - namespace :users, path: '/user/api/v1' do resources :product_categories, only: [:index] resources :lists, only: [:index, :show] do diff --git a/spec/acceptance/users/join_an_occupied_table.feature b/spec/acceptance/users/join_an_occupied_table.feature index 7d858ad2..48ec75c7 100644 --- a/spec/acceptance/users/join_an_occupied_table.feature +++ b/spec/acceptance/users/join_an_occupied_table.feature @@ -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 diff --git a/spec/acceptance_steps/global_list_steps.rb b/spec/acceptance_steps/global_list_steps.rb index f187302e..44b3cb1c 100644 --- a/spec/acceptance_steps/global_list_steps.rb +++ b/spec/acceptance_steps/global_list_steps.rb @@ -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 diff --git a/spec/acceptance_steps/global_order_steps.rb b/spec/acceptance_steps/global_order_steps.rb index e6e18193..cd64c834 100644 --- a/spec/acceptance_steps/global_order_steps.rb +++ b/spec/acceptance_steps/global_order_steps.rb @@ -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| diff --git a/spec/acceptance_steps/global_user_steps.rb b/spec/acceptance_steps/global_user_steps.rb index 0b2247d4..6ae06041 100644 --- a/spec/acceptance_steps/global_user_steps.rb +++ b/spec/acceptance_steps/global_user_steps.rb @@ -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 diff --git a/spec/acceptance_steps/order_steps.rb b/spec/acceptance_steps/order_steps.rb index e0b78e58..b314bf22 100644 --- a/spec/acceptance_steps/order_steps.rb +++ b/spec/acceptance_steps/order_steps.rb @@ -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 diff --git a/spec/acceptance_steps/users/authentication_steps.rb b/spec/acceptance_steps/users/authentication_steps.rb index b0d11ba7..83c1f920 100644 --- a/spec/acceptance_steps/users/authentication_steps.rb +++ b/spec/acceptance_steps/users/authentication_steps.rb @@ -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 diff --git a/spec/acceptance_steps/users/changing_table_steps.rb b/spec/acceptance_steps/users/changing_table_steps.rb index 175bdbfc..e64a15a5 100644 --- a/spec/acceptance_steps/users/changing_table_steps.rb +++ b/spec/acceptance_steps/users/changing_table_steps.rb @@ -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 diff --git a/spec/acceptance_steps/users/feedback_steps.rb b/spec/acceptance_steps/users/feedback_steps.rb index ff030149..51f3eae0 100644 --- a/spec/acceptance_steps/users/feedback_steps.rb +++ b/spec/acceptance_steps/users/feedback_steps.rb @@ -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 diff --git a/spec/acceptance_steps/users/join_request_steps.rb b/spec/acceptance_steps/users/join_request_steps.rb index f7ff90b2..78dbe8f0 100644 --- a/spec/acceptance_steps/users/join_request_steps.rb +++ b/spec/acceptance_steps/users/join_request_steps.rb @@ -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 diff --git a/spec/acceptance_steps/users/order_products_steps.rb b/spec/acceptance_steps/users/order_products_steps.rb index 010c7f41..a04a715e 100644 --- a/spec/acceptance_steps/users/order_products_steps.rb +++ b/spec/acceptance_steps/users/order_products_steps.rb @@ -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 diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index 2503c9b8..0dae2e99 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -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", diff --git a/spec/integrety/persistance_spec.rb b/spec/integrety/persistance_spec.rb index 89d4852e..3dee648f 100644 --- a/spec/integrety/persistance_spec.rb +++ b/spec/integrety/persistance_spec.rb @@ -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 diff --git a/spec/models/employee_shift_spec.rb b/spec/models/employee_shift_spec.rb index b21fb969..6a525379 100644 --- a/spec/models/employee_shift_spec.rb +++ b/spec/models/employee_shift_spec.rb @@ -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 diff --git a/spec/models/list/join_requests_spec.rb b/spec/models/list/join_requests_spec.rb index 9f2ee69c..d8c233d7 100644 --- a/spec/models/list/join_requests_spec.rb +++ b/spec/models/list/join_requests_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f9afb8dd..f2d398d5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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) diff --git a/spec/support/ember_helpers.rb b/spec/support/ember_helpers.rb index c2c50882..23f41458 100644 --- a/spec/support/ember_helpers.rb +++ b/spec/support/ember_helpers.rb @@ -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 diff --git a/spec/support/features/basic_helpers.rb b/spec/support/features/basic_helpers.rb index 270aa073..b593811f 100644 --- a/spec/support/features/basic_helpers.rb +++ b/spec/support/features/basic_helpers.rb @@ -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) diff --git a/spec/support/route_helpers.rb b/spec/support/route_helpers.rb index ad72744b..dde3d3fa 100644 --- a/spec/support/route_helpers.rb +++ b/spec/support/route_helpers.rb @@ -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"