Spec squashing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
App.DashboardActiveOrderComponent = Ember.Component.extend
|
||||
tagName: 'tr'
|
||||
layoutName: 'dashboard/active-order'
|
||||
classNameBindings: ['content.active:active', 'content.delivered:delivered', 'classIdentifier']
|
||||
classNameBindings: ['order.active:active', 'order.delivered:delivered', 'classIdentifier']
|
||||
classIdentifier: Ember.computed 'order.id', -> "order-row-#{@get('order.id')}"
|
||||
|
||||
@@ -17,6 +17,13 @@ App.MySelectComponent = Ember.Component.extend
|
||||
@set('content', []) unless @get('content')
|
||||
).on('init')
|
||||
|
||||
didRender: ->
|
||||
# Set select to current value if can be found
|
||||
key = @get('optionValuePath')
|
||||
index = @get('content').mapBy(key).indexOf(@get("selection.#{key}"))
|
||||
if index > -1
|
||||
@$('select:first').prop('selectedIndex', index)
|
||||
|
||||
actions:
|
||||
change: ->
|
||||
selectedIndex = @$('select:first').get(0).selectedIndex
|
||||
@@ -25,7 +32,7 @@ App.MySelectComponent = Ember.Component.extend
|
||||
hasPrompt = !!@get('prompt')
|
||||
contentIndex = if hasPrompt then selectedIndex - 1 else selectedIndex
|
||||
|
||||
selection = @get('content')[contentIndex]
|
||||
selection = @get('content').toArray()[contentIndex]
|
||||
|
||||
# set the local, shadowed selection to avoid leaking
|
||||
# changes to `selection` out via 2-way binding
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
App.EmployeesController = Ember.Controller.extend
|
||||
employeeSorting: ['name']
|
||||
employees: Ember.computed.sort 'model', 'employeeSorting'
|
||||
@@ -1,2 +0,0 @@
|
||||
App.EmployeesIndexController = Ember.Controller.extend
|
||||
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
|
||||
@@ -3,10 +3,5 @@ App.modals.TableEditController = App.modals.BaseController.extend
|
||||
sections: (-> @store.peekAll('section')).property()
|
||||
#setSelectedSection: (-> @set 'selectedSection', @get('model.section')).on('init')
|
||||
actions:
|
||||
confirm: ->
|
||||
@get('model').then (l)->l.close()
|
||||
@send 'closeModal'
|
||||
saveTable: ->
|
||||
#@set 'model.section', @get('selectedSection')
|
||||
@set 'model.section', @get('model.section')
|
||||
@send 'save'
|
||||
|
||||
@@ -2,7 +2,8 @@ App.TablesIndexController = Ember.Controller.extend
|
||||
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
|
||||
actions:
|
||||
newTable: ->
|
||||
table = @store.createRecord('table')
|
||||
section = @get('globals.active_section') || @store.peekAll('section').toArray()[0]
|
||||
table = @store.createRecord('table', section: section)
|
||||
@modal 'table_edit',
|
||||
model: table
|
||||
close: -> table.deleteRecord()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
App.EmployeeActionsMixin = Ember.Mixin.create
|
||||
actions:
|
||||
newEmployee: ->
|
||||
employee = @store.createRecord('employee')
|
||||
@get('controller').modal 'employee_edit',
|
||||
model: employee
|
||||
title_path: 'employee.modal.new_title'
|
||||
close: -> employee.deleteRecord()
|
||||
editEmployee: (employee)->
|
||||
@get('controller').modal 'employee_edit',
|
||||
model: employee
|
||||
title_path: 'employee.modal.edit_title'
|
||||
close: -> employee.rollbackAttributes()
|
||||
destroyEmployee: (employee)->
|
||||
ac = @controllerFor('application')
|
||||
if @get('globals.current_employee.id') isnt employee.id
|
||||
ac.modal 'confirm',
|
||||
title: t('employee.destroy.modal.title', employee.toJSON())
|
||||
ok: -> employee.destroyRecord()
|
||||
else
|
||||
ac.modal 'alert',
|
||||
title: 'You cannot remove yourself'
|
||||
@@ -12,8 +12,8 @@ App.Router.map ->
|
||||
@resource 'table', path: ':table_id'
|
||||
@resource 'lists', ->
|
||||
@resource 'list', path: ':list_id'
|
||||
@resource 'employees', ->
|
||||
@resource 'employee', path: ':employee_id'
|
||||
@route 'employees'
|
||||
@route 'employee', path: '/employees/:employee_id'
|
||||
@resource 'pages', ->
|
||||
@resource 'page', path: ':page_id'
|
||||
@route 'orders_display' # chromecast etc
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
App.EmployeeRoute = Ember.Route.extend App.EmployeeActionsMixin
|
||||
@@ -1,23 +1,2 @@
|
||||
App.EmployeesRoute = Ember.Route.extend
|
||||
model: -> @store.peekAll 'employee'
|
||||
actions:
|
||||
newEmployee: ->
|
||||
employee = @store.createRecord('employee')
|
||||
@get('controller').modal 'employee_edit',
|
||||
model: employee
|
||||
title_path: 'employee.modal.new_title'
|
||||
close: -> employee.deleteRecord()
|
||||
editEmployee: (employee)->
|
||||
@get('controller').modal 'employee_edit',
|
||||
model: employee
|
||||
title_path: 'employee.modal.edit_title'
|
||||
close: -> employee.rollbackAttributes()
|
||||
destroyEmployee: (employee)->
|
||||
ac = @controllerFor('application')
|
||||
if ac.get('employee.id') isnt employee.id
|
||||
ac.modal 'confirm',
|
||||
title: t('employee.destroy.modal.title', employee.toJSON())
|
||||
ok: -> employee.destroyRecord()
|
||||
else
|
||||
ac.modal 'alert',
|
||||
title: 'You cannot remove yourself'
|
||||
App.EmployeesRoute = Ember.Route.extend App.EmployeeActionsMixin,
|
||||
model: -> @store.findAll 'employee'
|
||||
|
||||
@@ -1 +1,29 @@
|
||||
= outlet
|
||||
.row: .small-12.columns
|
||||
h2.main-section-header=t 'models.plural.employee'
|
||||
if employees
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th.name=t 'attributes.employee.name'
|
||||
th.email=t 'attributes.employee.email'
|
||||
th.boolean= t 'attributes.employee.manager'
|
||||
th.boolean= t 'attributes.employee.active'
|
||||
th.colorbox= t 'attributes.employee.color'
|
||||
th.actions=t 'helpers.actions.title'
|
||||
tbody
|
||||
each employees as |employee|
|
||||
tr
|
||||
td: link-to 'employee' employee: span= employee.name
|
||||
td.email
|
||||
= employee.email
|
||||
= errors employee.errors.email
|
||||
td.boolean= boolean employee.manager
|
||||
td.boolean= boolean employee.active
|
||||
td.colorbox= colorbox employee.color
|
||||
td.actions
|
||||
if (can "manage" "employees")
|
||||
a.table-edit{ action 'editEmployee' employee }: span
|
||||
a.table-destroy{ action 'destroyEmployee' employee }: span
|
||||
.form-actions
|
||||
if (can "manage" "employees")
|
||||
a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
.row: .small-12.columns
|
||||
h2.main-section-header=t 'models.plural.employee'
|
||||
if employees
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th.name=t 'attributes.employee.name'
|
||||
th.email=t 'attributes.employee.email'
|
||||
th.boolean= t 'attributes.employee.manager'
|
||||
th.boolean= t 'attributes.employee.active'
|
||||
th.colorbox= t 'attributes.employee.color'
|
||||
th.actions=t 'helpers.actions.title'
|
||||
tbody
|
||||
each employees as |employee|
|
||||
tr
|
||||
td: link-to 'employee' employee: span= employee.name
|
||||
td.email
|
||||
= employee.email
|
||||
= errors employee.errors.email
|
||||
td.boolean= boolean employee.manager
|
||||
td.boolean= boolean employee.active
|
||||
td.colorbox= colorbox employee.color
|
||||
td.actions
|
||||
if (can "manage" "sections")
|
||||
a.table-edit{ action 'editEmployee' employee }: span
|
||||
a.table-destroy{ action 'destroyEmployee' employee }: span
|
||||
.form-actions
|
||||
if (can "manage" "employees")
|
||||
a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
|
||||
@@ -13,5 +13,5 @@ p=t 'table.modal.body_header'
|
||||
.form-field= number-field numericValue=model.height
|
||||
hr
|
||||
button.modal-close{action "close"}=t 'table.modal.close_button'
|
||||
button.modal-confirm.right{action "save"}=t 'table.modal.save_button'
|
||||
button.modal-confirm.right{action "saveTable"}=t 'table.modal.save_button'
|
||||
= qr-codes-link table=model
|
||||
|
||||
@@ -12,6 +12,8 @@ Feature: Manage employees
|
||||
And I click on selector '.modal-confirm'
|
||||
And I wait 1 second
|
||||
Then the new employee should be added to the supplier
|
||||
When I reload the page
|
||||
Then the supplier employee should see content 'new-employee@example.com'
|
||||
|
||||
@javascript
|
||||
Scenario: adding an already existing employee that was firstly added as manager without manager and active
|
||||
|
||||
@@ -8,6 +8,10 @@ step "the supplier employee clicks on the other employee table edit button" do
|
||||
all('tr').last.find('.table-edit').click
|
||||
end
|
||||
|
||||
step "the supplier employee should see content :content" do |content|
|
||||
page.should have_content content
|
||||
end
|
||||
|
||||
step "the supplier employee clicks on the existing employee table destroy button" do
|
||||
find 'table.table'
|
||||
sleep 0.2
|
||||
|
||||
@@ -70,7 +70,7 @@ step "the section table should not have any active list markings anymore" do
|
||||
css_class.should_not include 'occupied'
|
||||
css_class.should_not include 'active_order'
|
||||
css_class.should_not include 'needs_payment'
|
||||
ember_find('table', @table.id)['active_list_id'].should_not be_present
|
||||
ember_find('table', @table.id)['active_list'].should_not be_present
|
||||
end
|
||||
|
||||
step "I should be redirected to the supplier section view" do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module SpecEmberHelpers
|
||||
def ember_store
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
$s = (MozoUser || App).__container__.lookup('store:main');
|
||||
$s = (window.MozoUser || App).__container__.lookup('store:main');
|
||||
JSON.stringify({
|
||||
lists: $s.all('list').invoke('serialize'),
|
||||
orders: $s.all('order').invoke('serialize'),
|
||||
@@ -84,14 +84,12 @@ module SpecEmberHelpers
|
||||
end
|
||||
|
||||
def ember_find(typeKey, id)
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
(MozoUser || App).__container__.lookup('service:store').peekRecord('#{typeKey}', '#{id}').toJSON()
|
||||
SCRIPT
|
||||
h = page.evaluate_script "(window.MozoUser || App).__container__.lookup('service:store').peekRecord('#{typeKey}', '#{id}').toJSON()"
|
||||
end
|
||||
|
||||
def ember_all(typeKey)
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
(MozoUser || App).__container__.lookup('service:store').peekAll('#{typeKey}').map(function(r){ result = r.toJSON(); result['id'] = r.id; return result })
|
||||
(window.MozoUser || App).__container__.lookup('service:store').peekAll('#{typeKey}').map(function(r){ result = r.toJSON(); result['id'] = r.id; return result })
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
|
||||
@@ -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(%{(MozoUser || App).__container__ && (window.location.hash || "#/").substr(1)})
|
||||
route = page.evaluate_script(%{(window.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