upgrade refactor

This commit is contained in:
2016-06-02 14:40:30 +02:00
parent 1acd200408
commit eb368a31ca
25 changed files with 36 additions and 30 deletions
@@ -40,8 +40,8 @@ App.Order = DS.Model.extend
display_with_table: (->
table = t('models.table').toLowerCase()
"#{@get('display')} #{table} #{@get('list.table.number')}".htmlSafe()
).property('display', 'list.table.number')
"#{@get('display')} #{table} #{@get('list.table.table_number')}".htmlSafe()
).property('display', 'list.table.table_number')
display_tag: (->
"<span class='display order-display order-#{@get('id')} #{@get('state')}'><span class='pre-display'></span>#{@get('display')}<span class='post-display'></span></span>".htmlSafe()
@@ -18,3 +18,4 @@ App.Table = DS.Model.extend
# Casted number to use in sortBy because a numberField will
# set property number to string value (TablesIndexController)
casted_number: (-> parseInt(@get('number'))).property('number')
table_number: Ember.computed.alias('number')
@@ -14,7 +14,7 @@ App.Router.map ->
@resource 'list', path: ':list_id'
@route 'employees'
@route 'employee', path: '/employees/:employee_id'
@route 'page', path: 'pages/:page_id'
@resource 'page', path: 'pages/:page_id'
@route 'orders-display' # chromecast etc
@route 'menu'
@route 'settings'
@@ -121,7 +121,7 @@ App.ApplicationRoute = Ember.Route.extend
if list = @store.peekRecord('list', data.id)
list.isNeedingHelp()
return if @get('globals.active_section.id') and list.get('section.id') isnt @get('globals.active_section.id')
@set 'globals.flash_message', t('table.needs_help.flash_message', number: list.get('table.number') || -1)
@set 'globals.flash_message', t('table.needs_help.flash_message', number: list.get('table.table_number') || -1)
try ion.sound.play 'bell_ring'
list_needs_payment: (data) ->
if list = @store.peekRecord('list', data.id)
@@ -1 +1 @@
= table-number list.table.number
= table-number list.table.table_number
@@ -5,7 +5,7 @@
span.icon.needs-help
if list.needs_payment
span.icon.needs-payment
span.table-number= table-number list.table.number
span.table-number= table-number list.table.table_number
= link-to 'section' list.table.section class="link-to-section"
span=list.table.section.title
span.currency=currency list.total
@@ -4,7 +4,7 @@
if order.active
span.active-order
span.order-display= order.display
span.table-number= table-number order.list.table.number
span.table-number= table-number order.list.table.table_number
= link-to 'section' order.list.table.section class="link-to-section"
span=order.list.table.section.title
span.currency=currency order.total
@@ -11,7 +11,7 @@ if list.closed_at
if list.active
.display-row
.display-label=t 'models.section'
.display-field= list.table.section.title
.display-field= link-to "section" list.table.section: list.table.section.title
.display-row
.display-label=t 'models.table'
.display-field
@@ -13,7 +13,7 @@ else
span.boolean.needs-payment=boolean list.needs_payment
span.timestamp.created_at= time list.created_at
span.state= state 'list' list.state
span.table-number= table-number list.table.number
span.table-number= table-number list.table.table_number
span.currency= currency list.price
.row.list-row-total: .small-12.columns
span.total-sentence= t 'lists.index.total_sentence'
@@ -47,7 +47,7 @@ else
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= list.table.number
td.table_number= list.table.table_number
td.currency=currency list.price
td.timestamp=time list.created_at
tfoot
@@ -1,10 +1,10 @@
h4=t 'modal.change_list_table.subtitle' current_table_number=model.table.number
h4=t 'modal.change_list_table.subtitle' current_table_number=model.table.table_number
= users-buttons users=model.users
each sections as |section|
h3= section.title
ul.change-list-table-section-tables
each section.sorted_tables as |table|
unless table.active_list
li: a{action "moveToTable" table}= table-number table.number
li: a{action "moveToTable" table}= table-number table.table_number
hr
button.modal-close{action "close"}=t 'modal.change_list_table.close_button'
@@ -1,6 +1,6 @@
p=t 'table.modal.body_header'
.form-row.number
.form-label=t 'attributes.table.number'
.form-label=t 'attributes.table.table_number'
.form-field= number-field numericValue=model.number
.form-row.section
.form-label=t 'models.section'
@@ -1,4 +1,4 @@
.table-number= table.number
.table-number= table.table_number
unless section.editmode
.status-icons
span.needs_payment
@@ -6,7 +6,7 @@ unless section.editmode
span.active_order
if table.active_list
div.table-actions
.title= table.number
.title= table.table_number
if table.active_list
.table-action-row
/= view "mark-list-helped-button" tableBinding="table.active_list"
@@ -1,9 +1,9 @@
.row: .small-12.columns
h2.main-section-header=t 'models.table'
.display-row
.display-label= t 'attributes.table.number'
.display-label= t 'attributes.table.table_number'
.display-field
span= table.number
span= table.table_number
if table.section
.display-row
.display-label=t 'models.section'
@@ -1,3 +1,3 @@
.number= list.table.number
.number= list.table.table_number
.extra-list-info
span.loading.medium
@@ -4,14 +4,14 @@
table.table
thead
tr
th=t 'attributes.table.number'
th=t 'attributes.table.table_number'
th.link=t 'models.section'
/th.timestamp= t 'attributes.table.created_at'
th.actions=t 'helpers.actions.title'
tbody
each tables as |table|
tr
td= link-to 'table' table: span= table.number
td= link-to 'table' table: span= table.table_number
td.link
if table.section
= link-to 'section' table.section
+1 -1
View File
@@ -22,6 +22,7 @@ class NewSuppliersController < ApplicationController
sign_in @new_supplier.employee
if @new_supplier.employee.suppliers.size < 2
session[:supplier_id] = @new_supplier.employee.suppliers.first.try(:id)
redirect_to supplier_root_path
else
render "choose_supplier"
end
@@ -29,7 +30,6 @@ class NewSuppliersController < ApplicationController
else
save_new_supplier
end
end
def choose_supplier
@@ -12,7 +12,7 @@ module Suppliers
rescue_from CanCan::AccessDenied do |exception|
respond_to do |format|
format.html { redirect_to root_path, alert: 'Action forbidden'}
format.json { render json: {}, status: :forbidden }
format.json { render json: {errors: "403 Forbidden"}, status: :forbidden }
end
end
@@ -1,6 +1,6 @@
module Suppliers
class PagesController < Suppliers::ApplicationController
prepend_before_action :find_page, only: [:show]
before_action :find_page, only: [:show]
def index
@pages = Page.all_for_suppliers(locale: params[:locale])
render json: @pages
+2 -1
View File
@@ -34,7 +34,7 @@ class NewSupplier
return true if current_employee.present?
return false unless email.present? and password.present?
existing_employee = Employee.find_by_email email
if existing_employee.valid_password?(password)
if existing_employee.try(:valid_password?, password)
@employee = existing_employee
return true
end
@@ -60,6 +60,7 @@ class NewSupplier
return if @employee = current_employee
if Employee.count_by_email(email) > 0
employee = Employee.find_by_email(email)
# Login employee when valid password is given for signup
if employee.valid_password? password
@employee = employee
else
+1
View File
@@ -1,3 +1,4 @@
require 'sucker_punch/async_syntax' # remove for rails >= 5
Rails.application.configure do
config.active_job.queue_adapter = :sucker_punch
end
+1 -1
View File
@@ -87,7 +87,7 @@ en:
password: Password
password_confirmation: Password confirmation
table:
number: Number
table_number: Number
from_number: From number
to_number: To number
created_at: Created
+1 -1
View File
@@ -85,7 +85,7 @@ nl:
password: Wachtwoord
password_confirmation: Nogmaals wachtwoord
table:
number: Nummer
table_number: Nummer
from_number: Vanaf nummer
to_number: Tot nummer
created_at: Aangemaakt
+4 -2
View File
@@ -37,7 +37,8 @@ Feature: A supplier can sign up
When I visit the supplier signup path
And fill in the supplier signup form with an existing supplier name
And click on the supplier signup submit button
Then the new supplier signup for should have an error on 'supplier_name'
#Then the new supplier signup for should have an error on 'supplier_name' # no new supplier
Then the supplier should be redirected to the root path
@javascript
Scenario: Existing non signed in employee creates existing supplier name
@@ -46,7 +47,8 @@ Feature: A supplier can sign up
And fill in the supplier signup form with existing employee credentials
And fill in the supplier signup form with an existing supplier name
And click on the supplier signup submit button
Then the new supplier signup for should have an error on 'supplier_name'
#Then the new supplier signup for should have an error on 'supplier_name'
Then the supplier should be redirected to the root path
#Scenarios
#- non existing non signed in employee
#- existing non signed in employee
+2 -1
View File
@@ -16,7 +16,8 @@ describe NewSupplier do
subject.errors[:password_confirmation].should be_present
end
it "does not create a supplier when the name is already taken" do
# This is tested with acceptance tests since part of this logic is inside the controller
xit "does not create a supplier when the name is already taken" do
create :supplier, name: 'New suppy'
expect{ subject.save }.not_to change{ Supplier.count }
subject.errors[:supplier_name].should be_present
+1 -1
View File
@@ -23,7 +23,7 @@ Devise.stretches = 1
#Capybara.javascript_driver = :webkit
#Capybara.javascript_driver = :poltergeist
Capybara.javascript_driver = :selenium
Capybara.default_wait_time = 5 # ember needs more time than the default of 2
Capybara.default_max_wait_time = 5 # ember needs more time than the default of 2
Capybara.server_port = 62625
Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
WebMock.disable_net_connect!(allow_localhost: true)