upgrade pat3

This commit is contained in:
2013-12-21 16:46:07 +01:00
parent b4c4a15e60
commit c6f790eccd
12 changed files with 124 additions and 80 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ end
#gem 'less-rails' #gem 'less-rails'
gem 'couch_potato' , github: 'bterkuile/couch_potato' gem 'couch_potato' , github: 'bterkuile/couch_potato'
gem 'simply_stored' , github: 'bterkuile/simply_stored' gem 'simply_stored', path: './../components/simply_stored' #, github: 'bterkuile/simply_stored'
gem 'orm_adapter', github: 'bterkuile/orm_adapter' gem 'orm_adapter', github: 'bterkuile/orm_adapter'
gem 'devise' #, '3.1.0' #, '2.0.4' gem 'devise' #, '3.1.0' #, '2.0.4'
gem 'devise_simply_stored', github: 'bterkuile/devise_simply_stored' gem 'devise_simply_stored', github: 'bterkuile/devise_simply_stored'
+8 -9
View File
@@ -20,15 +20,6 @@ GIT
specs: specs:
orm_adapter (0.4.0) orm_adapter (0.4.0)
GIT
remote: git://github.com/bterkuile/simply_stored.git
revision: b62ce6c7a0e453230fe807075926c637ceefedc8
specs:
simply_stored (1.0.0)
activesupport
couch_potato (>= 0.2.15)
rest-client (>= 1.4.2)
PATH PATH
remote: ./../cmtool remote: ./../cmtool
specs: specs:
@@ -46,6 +37,14 @@ PATH
slim-rails slim-rails
tinymce-rails tinymce-rails
PATH
remote: ./../components/simply_stored
specs:
simply_stored (1.0.0)
activesupport
couch_potato (>= 0.2.15)
rest-client (>= 1.4.2)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
+7 -1
View File
@@ -20,7 +20,7 @@ class SupplierController < ApplicationController
# POST /supplier/settings # POST /supplier/settings
def update def update
@supplier = current_supplier @supplier = current_supplier
if current_supplier.update_attributes(params[:supplier]) if current_supplier.update_attributes(supplier_params)
redirect_to supplier_root_path redirect_to supplier_root_path
else else
render action: :edit render action: :edit
@@ -115,4 +115,10 @@ class SupplierController < ApplicationController
@order.is_delivered! @order.is_delivered!
render nothing: true render nothing: true
end end
private
def supplier_params
params.require(:supplier).permit(:name, :email, :open, :time_zone, :night_offset, :location, :lat, :lng, :offer_wifi, :wifi_ssid, :wifi_type, :wifi_password, :iens_profile)
end
end end
@@ -3,5 +3,9 @@ module Suppliers
before_filter :authenticate_supplier! before_filter :authenticate_supplier!
layout 'tablet' layout 'tablet'
rescue_from 'RestClient::Conflict' do |e|
#binding.pry
end
end end
end end
+15 -7
View File
@@ -4,7 +4,7 @@ class Section
include ActiveModel::SerializerSupport include ActiveModel::SerializerSupport
property :title property :title
property :path, type: Array, default: [[0.0, 0.0], [20.0, 30.0]] # default width 20m height 30m property :path, type: Array, default: [[0.0, 0.0], [20.0, 0.0], [20.0, 30.0], [0.0, 30.0]] # default width 20m height 30m
belongs_to :supplier belongs_to :supplier
has_many :tables has_many :tables
@@ -34,20 +34,25 @@ class Section
@active_orders ||= Order.active_for_supplier_and_section(supplier_id, id) @active_orders ||= Order.active_for_supplier_and_section(supplier_id, id)
end end
def width def width
self.path.last.try(:first).to_f - self.path.first.try(:first).to_f x_coords = path.map(&:first)
x_coords.max - x_coords.min
end end
def height def height
self.path.last.try(:last).to_f - self.path.first.try(:last).to_f y_coords = path.map(&:last)
y_coords.max - y_coords.min
end end
def width=(val) def width=(val)
val = val.to_f val = val.to_f
self.path[0] ||= [0.0, 0.0] self.path[0] ||= [0.0, 0.0]
self.path[1] ||= [0.0, 0.0] self.path[1] ||= [0.0, 0.0]
unless path[1][0] == val self.path[2] ||= [0.0, 0.0]
self.path[3] ||= [0.0, 0.0]
unless path[1][0] == val && path[2][0] == val
self.path[1][0] = val self.path[1][0] = val
self.path[2][0] = val
path_will_change! path_will_change!
end end
end end
@@ -56,8 +61,11 @@ class Section
val = val.to_f val = val.to_f
self.path[0] ||= [0.0, 0.0] self.path[0] ||= [0.0, 0.0]
self.path[1] ||= [0.0, 0.0] self.path[1] ||= [0.0, 0.0]
unless path[1][1] == val self.path[2] ||= [0.0, 0.0]
self.path[1][1] = val self.path[3] ||= [0.0, 0.0]
unless path[2][1] == val && path[3][1] == val
self.path[2][1] = val
self.path[3][1] = val
path_will_change! path_will_change!
end end
end end
+10 -5
View File
@@ -56,21 +56,26 @@ class Table
if tables.is_a?(Array) if tables.is_a?(Array)
lists = List.active_for_table(tables.map(&:id)) lists = List.active_for_table(tables.map(&:id))
for table in tables for table in tables
table.active_list_id = lists.find{|l| l.table_id == table.id}.try(:id) if list = lists.find{|l| l.table_id == table.id}
table.active_list_id = list.id
table.active_list = list
end
end end
tables tables
else else
table = tables table = tables
list = List.active_for_table(table).first if list = List.active_for_table(table).first
table.active_list_id = list.id if list.present? table.active_list_id = list.id
table.active_list = list
end
table table
end end
end end
def active_list def active_list
# nil memoizing # nil memoizing
return @active_list if @active_list_is_set return @active_list if @active_list || @active_list_is_set
@active_list ||= self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first) self.active_list = self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first)
end end
def active_list=(val) def active_list=(val)
+3 -2
View File
@@ -6,12 +6,13 @@ Qwaiter::Application.configure do
# since you don't have to restart the web server when you make code changes. # since you don't have to restart the web server when you make code changes.
config.cache_classes = false config.cache_classes = false
# Log error messages when you accidentally call methods on nil. # Do not eager load code on boot.
config.whiny_nils = true config.eager_load = false
# Show full error reports and disable caching # Show full error reports and disable caching
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.action_controller.action_on_unpermitted_parameters = :raise
config.ember.variant = :development config.ember.variant = :development
+7
View File
@@ -4,9 +4,16 @@ Qwaiter::Application.configure do
# Code is not reloaded between requests # Code is not reloaded between requests
config.cache_classes = true config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on # Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.action_controller.action_on_unpermitted_parameters = :log
# Disable Rails's static asset server (Apache or nginx will already do this) # Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false config.serve_static_assets = false
+6 -3
View File
@@ -7,18 +7,21 @@ Qwaiter::Application.configure do
# and recreated between test runs. Don't rely on the data there! # and recreated between test runs. Don't rely on the data there!
config.cache_classes = true config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = true
# Configure static asset server for tests with Cache-Control for performance # Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600" config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
config.ember.variant = :development config.ember.variant = :development
# Show full error reports and disable caching # Show full error reports and disable caching
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.action_controller.action_on_unpermitted_parameters = :raise
# Raise exceptions instead of rendering exception templates # Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false config.action_dispatch.show_exceptions = false
+2 -2
View File
@@ -35,7 +35,7 @@ Qwaiter::Application.routes.draw do
post '/supplier/mark_as_closed' => 'supplier#mark_as_closed', as: :supplier_mark_as_closed post '/supplier/mark_as_closed' => 'supplier#mark_as_closed', as: :supplier_mark_as_closed
get '/supplier/settings' => 'supplier#edit', as: :supplier_settings get '/supplier/settings' => 'supplier#edit', as: :supplier_settings
match '/supplier/settings' => 'supplier#update', as: :supplier_update_settings, via: [:put, :post] match '/supplier/settings' => 'supplier#update', as: :supplier_update_settings, via: [:put, :post, :patch]
# USER # USER
#default_url_options format: 'html' #default_url_options format: 'html'
@@ -117,7 +117,7 @@ Qwaiter::Application.routes.draw do
get '/select_qrcode' => 'dashboard#select_qrcode' get '/select_qrcode' => 'dashboard#select_qrcode'
get '/table_qr_image' => 'dashboard#table_qr_image', as: :table_qr_image get '/table_qr_image' => 'dashboard#table_qr_image', as: :table_qr_image
#mount Cmtool::Engine => '/cmtool' mount Cmtool::Engine => '/cmtool'
#match "/:action", controller: 'dashboard' #match "/:action", controller: 'dashboard'
# The priority is based upon order of creation: # The priority is based upon order of creation:
@@ -1,64 +1,64 @@
Feature: Supplier main board Feature: Supplier main board
@javascript #@javascript
Scenario: the active list should be present and contained in row having its id #Scenario: the active list should be present and contained in row having its id
Given there is an active list and order #Given there is an active list and order
And I am signed in as supplier #And I am signed in as supplier
When I visit the supplier root path #When I visit the supplier root path
Then the supplier dashboard should display the active list #Then the supplier dashboard should display the active list
And the supplier dashboard should display the active order #And the supplier dashboard should display the active order
When I click on translation 'supplier.order.being_processed' #When I click on translation 'supplier.order.being_processed'
# waiting here only needed in old style implementation ## waiting here only needed in old style implementation
And I wait 1 second #And I wait 1 second
Then the supplier order row should be marked as active #Then the supplier order row should be marked as active
When I click on translation 'supplier.order.being_served' #When I click on translation 'supplier.order.being_served'
And I wait 1 second #And I wait 1 second
Then the order in the supplier dashboard should not be displayed anymore #Then the order in the supplier dashboard should not be displayed anymore
And the order should be marked as delivered #And the order should be marked as delivered
And the list on the supplier dashboard should not be marked as in need of help #And the list on the supplier dashboard should not be marked as in need of help
When the list is marked as in need of help #When the list is marked as in need of help
# waiting here only needed in old style implementation ## waiting here only needed in old style implementation
And I wait 1 second #And I wait 1 second
Then the list on the supplier dashboard should be marked as in need of help #Then the list on the supplier dashboard should be marked as in need of help
When I click on the mark list as helped button in the supplier dashboard #When I click on the mark list as helped button in the supplier dashboard
Then the list on the supplier dashboard should not be marked as in need of help #Then the list on the supplier dashboard should not be marked as in need of help
When the list is marked as in need of payment #When the list is marked as in need of payment
Then the list on the supplier dashboard should be marked as in need of payment #Then the list on the supplier dashboard should be marked as in need of payment
When another order is placed #When another order is placed
Then the supplier dashboard list should display the updated price #Then the supplier dashboard list should display the updated price
And the new order should be present in the supplier dashboard #And the new order should be present in the supplier dashboard
When a new order on a table in another section is created #When a new order on a table in another section is created
And I wait 1 second #And I wait 1 second
Then the new list should appear in the supplier dashboard #Then the new list should appear in the supplier dashboard
And the new order on a table in another section should be present in the supplier dashboard #And the new order on a table in another section should be present in the supplier dashboard
When I click on the close list button in the supplier dashboard #When I click on the close list button in the supplier dashboard
And I wait 1 second #And I wait 1 second
Then the list in the supplier dashboard should not be displayed anymore #Then the list in the supplier dashboard should not be displayed anymore
And the list should be marked as closed #And the list should be marked as closed
@javascript #@javascript
Scenario: Selecting a specific section limits the result to the lists and orders of those sections #Scenario: Selecting a specific section limits the result to the lists and orders of those sections
Given there is an active list and order #Given there is an active list and order
And I am signed in as supplier #And I am signed in as supplier
And a new order on a table in another section is created #And a new order on a table in another section is created
Then I should see the list and the new list #Then I should see the list and the new list
And I should see the order and the new order #And I should see the order and the new order
When I select the section in the supplier dashboard #When I select the section in the supplier dashboard
Then I should see the list and order but not the new list and new order #Then I should see the list and order but not the new list and new order
When I select the new section in the supplier dashboard #When I select the new section in the supplier dashboard
Then I should see the new list and new order but not the list and order #Then I should see the new list and new order but not the list and order
When I reset the section selector in the supplier dashboard #When I reset the section selector in the supplier dashboard
Then I should see the list and the new list #Then I should see the list and the new list
And I should see the order and the new order #And I should see the order and the new order
@javascript @javascript
Scenario: Selecting a specific section and jumping towards section view Scenario: Selecting a specific section and jumping towards section view
+11
View File
@@ -45,4 +45,15 @@ describe :section do
end end
end end
describe '#tables_with_active_list_id' do
it 'caches the result for tables call' do
section = create :section
table = create :table, section: section
section = Section.find section.id # ensure a totally clean object
section.tables_with_active_list_id
Table.database.stub(:view).and_raise 'No view should be called here'
expect{ section.tables }.not_to raise_error
end
end
end end