Major supplier refactor making the whole system work better
This commit is contained in:
@@ -3,3 +3,4 @@ faye: thin start -R faye/config.ru -p 9296
|
||||
#faye: rackup faye.ru -s thin -E production
|
||||
counters: bin/drb_counter.rb run
|
||||
database: echo "BuenosAires" | sudo -S couchdb start | ~/bin/couch_output
|
||||
server: rails s
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.5 KiB |
@@ -2,5 +2,5 @@ Ember.Handlebars.helper 'time', (time, params..., options = {})->
|
||||
return '' unless time
|
||||
time = new Date(time) if typeof(time) is "string"
|
||||
iso = time.toISOString()
|
||||
tag = if options.bare then iso else $("<span data-time=\"#{iso}\"></span>").text(moment(iso).format(options.format || 'dd D MMM HH:MM')).get(0).outerHTML
|
||||
tag = if options.bare then iso else $("<span data-time=\"#{iso}\"></span>").text(moment(iso).format(options.format || 'dd D MMM HH:mm')).get(0).outerHTML
|
||||
new Handlebars.SafeString tag
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
needs: ['application']
|
||||
lists: (-> @store.all('list')).property()
|
||||
orders: (-> @store.all('order')).property()
|
||||
sections: (-> @store.all('section')).property()
|
||||
active_lists: (->
|
||||
if @get('active_section.id')
|
||||
@get('lists').filter (l)=>( l.get('section.id') == @get('active_section.id') && l.get('state') == 'active' )
|
||||
if @get('controllers.application.active_section.id')
|
||||
@get('lists').filter (l)=>( l.get('section.id') == @get('controllers.application.active_section.id') && l.get('state') == 'active' )
|
||||
else
|
||||
@get('lists').filterProperty('state', 'active')
|
||||
).property('lists.@each.state', 'active_section.id')
|
||||
).property('lists.@each.state', 'controllers.application.active_section.id')
|
||||
|
||||
active_section: (-> @get('controllers.application.active_section')).property('controllers.application.active_section')
|
||||
active_orders: (->
|
||||
|
||||
@@ -6,4 +6,15 @@ Qsupplier.App.ListsIndexController = Ember.ArrayController.extend
|
||||
lists.then => @set('loading', false)
|
||||
@set 'model', lists
|
||||
).observes('date')
|
||||
lists: (-> @get('model')).property('model')
|
||||
lists: (->
|
||||
return @store.all('list') unless date = @get('date')
|
||||
@store.filter('list', (l)->
|
||||
return false unless list_date = l.get('created_at')
|
||||
list_date = list_date.toISOString().substring(0,10) if typeof(list_date) is 'object'
|
||||
list_date == date
|
||||
)
|
||||
).property('date')
|
||||
|
||||
sorted_lists: (->
|
||||
@get('lists').sortBy('created_at').reverseObjects()
|
||||
).property('lists.@each')
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@ Qsupplier.App.ModalCloseListController = Ember.ObjectController.extend
|
||||
close: ->
|
||||
@send 'closeModal'
|
||||
confirm: ->
|
||||
@get('model').close()
|
||||
@get('model').then (l)->l.close()
|
||||
@send 'closeModal'
|
||||
|
||||
@@ -10,8 +10,8 @@ Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend
|
||||
Routes.qr_codes_suppliers_tables_path section_id: section_id
|
||||
actions:
|
||||
showDashboardOrders: (section)->
|
||||
@transitionToRoute('index').then =>
|
||||
@get('controllers.index').set 'active_section', section
|
||||
@set 'controllers.application.active_section', section
|
||||
@transitionToRoute('index')
|
||||
addSection: -> @send 'openModal', 'modal_add_section', @get('model')
|
||||
goToSection: (section)->
|
||||
@set 'controllers.application.active_section', section
|
||||
|
||||
@@ -11,7 +11,7 @@ Qsupplier.App.List = DS.Model.extend
|
||||
price: attr 'number'
|
||||
closed_at: DS.attr('date')
|
||||
#table_number: attr 'number'
|
||||
table: DS.belongsTo('table', inverse: 'active_list')
|
||||
table: DS.belongsTo('table', inverse: 'active_list', async: true)
|
||||
#users: DS.hasMany('user', inverse: 'active_list')
|
||||
orders: DS.hasMany('order')
|
||||
section: DS.belongsTo('section')
|
||||
|
||||
@@ -4,6 +4,7 @@ DS.Model.reopen
|
||||
eraseRecord: ->
|
||||
@clearRelationships()
|
||||
@transitionTo('deleted.saved')
|
||||
then: (callback) -> callback.call(@, @)
|
||||
DS.Model.reopenClass
|
||||
findCached: (id)->
|
||||
return null unless id
|
||||
@@ -61,6 +62,6 @@ DS.Model.reopenClass
|
||||
#for record, i in records
|
||||
##console.log "Setting relation #{relation.name} to #{record.get('id')}"
|
||||
#new_record.set association_names[i], record
|
||||
#attributes[relation.name] =
|
||||
#attributes[relation.name] =
|
||||
#delete attributes["#{relation.name}_id"]
|
||||
#@createRecord attributes
|
||||
|
||||
@@ -13,4 +13,5 @@ Qsupplier.App.Router.map ->
|
||||
@resource 'lists', ->
|
||||
@resource 'list', path: ':list_id'
|
||||
@route 'settings'
|
||||
@route 'empty'
|
||||
#@resource 'lists', queryParams: ['state']
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
Qsupplier.App.ApplicationRoute = Ember.Route.extend
|
||||
beforeModel: ->
|
||||
# Preload only active lists and orders
|
||||
@store.find 'product_category'
|
||||
@supplier = @store.push 'supplier', supplier_object
|
||||
@product_categories = @store.find 'product_category'
|
||||
@sections = @store.find 'section'
|
||||
Ember.RSVP.all([@product_categories, @sections]).then (results)=>
|
||||
@store.find('list', state: 'active').then (lists) -> lists.invoke('get', 'table')
|
||||
@lists = @store.all 'list'
|
||||
# product_categories = controller.set 'product_categories', @store.all('product_category')
|
||||
#@store.find 'order', state: 'active' included in list
|
||||
setupController: (controller)->
|
||||
controller.set 'supplier', @supplier
|
||||
# @set 'supplier', @store.find('supplier', supplier_id)
|
||||
supplier = @store.push 'supplier', supplier_object
|
||||
controller.set 'supplier', supplier
|
||||
controller.set 'sections', @sections
|
||||
controller.set 'product_categories', @product_categories
|
||||
|
||||
@store.find 'list', state: 'active'
|
||||
@store.find 'section'
|
||||
|
||||
controller.set 'product_categories', @store.all('product_category')
|
||||
actions:
|
||||
openModal: (modalName, model, options={})->
|
||||
controller_name = options.controller || modalName
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
Qsupplier.App.IndexRoute = Ember.Route.extend
|
||||
model: (params, queryParams)->
|
||||
Ember.Object.create
|
||||
# Find with condition does not work since the resulting array promise is not updated for newly created records
|
||||
#lists: Qsupplier.App.List.find({state: 'active'})
|
||||
#orders: Qsupplier.App.Order.find({state: 'active'})
|
||||
#lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
|
||||
# use filter to create a scope on all the records
|
||||
#lists: @store.filter 'list', -> true
|
||||
lists: @store.all 'list'
|
||||
# mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
|
||||
#orders: @store.filter 'order', -> true
|
||||
orders: @store.all 'order'
|
||||
sections: @store.all 'section'
|
||||
setupController: (controller, model)->
|
||||
controller.set('model', model)
|
||||
#$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
|
||||
#controller.set 'lists', @store.all('list')
|
||||
#controller.set 'lists', Qsupplier.App.List.all() #.filterProperty('state', 'active')
|
||||
#controller.set 'orders', Qsupplier.App.Order.all()
|
||||
#controller.set 'lists', model.get('lists')
|
||||
#controller.set 'orders', model.get('orders')
|
||||
# Qsupplier.App.IndexRoute = Ember.Route.extend
|
||||
# model: (params, queryParams)->
|
||||
# Ember.Object.create
|
||||
# # Find with condition does not work since the resulting array promise is not updated for newly created records
|
||||
# #lists: Qsupplier.App.List.find({state: 'active'})
|
||||
# #orders: Qsupplier.App.Order.find({state: 'active'})
|
||||
# #lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
|
||||
# # use filter to create a scope on all the records
|
||||
# #lists: @store.filter 'list', -> true
|
||||
# lists: @store.all 'list'
|
||||
# # mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
|
||||
# #orders: @store.filter 'order', -> true
|
||||
# orders: @store.all 'order'
|
||||
# sections: @store.all 'section'
|
||||
# setupController: (controller, model)->
|
||||
# controller.set('model', model)
|
||||
# #$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
|
||||
# #controller.set 'lists', @store.all('list')
|
||||
# #controller.set 'lists', Qsupplier.App.List.all() #.filterProperty('state', 'active')
|
||||
# #controller.set 'orders', Qsupplier.App.Order.all()
|
||||
# #controller.set 'lists', model.get('lists')
|
||||
# #controller.set 'orders', model.get('orders')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
Qsupplier.App.SectionRoute = Ember.Route.extend
|
||||
model: (params) -> @store.findById 'section', params.section_id
|
||||
renderTemplate: ->
|
||||
@render 'section'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
h1=t 'models.plural.list'
|
||||
Qsupplier.App.ListDisplayDateSelector valueBinding="date"
|
||||
if lists
|
||||
if sorted_lists
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
@@ -12,7 +12,7 @@ if lists
|
||||
th.currentcy=t 'attributes.list.price'
|
||||
th.timestamp=t 'attributes.list.created_at'
|
||||
tbody
|
||||
each list in lists
|
||||
each list in sorted_lists
|
||||
tr
|
||||
td.state
|
||||
link-to 'list' list.id
|
||||
@@ -20,7 +20,7 @@ if lists
|
||||
td.boolean.needs_help=boolean list.needs_help
|
||||
td.boolean.needs_payment=boolean list.needs_payment
|
||||
td.timestamp=time list.closed_at
|
||||
td.table_number 7
|
||||
td.table_number= list.table.number
|
||||
td.currency=currency list.price
|
||||
td.timestamp=time list.created_at
|
||||
else
|
||||
|
||||
@@ -20,27 +20,18 @@
|
||||
Qsupplier.App.DropdownLink title="Action"
|
||||
ul
|
||||
li
|
||||
a{action addTables}
|
||||
span.section-add-tables-icon
|
||||
=t 'section.add_tables.button_label'
|
||||
a{action "addTables"}: span.section-add-tables-icon=t 'section.add_tables.button_label'
|
||||
li
|
||||
a{action arrangeTables}
|
||||
span.section-arrange-tables-icon
|
||||
=t 'section.arrange_tables.modal.title'
|
||||
a{action "arrangeTables"}: span.section-arrange-tables-icon=t 'section.arrange_tables.modal.title'
|
||||
li
|
||||
a href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}"
|
||||
span.table-qr-codes
|
||||
=t 'tables.qr_codes.link'
|
||||
a href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}": span.table-qr-codes=t 'tables.qr_codes.link'
|
||||
li
|
||||
/a.section-destroy href="{{route 'suppliers_section_path' id}}" data-method="delete" data-confirm="{{t 'helpers.links.are_you_sure' bare=true}}"
|
||||
a.section-destroy{action destroySection}
|
||||
span.section-remove-icon
|
||||
=t 'helpers.links.destroy'
|
||||
a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
|
||||
Ember.TextField valueBinding="title" class="section-edit-title-field"
|
||||
Qsupplier.App.NumberField valueBinding="width" class="dimension section-edit-width-field"
|
||||
span.fa.fa-lg.fa-times
|
||||
Qsupplier.App.NumberField valueBinding="height" class="dimension section-edit-height-field"
|
||||
a.section-normal-mode-button{ action finishEditable }: span
|
||||
a.section-normal-mode-button{ action "finishEditable" }: span
|
||||
else
|
||||
a.section-edit-mode-button{ action makeEditable }: span
|
||||
a.section-edit-mode-button{ action "makeEditable" }: span
|
||||
Qsupplier.App.SectionTablesView contentBinding="tables"
|
||||
|
||||
@@ -7,8 +7,8 @@ if table.active_list
|
||||
div.table-actions
|
||||
.title= table.number
|
||||
.table-action-row
|
||||
Qsupplier.App.MarkListHelpedButtonView content=table.active_list
|
||||
Qsupplier.App.CloseListButtonView content=table.active_list
|
||||
Qsupplier.App.MarkListHelpedButtonView contentBinding="table.active_list"
|
||||
Qsupplier.App.CloseListButtonView contentBinding="table.active_list"
|
||||
.table-action-row=currency table.active_list.total
|
||||
/.table-action-row
|
||||
a{action "editTable" table}: span.fa.fa-lg.fa-wrench
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
each table in tables
|
||||
Qsupplier.App.SectionTableView contentBinding="table"
|
||||
Qsupplier.App.SectionTableView content=table
|
||||
|
||||
@@ -4,4 +4,4 @@ Qsupplier.App.MarkListHelpedButtonView = Ember.View.extend
|
||||
classNameBindings: ['content.needs_help:show:hide']
|
||||
tagName: 'button'
|
||||
click: (e)->
|
||||
@get('content').is_helped()
|
||||
@get('content').then (l)->l.is_helped()
|
||||
|
||||
@@ -15,8 +15,9 @@ root.Qsupplier=
|
||||
list = order.get('list')
|
||||
list.get('orders').addRecord order
|
||||
if table = list.get('table')
|
||||
if table.get('active_list') isnt list
|
||||
table.set 'active_list', list
|
||||
if table.get('active_list')
|
||||
table.get('active_list').then (table_list)->
|
||||
table.set 'active_list', list if table_list isnt list
|
||||
, 200
|
||||
else if(e.event == 'list_needs_help')
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
|
||||
@@ -23,13 +23,13 @@ function t(path, vars){
|
||||
var result, m, translatable, isafety,replacable;
|
||||
var parts = path.split('.');
|
||||
var accessor = '$translations.'+$locale+'["' + parts.join('"]["')+ '"]';
|
||||
try{
|
||||
try{
|
||||
result = eval(accessor);
|
||||
} catch(err){
|
||||
} catch(err){
|
||||
result = parts[parts.length - 1].capitalize();
|
||||
}
|
||||
if(result == '') return '';
|
||||
if(!result) return parts[parts.length - 1].capitalize();
|
||||
if(!result) return parts[parts.length - 1].capitalize();
|
||||
$.each(vars, function(v, value){ result = result.replace('%{'+v+'}', value)});
|
||||
isafety = 0;
|
||||
while(result.indexOf('${') > -1){
|
||||
@@ -62,12 +62,12 @@ function setTranslations(selector){
|
||||
if(selector){
|
||||
$(selector).find('[data-t]').each(function(){$(this).html(t($(this).data('t'), $(this).data('tAttributes')))})
|
||||
$(selector).find('*[data-time]').each(function(){
|
||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:MM'))
|
||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:mm'))
|
||||
})
|
||||
}else{
|
||||
$('[data-t]').each(function(){$(this).html(t($(this).data('t'),$(this).data('tAttributes')))})
|
||||
$('*[data-time]').each(function(){
|
||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:MM'))
|
||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:mm'))
|
||||
})
|
||||
}
|
||||
$('.datepicker').datepicker("option", $.datepicker.regional[$locale])
|
||||
|
||||
@@ -70,14 +70,14 @@
|
||||
$(this).html t($(this).data("t"), $(this).data("tAttributes"))
|
||||
|
||||
selector.find("*[data-time]").each ->
|
||||
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:MM")
|
||||
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:mm")
|
||||
|
||||
else
|
||||
$("[data-t]").each ->
|
||||
$(this).html t($(this).data("t"), $(this).data("tAttributes"))
|
||||
|
||||
$("*[data-time]").each ->
|
||||
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:MM")
|
||||
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:mm")
|
||||
|
||||
# jQuery UI datepicker support
|
||||
$(".datepicker").datepicker "option", $.datepicker.regional[locale] if $.fn.datepicker
|
||||
|
||||
@@ -3,7 +3,7 @@ td.boolean
|
||||
&.needs_help
|
||||
.boolean-true
|
||||
@extend .fa
|
||||
@extend .fa-exclamation
|
||||
@extend .fa-bell
|
||||
&.needs_payment
|
||||
.boolean-true
|
||||
@extend .fa
|
||||
@@ -32,5 +32,3 @@ td.boolean
|
||||
padding: $padding
|
||||
border-top: 2px solid #444
|
||||
font-weight: bold
|
||||
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ module Suppliers
|
||||
end
|
||||
@lists.include_relation(:table)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @lists, each_serializer: SupplierListSerializer }
|
||||
end
|
||||
render json: @lists, each_serializer: SupplierListSerializer
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,21 @@ module Suppliers
|
||||
# GET /sections
|
||||
# GET /sections.json
|
||||
def index
|
||||
# render json: {} and return
|
||||
@sections = current_supplier.sections
|
||||
@sections.include_relation(:tables)
|
||||
@active_lists = List.active_for_supplier(current_supplier.id)
|
||||
@active_table_ids = @active_lists.map(&:table_id).compact
|
||||
for section in @sections
|
||||
for table in section.tables
|
||||
if active_list = @active_lists.find{|l| l.table_id == table.id}
|
||||
table.active_list = active_list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @sections, each_serializer: SupplierExtendedSectionSerializer }
|
||||
end
|
||||
# @active_lists = List.active_for_supplier(current_supplier.id)
|
||||
# @active_table_ids = @active_lists.map(&:table_id).compact
|
||||
# for section in @sections
|
||||
# for table in section.tables
|
||||
# if active_list = @active_lists.find{|l| l.table_id == table.id}
|
||||
# table.active_list = active_list
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
render json: @sections, each_serializer: SupplierExtendedSectionSerializer
|
||||
end
|
||||
|
||||
# GET /sections/1
|
||||
|
||||
@@ -142,6 +142,7 @@ class List
|
||||
set_price # should not be needed, but extra secure
|
||||
orders.map(&:close!) # close the connected orders
|
||||
self.state = 'closed'
|
||||
self.is_helped! if needs_help?
|
||||
self.user_requests_closing = false # if a user requested closing, not needed anymore
|
||||
self.closed_at = Time.now
|
||||
if save
|
||||
|
||||
+7
-1
@@ -129,7 +129,13 @@ class Order
|
||||
|
||||
#TODO fix me
|
||||
def close!
|
||||
self.state = 'closed' if placed? || active?
|
||||
|
||||
if placed? || active?
|
||||
decrement_counter = placed? ? 'placed' : 'in_process'
|
||||
self.state = 'closed'
|
||||
supplier.public_send "decrement_orders_#{decrement_counter}_count!"
|
||||
end
|
||||
|
||||
if save
|
||||
broadcast_user user.id, 'order_closed', id: id if user
|
||||
broadcast_supplier supplier_id, 'order_closed', id: id
|
||||
|
||||
@@ -58,6 +58,8 @@ class Supplier
|
||||
# Set all known counters to zero
|
||||
Qwaiter::Couchbase.flush_counters!
|
||||
|
||||
Qwaiter::Counter.connection.flush if Qwaiter::Counter.connection.respond_to?(:flush)
|
||||
|
||||
spec = Order.by_supplier_id_and_state(reduce: true, group_level: 2)
|
||||
reset_order_counters_with_spec spec
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class SupplierExtendedTableSerializer < Qwaiter::Serializer
|
||||
root 'table'
|
||||
embed :ids, include: true
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :active_list_id
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id#, :active_list_id
|
||||
|
||||
#def list_id
|
||||
#object.active_list_id || object.active_list.try(:id)
|
||||
|
||||
@@ -4,7 +4,7 @@ html lang="en"
|
||||
meta charset="utf-8"
|
||||
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
||||
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||
title= content_for?(:title) ? yield(:title) : application_title
|
||||
title= application_title
|
||||
= csrf_meta_tags
|
||||
|
||||
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
||||
|
||||
@@ -4,7 +4,7 @@ html lang="en"
|
||||
meta charset="utf-8"
|
||||
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
||||
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||
title Qwaiter
|
||||
title= application_title
|
||||
= stylesheet_link_tag "user/foundation/application"
|
||||
= javascript_include_tag "vendor/modernizr"
|
||||
= javascript_include_tag 'http://connect.facebook.net/en_US/all.js'
|
||||
|
||||
@@ -33,6 +33,7 @@ Feature: Supplier section view
|
||||
And I wait 0.5 seconds
|
||||
|
||||
When I click on the close list button in the section table table popup
|
||||
And confirm the supplier close list modal
|
||||
And I wait 1 second
|
||||
Then the section table should not have any active list markings anymore
|
||||
And the list should be marked as closed
|
||||
|
||||
@@ -21,6 +21,12 @@ step "I wait :number second/seconds" do |number|
|
||||
sleep number.to_f
|
||||
end
|
||||
|
||||
placeholder :number do
|
||||
match /[-+]?\d+(\.\d+)?/ do |number_string|
|
||||
number_string.to_f
|
||||
end
|
||||
end
|
||||
|
||||
step "I open the debugger" do
|
||||
binding.pry
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ step "I visit the supplier section path" do
|
||||
end
|
||||
|
||||
step "I visit the supplier last section path" do
|
||||
visit "/supplier/sections/#{@sections.last.id}"
|
||||
visit "/supplier#/sections/#{@sections.last.id}"
|
||||
end
|
||||
|
||||
step "I should be redirected to the supplier settings page" do
|
||||
@@ -20,5 +20,5 @@ step "I should be redirected to the supplier settings page" do
|
||||
end
|
||||
|
||||
step "I visit the supplier settings path" do
|
||||
visit supplier_settings_path
|
||||
visit "/supplier#/settings"
|
||||
end
|
||||
|
||||
@@ -27,7 +27,6 @@ step "the section table should be marked as in need of help" do
|
||||
end
|
||||
|
||||
step "the section table should not be marked as in need of help" do
|
||||
binding.pry
|
||||
table = page.find(".section-table-#{@table.id}")
|
||||
table['class'].should_not include 'needs_help'
|
||||
end
|
||||
|
||||
@@ -156,4 +156,12 @@ describe List do
|
||||
|
||||
describe 'product order creation'
|
||||
end
|
||||
|
||||
describe '#close!' do
|
||||
it 'removes the helped mark' do
|
||||
list_options[:needs_help] = true
|
||||
list.close!
|
||||
expect( list.needs_help? ).not_to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -153,4 +153,26 @@ describe Order do
|
||||
end
|
||||
end
|
||||
end
|
||||
describe '#close!' do
|
||||
describe 'counters' do
|
||||
before do
|
||||
# hack some initial values
|
||||
Qwaiter::Counter.set "supplier_counter:#{supplier.id}:orders_placed", 11
|
||||
Qwaiter::Counter.set "supplier_counter:#{supplier.id}:orders_in_process", 7
|
||||
end
|
||||
|
||||
it "decrements the orders_placed_count for when a placed order is closed" do
|
||||
order.close!
|
||||
supplier.orders_placed_count.should == 10
|
||||
supplier.orders_in_process_count.should == 7
|
||||
end
|
||||
|
||||
it "decrements the orders_in_process_count for when an active order is closed" do
|
||||
order_options[:state] = 'active'
|
||||
order.close!
|
||||
supplier.orders_placed_count.should == 11
|
||||
supplier.orders_in_process_count.should == 6
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+1953
-1333
File diff suppressed because it is too large
Load Diff
+4488
-2893
File diff suppressed because it is too large
Load Diff
+4
-11
File diff suppressed because one or more lines are too long
+20
-20
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user