All specs green, ember transition successful

This commit is contained in:
2014-06-27 14:52:18 +02:00
parent a5e8d38882
commit b5a68e9627
19 changed files with 100 additions and 14 deletions
@@ -1,3 +1,4 @@
Qsupplier.App = Ember.Application.create
LOG_TRANSITIONS: true
rootElement: '#ember-app-container'
store: -> @__container__.lookup('controller:application').store
@@ -9,7 +9,8 @@ Qsupplier.App.List = DS.Model.extend
#has_active_orders: attr 'boolean'
has_active_orders: (->
return false unless @get('state') == 'active'
!!@get('orders').filterProperty('state', 'active').length
#!!@get('orders').filterProperty('state', 'active').length
!!@get('orders').filter( (order) -> order.get('state') is 'active' or order.get('state') is 'placed').length
).property('state', 'orders.@each.state')
price: attr 'number'
closed_at: DS.attr('date')
@@ -20,19 +20,30 @@ DS.Model.reopenClass
else
#@store.find(@, attributes.id)
@pushByAttriburtes(attributes)
pushByAttriburtes: (attributes)->
pushByAttriburtes: (attributes, options = {})->
#store = @all().get('store')
#Ugly hack at the cost of an extra request since I do not yet know the proper
#code for adding a record by its attributes and having its associations set
#@find(attributes.id)
decamelized = Ember.String.decamelize(@typeKey)
self_name = Ember.String.pluralize(decamelized)
self_name = self_name.substr(1) if self_name[0] == '.'
Ember.get(@, 'relationships').forEach (model, relation)=>
relation = relation[0]
if relation.kind == 'belongsTo' and id = attributes["#{relation.name}_id"]
attributes[relation.name] = id unless attributes[relation.name]
#belongs_tos = {}
#Ember.get(@, 'relationships').forEach (model, relation)=>
#relation = relation[0]
#if relation.kind == 'belongsTo' and id = attributes["#{relation.name}_id"]
#attributes[relation.name] = id unless attributes[relation.name]
#debugger if options.debug
#belongs_tos[relation.name] = id
@store.push @toString(), attributes
nested_attributes = {}
nested_attributes[self_name] = attributes
# pushPayload makes association back references, just push not yet 2014-06-27
new_record = @store.pushPayload(@toString(), nested_attributes)
#debugger if options.debug
#promises = []
#association_names = []
@@ -1,10 +1,15 @@
.display-row
.display-label=t 'attributes.list.created_at'
.display-field=time list.created_at
if list.closed_at
.display-row
.display-label=t 'attributes.list.closed_at'
.display-field=time list.closed_at
.display-row
.display-label=t 'attributes.list.state'
.display-field=state 'list' list.state
each user in list.users
.row
each user in list.users
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square" alt="f"
if list.orders
.list-orders-container
@@ -5,7 +5,11 @@ root.Qsupplier=
faye.subscribe "/supplier/"+supplier_id, (e)=>
console.log(e)
if(e.event == 'new_order')
Qsupplier.App.Order.pushByAttriburtes(e.data.order) if Qsupplier.App
if Qsupplier.App
Qsupplier.App.store().pushPayload e.data
#Qsupplier.App.Order.pushByAttriburtes(e.data.order)
#for product_order in e.data.product_orders
#Qsupplier.App.ProductOrder.pushByAttriburtes product_order, debug: true
else if(e.event == 'list_needs_help')
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.markNeedsHelp()
@@ -7,6 +7,7 @@ App.List = DS.Model.extend
supplier_name: attr('string')
state: attr('string')
price: attr('number')
closed_at: DS.attr('date')
extended_version: attr('boolean')
supplier_orders_in_process_count: attr('number')
supplier_orders_placed_count: attr('number')
@@ -1,5 +1,15 @@
each user in list.users
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square" alt="f"
.display-row
.display-label=t 'attributes.list.created_at'
.display-field=time list.created_at
if list.closed_at
.display-row
.display-label=t 'attributes.list.closed_at'
.display-field=time list.closed_at
.display-row
.display-label=t 'attributes.list.state'
.display-field=state 'list' list.state
if list.orders
.list-orders-container
each order in list.sorted_orders
@@ -0,0 +1,17 @@
.display-row
@extend .row
.display-label
font-weight: bold
@media #{$small-only}
+grid-column($columns:10, $center:true)
@media #{$medium-only}
+grid-column($columns:4, $offset:1)
@media #{$large-up}
+grid-column(3)
.display-field
@media #{$small-only}
+grid-column($columns:10, $center:true, $last-column:true)
@media #{$medium-only}
+grid-column($columns:4, $last-column:true)
@media #{$large-up}
+grid-column($columns: 3, $last-column:true)
@@ -12,6 +12,7 @@
clear: right
+panel($padding: 4px)
.list-orders-container
border-top: 2px solid #555
.currency
float: right
list-style: none
@@ -6,6 +6,7 @@
@import ./menu_main
@import ./menu_side
@import ./qmodal
@import ./display_fields
@import ./qproduct_orders
@import ./qproduct_categories
@import ./form_additions
@@ -17,8 +17,8 @@ header.top-menu
.table-number
.supplier-info-row
.counter.supplier-orders-placed-count
span.orders-placed-count-number= current_supplier.orders_placed_count
span.orders-placed-count-icon
span.supplier-orders-placed-count-number= current_supplier.orders_placed_count
span.supplier-orders-placed-count-icon
.counter.supplier-orders-in-process-count
span.supplier-orders-in-process-count-number= current_supplier.orders_in_process_count
span.supplier-orders-in-process-count-icon
+4
View File
@@ -84,3 +84,7 @@ en:
order_button: Order
total: Total
no_orders: No products
state:
list:
active: 'Active'
closed: 'Closed'
+4
View File
@@ -82,3 +82,7 @@ nl:
order_button: Bestel
total: Totaal
no_orders: Geen bestellingen
state:
list:
active: 'Actief'
closed: 'Afgesloten'
@@ -11,6 +11,9 @@ Feature: Supplier section view
And the section table should be marked as occupied
And the section table should not be marked as in need of help
When the order gets marked as being in process
Then the section table should still be marked as having an active order
When the list is marked as in need of help
# waiting here only needed in old style implementation
And I wait 1 second
+4
View File
@@ -23,6 +23,10 @@ step "the user order should be created as a new order" do
end
step "the user order gets marked as being in process" do
step "the order gets marked as being in process"
end
step "the order gets marked as being in process" do
@order.is_being_processed!
end
@@ -134,7 +134,6 @@ step "the active list changes to another table in another section" do
end
step "the supplier main board table number should be updated to the new table number" do
binding.pry
expect( find(".list-row-#{@list.id} .table_number").text ).to eq "65"
expect( find(".order-row-#{@list.orders.first.id} .table_number").text ).to eq "65"
end
@@ -10,9 +10,11 @@ end
step "the section table should be marked as having an active order" do
table = page.find(".section-table-#{@table.id}")
binding.pry
table['class'].should include 'active_order'
end
step "the section table should still be marked as having an active order" do
step "the section table should be marked as having an active order"
end
step "the section table should be marked as occupied" do
table = page.find(".section-table-#{@table.id}")
+1
View File
@@ -67,6 +67,7 @@ RSpec.configure do |config|
config.include Matchers
config.include Features::BasicHelpers, type: :feature
config.include SpecRouteHelpers, type: :feature
config.include SpecEmberHelpers, type: :feature
#config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = true
config.filter_run_excluding broken: true
+17
View File
@@ -0,0 +1,17 @@
module SpecEmberHelpers
def ember_store
h = page.evaluate_script <<-SCRIPT
$s = Qsupplier.App.__container__.lookup('controller:application').store;
JSON.stringify({
lists: $s.all('list').invoke('serialize'),
orders: $s.all('order').invoke('serialize'),
product_orders: $s.all('product_order').invoke('serialize'),
product_categories: $s.all('product_category').invoke('serialize'),
products: $s.all('product').invoke('serialize'),
sections: $s.all('section').invoke('serialize'),
tables: $s.all('table').invoke('serialize')
})
SCRIPT
JSON.parse(h)
end
end