Spec squashing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
App.DashboardActiveOrderComponent = Ember.Component.extend
|
App.DashboardActiveOrderComponent = Ember.Component.extend
|
||||||
tagName: 'tr'
|
tagName: 'tr'
|
||||||
layoutName: 'dashboard/active-order'
|
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')}"
|
classIdentifier: Ember.computed 'order.id', -> "order-row-#{@get('order.id')}"
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ App.MySelectComponent = Ember.Component.extend
|
|||||||
@set('content', []) unless @get('content')
|
@set('content', []) unless @get('content')
|
||||||
).on('init')
|
).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:
|
actions:
|
||||||
change: ->
|
change: ->
|
||||||
selectedIndex = @$('select:first').get(0).selectedIndex
|
selectedIndex = @$('select:first').get(0).selectedIndex
|
||||||
@@ -25,7 +32,7 @@ App.MySelectComponent = Ember.Component.extend
|
|||||||
hasPrompt = !!@get('prompt')
|
hasPrompt = !!@get('prompt')
|
||||||
contentIndex = if hasPrompt then selectedIndex - 1 else selectedIndex
|
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
|
# set the local, shadowed selection to avoid leaking
|
||||||
# changes to `selection` out via 2-way binding
|
# 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()
|
sections: (-> @store.peekAll('section')).property()
|
||||||
#setSelectedSection: (-> @set 'selectedSection', @get('model.section')).on('init')
|
#setSelectedSection: (-> @set 'selectedSection', @get('model.section')).on('init')
|
||||||
actions:
|
actions:
|
||||||
confirm: ->
|
|
||||||
@get('model').then (l)->l.close()
|
|
||||||
@send 'closeModal'
|
|
||||||
saveTable: ->
|
saveTable: ->
|
||||||
#@set 'model.section', @get('selectedSection')
|
|
||||||
@set 'model.section', @get('model.section')
|
|
||||||
@send 'save'
|
@send 'save'
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ App.TablesIndexController = Ember.Controller.extend
|
|||||||
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
|
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
|
||||||
actions:
|
actions:
|
||||||
newTable: ->
|
newTable: ->
|
||||||
table = @store.createRecord('table')
|
section = @get('globals.active_section') || @store.peekAll('section').toArray()[0]
|
||||||
|
table = @store.createRecord('table', section: section)
|
||||||
@modal 'table_edit',
|
@modal 'table_edit',
|
||||||
model: table
|
model: table
|
||||||
close: -> table.deleteRecord()
|
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 'table', path: ':table_id'
|
||||||
@resource 'lists', ->
|
@resource 'lists', ->
|
||||||
@resource 'list', path: ':list_id'
|
@resource 'list', path: ':list_id'
|
||||||
@resource 'employees', ->
|
@route 'employees'
|
||||||
@resource 'employee', path: ':employee_id'
|
@route 'employee', path: '/employees/:employee_id'
|
||||||
@resource 'pages', ->
|
@resource 'pages', ->
|
||||||
@resource 'page', path: ':page_id'
|
@resource 'page', path: ':page_id'
|
||||||
@route 'orders_display' # chromecast etc
|
@route 'orders_display' # chromecast etc
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
App.EmployeeRoute = Ember.Route.extend App.EmployeeActionsMixin
|
||||||
@@ -1,23 +1,2 @@
|
|||||||
App.EmployeesRoute = Ember.Route.extend
|
App.EmployeesRoute = Ember.Route.extend App.EmployeeActionsMixin,
|
||||||
model: -> @store.peekAll 'employee'
|
model: -> @store.findAll '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'
|
|
||||||
|
|||||||
@@ -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
|
.form-field= number-field numericValue=model.height
|
||||||
hr
|
hr
|
||||||
button.modal-close{action "close"}=t 'table.modal.close_button'
|
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
|
= qr-codes-link table=model
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ Feature: Manage employees
|
|||||||
And I click on selector '.modal-confirm'
|
And I click on selector '.modal-confirm'
|
||||||
And I wait 1 second
|
And I wait 1 second
|
||||||
Then the new employee should be added to the supplier
|
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
|
@javascript
|
||||||
Scenario: adding an already existing employee that was firstly added as manager without manager and active
|
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
|
all('tr').last.find('.table-edit').click
|
||||||
end
|
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
|
step "the supplier employee clicks on the existing employee table destroy button" do
|
||||||
find 'table.table'
|
find 'table.table'
|
||||||
sleep 0.2
|
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 'occupied'
|
||||||
css_class.should_not include 'active_order'
|
css_class.should_not include 'active_order'
|
||||||
css_class.should_not include 'needs_payment'
|
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
|
end
|
||||||
|
|
||||||
step "I should be redirected to the supplier section view" do
|
step "I should be redirected to the supplier section view" do
|
||||||
|
|||||||
@@ -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 = (MozoUser || App).__container__.lookup('store:main');
|
$s = (window.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'),
|
||||||
@@ -84,14 +84,12 @@ module SpecEmberHelpers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ember_find(typeKey, id)
|
def ember_find(typeKey, id)
|
||||||
h = page.evaluate_script <<-SCRIPT
|
h = page.evaluate_script "(window.MozoUser || App).__container__.lookup('service:store').peekRecord('#{typeKey}', '#{id}').toJSON()"
|
||||||
(MozoUser || App).__container__.lookup('service:store').peekRecord('#{typeKey}', '#{id}').toJSON()
|
|
||||||
SCRIPT
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def ember_all(typeKey)
|
def ember_all(typeKey)
|
||||||
h = page.evaluate_script <<-SCRIPT
|
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
|
SCRIPT
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -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(%{(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
|
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user