Acceptance tests for user

This commit is contained in:
2015-09-17 17:46:33 +02:00
parent 8e931cabd4
commit cb744943bd
35 changed files with 91 additions and 49 deletions
+1
View File
@@ -46,3 +46,4 @@ erl_crash.dump
/*.autosave /*.autosave
/db/data /db/data
/db/config /db/config
public/user
+2 -1
View File
@@ -99,6 +99,7 @@ end
group :development, :test do group :development, :test do
gem 'rspec-rails' gem 'rspec-rails'
gem 'pry-rails' gem 'pry-rails'
gem 'pry-doc'
gem 'test_squad' gem 'test_squad'
gem 'factory_girl_rails' gem 'factory_girl_rails'
end 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 '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', '~> 2.45.0.dev3'
gem 'selenium-webdriver' gem 'selenium-webdriver'
gem 'hashie' gem 'timecop'
#gem 'poltergeist' #gem 'poltergeist'
#gem 'capybara-webkit' #gem 'capybara-webkit'
gem 'capybara-screenshot' gem 'capybara-screenshot'
+8 -2
View File
@@ -31,7 +31,7 @@ GIT
GIT GIT
remote: git://github.com/bterkuile/simply_stored.git remote: git://github.com/bterkuile/simply_stored.git
revision: 57773e8d4b3fc3410875576b3257ffa628e8d4ec revision: 323c11efe7f86b3e156acfa7e53d8f06d8fb73c4
specs: specs:
simply_stored (1.0.0) simply_stored (1.0.0)
activesupport activesupport
@@ -313,6 +313,9 @@ GEM
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
pry-doc (0.8.0)
pry (~> 0.9)
yard (~> 0.8)
pry-rails (0.3.4) pry-rails (0.3.4)
pry (>= 0.9.10) pry (>= 0.9.10)
puma (2.13.4) puma (2.13.4)
@@ -436,6 +439,7 @@ GEM
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (2.0.1) tilt (2.0.1)
timecop (0.8.0)
timers (4.0.4) timers (4.0.4)
hitimes hitimes
tinymce-rails (4.2.5) tinymce-rails (4.2.5)
@@ -467,6 +471,7 @@ GEM
websocket-extensions (0.1.2) websocket-extensions (0.1.2)
xpath (2.0.0) xpath (2.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
yard (0.8.7.6)
PLATFORMS PLATFORMS
ruby ruby
@@ -499,7 +504,6 @@ DEPENDENCIES
foreman foreman
foundation-rails foundation-rails
fuubar fuubar
hashie
iso_country_codes iso_country_codes
jquery-rails jquery-rails
jquery-ui-rails jquery-ui-rails
@@ -514,6 +518,7 @@ DEPENDENCIES
omniauth-instagram omniauth-instagram
paperclip (>= 4.2.4, != 4.3.0) paperclip (>= 4.2.4, != 4.3.0)
pickadate-rails pickadate-rails
pry-doc
pry-rails pry-rails
puma puma
quiet_assets quiet_assets
@@ -534,6 +539,7 @@ DEPENDENCIES
sucker_punch sucker_punch
test_squad test_squad
therubyracer therubyracer
timecop
turnip turnip
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
web-console (~> 2.0.0) web-console (~> 2.0.0)
+1 -1
View File
@@ -31,7 +31,7 @@ module Admin
sign_in user sign_in user
render layout: false render layout: false
else else
render nothing: true head :not_found
end end
end end
+1 -1
View File
@@ -59,7 +59,7 @@ private
end end
def _render_with_renderer_json(resource, options) 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 options[:serializer] ||= begin
if resource.is_a?(SimplyStored::Couch) if resource.is_a?(SimplyStored::Couch)
#infer based on controller path replacing actual controller part with resouce part /lists/:id/table #infer based on controller path replacing actual controller part with resouce part /lists/:id/table
+6 -1
View File
@@ -14,7 +14,7 @@ module Users
#EMBER #EMBER
def current def current
@list = current_user.active_list @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 show
end end
@@ -67,6 +67,11 @@ module Users
# POST /user/lists/:id/order_products # POST /user/lists/:id/order_products
def order_products def order_products
res = {} res = {}
unless active_list.present?
res[:list_closed] = true
render json: res, status: 404
return
end
res[:supplier_closed] = active_list.supplier.closed? res[:supplier_closed] = active_list.supplier.closed?
unless res[:supplier_closed] unless res[:supplier_closed]
# Create new list # Create new list
+1 -1
View File
@@ -75,7 +75,7 @@ module Users
list = List.from_table( table, current_user ) list = List.from_table( table, current_user )
res[:active_list_id] = list.id # used to set the active list in the app 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 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 end
render json: res render json: res
end end
+5
View File
@@ -0,0 +1,5 @@
module UsersHelper
def user_ember_target
"*"
end
end
+2 -2
View File
@@ -163,7 +163,7 @@ class List
for user in users for user in users
user.active_list_id = nil user.active_list_id = nil
user.save user.save
broadcast_user user.id, 'list_closed', broadcast_info #broadcast_user user.id, 'list_closed', broadcast_info
end end
broadcast_supplier supplier_id, 'list_closed', broadcast_info broadcast_supplier supplier_id, 'list_closed', broadcast_info
end end
@@ -333,7 +333,7 @@ class List
user user
product_orders 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 broadcast_supplier supplier.id, 'new_order', supplier_orders_placed_count: orders_placed_count, payload: supplier_payload
end end
#broadcast_supplier supplier.id, 'orders_placed_count', count: orders_placed_count # done inside new order payload #broadcast_supplier supplier.id, 'orders_placed_count', count: orders_placed_count # done inside new order payload
+1 -1
View File
@@ -20,7 +20,7 @@ class List
self.join_request_user_ids |= [requester.id] self.join_request_user_ids |= [requester.id]
self.is_dirty self.is_dirty
if save 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 end
end end
+3 -1
View File
@@ -13,7 +13,9 @@ class User
property :oauth_expires_at property :oauth_expires_at
property :auth_data 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 property :authentication_token
+1 -1
View File
@@ -1,5 +1,5 @@
class Users::SupplierSerializer class Users::SupplierSerializer
include Qwaiter::UserBaseSerializer include Qwaiter::UserBaseSerializer
attributes :open, :name attributes :open, :name, :orders_placed_count, :orders_in_process_count
has_many :product_categories, serializer: Users::ProductCategorySerializer has_many :product_categories, serializer: Users::ProductCategorySerializer
end end
@@ -5,8 +5,6 @@ html
localStorage.setItem('auth_token', '#{current_user.authentication_token}'); localStorage.setItem('auth_token', '#{current_user.authentication_token}');
localStorage.setItem('user_id', '#{current_user.id}'); localStorage.setItem('user_id', '#{current_user.id}');
localStorage.setItem('locale', '#{I18n.default_locale}'); localStorage.setItem('locale', '#{I18n.default_locale}');
body body
p Test login page p Test login page
p= "Signed in as: #{current_user.email}" p= "Signed in as: #{current_user.email}"
+1 -1
View File
@@ -3,7 +3,7 @@
<head> <head>
<script> <script>
console.log("closing window"); console.log("closing window");
window.opener.postMessage({user_id: '<%= params[:user_id] %>', authentication_token: '<%= params[:authentication_token] %>'}, "http://localhost:4200"); window.opener.postMessage({user_id: '<%= params[:user_id] %>', authentication_token: '<%= params[:authentication_token] %>'}, "<%= user_ember_target %>");
window.close(); window.close();
</script> </script>
</head> </head>
+8
View File
@@ -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
+1 -1
View File
@@ -236,7 +236,7 @@ Devise.setup do |config|
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
if Rails.env.production? if Rails.env.production?
# config.omniauth :facebook, "505160086210072", "fcc474a3fb13c6bcc0f7c83a92ad1b17", # config.omniauth :facebook, "505160086210072", "fcc474a3fb13c6bcc0f7c83a92ad1b17",
# scope: 'email,user_birthday,publish_stream' # scope: 'email,user_birthday,publish_actions'
config.omniauth :facebook, "653729178057509", "d4cea86f70803f1b75ed03c506a4d78e", config.omniauth :facebook, "653729178057509", "d4cea86f70803f1b75ed03c506a4d78e",
scope: 'email,user_birthday,publish_actions' scope: 'email,user_birthday,publish_actions'
config.omniauth :instagram, "cd7bdfbee825499b94fb3783d1bc143b", "6b4f9ecf251c462993a696eebc0189be" config.omniauth :instagram, "cd7bdfbee825499b94fb3783d1bc143b", "6b4f9ecf251c462993a696eebc0189be"
+2 -3
View File
@@ -73,11 +73,10 @@ Qwaiter::Application.routes.draw do
#post '/user/approve_join_request' => 'user#approve_join_request' #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 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' get '/close_window' => 'dashboard#close_window'
namespace :users, path: '/user/api/v1' do namespace :users, path: '/user/api/v1' do
resources :product_categories, only: [:index] resources :product_categories, only: [:index]
resources :lists, only: [:index, :show] do resources :lists, only: [:index, :show] do
@@ -11,6 +11,7 @@ Feature: Joining an occupied table
And the original user should see a join request message And the original user should see a join request message
When the original user approves the other user's join request When the original user approves the other user's join request
Then the original user should not see the join request anymore 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 added to the active list
And the other user should be redirected to active list it just joined And the other user should be redirected to active list it just joined
+1 -1
View File
@@ -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_section = create :section, title: 'Terrace', supplier: @supplier
# @new_table = create :table, number: 59, section: @new_section, 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_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 end
+1 -1
View File
@@ -1,7 +1,7 @@
step "A new order is placed" do step "A new order is placed" do
@user ||= create :user @user ||= create :user
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id] @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 end
step "an order with :quantity products :product_name should have been created" do |quantity, product_name| step "an order with :quantity products :product_name should have been created" do |quantity, product_name|
+5 -3
View File
@@ -1,6 +1,8 @@
step "the user scans a table QR code" do step "the user scans a table QR code" do
step 'there is a table' 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 end
step "I am on the user homepage" do step "I am on the user homepage" do
@@ -8,12 +10,12 @@ step "I am on the user homepage" do
end end
step "the user is on the homepage" do step "the user is on the homepage" do
visit '/user' user_visit '/'
end end
step "the user should be redirected to the user order overview page" do step "the user should be redirected to the user order overview page" do
#route_should_be 'user#active_list' #route_should_be 'user#active_list'
ember_route_should_be "/active_list" ember_route_should_be "/active-list"
end end
step "the user should be redirected to the archived list path" do step "the user should be redirected to the archived list path" do
+1 -1
View File
@@ -9,7 +9,7 @@ step "the order should be marked as delivered" do
end end
step "another order is placed" do 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 end
step "the user order should be created as a new order" do 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 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 = window.localStorage|
page.execute_script(%|Qstorage.removeItem('user_id')|) page.execute_script(%|Qstorage.removeItem('user_id')|)
page.execute_script(%|Qstorage.removeItem('auth_token')|) page.execute_script(%|Qstorage.removeItem('auth_token')|)
end 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 step "there is a user" do
@user ||= create :user @user ||= create :user
end end
@@ -33,7 +33,9 @@ step "there is another table with an active list of another user" do
end end
step "the user scans a QR code of another not occupied table" do 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}'})" #page.execute_script "Quser.actions_for_table({table_id: '#{@other_table.id}'})"
end end
@@ -7,7 +7,7 @@ step "the user clicks on the submit feedback button" do
end end
step "the user should see the feedback submitted message" do 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 end
step "a user feedback should be created containing the feedback" do 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 "another user scans the QR code on the table" do
step 'there is another signed in user user' step 'there is another signed in user user'
visit user_root_path user_visit '/'
when_ember_is_ready do 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
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 step "the original user approves the other user's join request" do
find('.join-request-approve').click find('.join-request-approve').click
end end
@@ -67,5 +71,5 @@ end
step "the other user should be redirected to active list it just joined" do step "the other user should be redirected to active list it just joined" do
Capybara.session_name = :other_user Capybara.session_name = :other_user
ember_route_should_be '/active_list' ember_route_should_be '/active-list'
end end
@@ -43,7 +43,7 @@ step "there is another signed in user on the same list" do
end end
step 'the other user orders a product :count times' do |count| 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 end
step 'the other user is part of the list' do 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 end
step 'the user is on the order products page' do step 'the user is on the order products page' do
visit "/user#/tables/#{@table.id}" user_visit "tables/#{@table.id}"
end end
step 'the user should see the products listed for the active list' do step 'the user should see the products listed for the active list' do
+2 -1
View File
@@ -4,7 +4,8 @@ FactoryGirl.define do
password "secret" password "secret"
trait :other_auth do trait :other_auth do
auth_data( { sequence( :email ){|i| "test-other-user#{i}@example.com" }
auth_data( {
'info' => { 'info' => {
'nickname' => "UOther", 'nickname' => "UOther",
"name" => "USR Other", "name" => "USR Other",
+12
View File
@@ -10,5 +10,17 @@ describe "persistance" do
response.should include %|"ruby_class":"Employee"| response.should include %|"ruby_class":"Employee"|
response.should_not include %|"id":| response.should_not include %|"id":|
end 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
end end
-2
View File
@@ -9,14 +9,12 @@ describe EmployeeShift do
es2 = create :employee_shift, supplier: supplier2, start_from: 9.days.ago, end_on: 5.days.ago 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 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 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 = EmployeeShift.for_supplier(supplier2)
results.should_not include(es1), 'different supplier' results.should_not include(es1), 'different supplier'
results.should include(es2), 'end day within a week ago' results.should include(es2), 'end day within a week ago'
results.should_not include(es3), 'end day more than a week ago' results.should_not include(es3), 'end day more than a week ago'
results.should include(es4) , 'Most relevant case' results.should include(es4) , 'Most relevant case'
results.should_not include(es5) , 'missing start_from'
end end
end end
end end
+4 -4
View File
@@ -36,7 +36,7 @@ describe List do
expect{ expect{
list.send_table_join_request_for_user! other_user list.send_table_join_request_for_user! other_user
}.to broadcast_to_user(user.id).message('user_join_request').with( }.to broadcast_to_user(user.id).message('user_join_request').with(
hash_including(:users, :join_request) hash_including(:payload)
) )
end end
end end
@@ -74,14 +74,14 @@ describe List do
it "broadcasts the event to the user itself" do it "broadcasts the event to the user itself" do
joining_user joining_user
expect{ list.approve_join_request_for_user! joining_user } expect{ list.approve_join_request_for_user! joining_user }
.to broadcast_to_user(joining_user).message('join_request_approved') .to broadcast_to_user(joining_user).message('join_request_approved')
.with( hash_including(:user) ) .with( id: "jr-#{joining_user.id}" )
end end
it "broadcasts the event to other associated users" do it "broadcasts the event to other associated users" do
expect{ list.approve_join_request_for_user! joining_user } expect{ list.approve_join_request_for_user! joining_user }
.to broadcast_to_user(user).message('join_request_approved') .to broadcast_to_user(user).message('join_request_approved')
.with( hash_including(:user) ) .with( id: "jr-#{joining_user.id}" )
end end
end end
+1
View File
@@ -24,6 +24,7 @@ Devise.stretches = 1
#Capybara.javascript_driver = :poltergeist #Capybara.javascript_driver = :poltergeist
Capybara.javascript_driver = :selenium Capybara.javascript_driver = :selenium
Capybara.default_wait_time = 5 # ember needs more time than the default of 2 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 } Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
WebMock.disable_net_connect!(allow_localhost: true) WebMock.disable_net_connect!(allow_localhost: true)
+3 -3
View File
@@ -1,7 +1,7 @@
module SpecEmberHelpers module SpecEmberHelpers
def ember_store def ember_store
h = page.evaluate_script <<-SCRIPT h = page.evaluate_script <<-SCRIPT
$s = App.__container__.lookup('store:main'); $s = (MozoUser || App).__container__.lookup('store:main');
JSON.stringify({ JSON.stringify({
lists: $s.all('list').invoke('serialize'), lists: $s.all('list').invoke('serialize'),
orders: $s.all('order').invoke('serialize'), orders: $s.all('order').invoke('serialize'),
@@ -85,13 +85,13 @@ module SpecEmberHelpers
def ember_find(typeKey, id) def ember_find(typeKey, id)
h = page.evaluate_script <<-SCRIPT 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 SCRIPT
end end
def ember_all(typeKey) def ember_all(typeKey)
h = page.evaluate_script <<-SCRIPT 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 SCRIPT
end end
+1 -1
View File
@@ -23,7 +23,7 @@ module Features
def user_visit(path) def user_visit(path)
#visit File.join("http://localhost:3/") #visit File.join("http://localhost:3/")
visit File.join("/user#", path) visit File.join("/user/index.html#", path)
end end
def login_employee_as(email) def login_employee_as(email)
+1 -1
View File
@@ -31,7 +31,7 @@ module SpecRouteHelpers
# currentRouteName does not include model information: /list/123 => currentRouteName == 'list' # 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('controller:application').get('currentRouteName')|
# page.evaluate_script %|App.__container__.lookup('router:main').location.lastSetURL| # not working for direct path supplier#/settings # 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 unless omit_should_raise
def route.should(*) def route.should(*)
raise "Cannot call should on ember route. Use ember_route_should_be instead" raise "Cannot call should on ember route. Use ember_route_should_be instead"