From 968d042501b10965c084899dbc18d31ddac1478a Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Wed, 9 Sep 2015 19:11:46 +0200 Subject: [PATCH] JSON api serializers for suppliers --- app/assets/images/supplier/unknown-avatar.png | Bin 0 -> 1256 bytes .../dashboard/active-list.js.coffee | 3 ++ .../controllers/index_controller.js.coffee | 3 -- .../supplier/app/models/order.js.coffee | 9 ++-- .../supplier/app/models/user.js.coffee | 7 ++- .../routes/application_route.js.coffee.erb | 2 +- .../templates/dashboard/active-list.emblem | 14 +----- .../templates/dashboard/active-order.emblem | 6 +-- .../supplier/app/templates/index.emblem | 2 - .../supplier/base1-shared/active_lists.sass | 27 ----------- .../supplier/foundation1/_qconstants.sass | 1 + .../supplier/foundation1/application.sass | 2 +- .../foundation1/components/_buttons.sass | 3 ++ .../components/_product_categories.sass | 44 ------------------ .../components/_products_preview.sass | 19 -------- ...switcher.sass => _suppliers-switcher.sass} | 0 .../{components => resources}/_dashboard.sass | 24 +++++++++- .../_section_areas.sass | 0 .../_section_elements.sass | 0 .../_section_tables.sass | 0 .../_sections_header.sass | 0 app/controllers/suppliers/lists_controller.rb | 4 +- .../suppliers/suppliers_controller.rb | 12 ++++- app/models/user.rb | 2 +- app/serializers/product_variant_serializer.rb | 4 -- app/serializers/suppliers/order_serializer.rb | 1 + .../suppliers/product_serializer.rb | 3 +- .../suppliers/product_variant_serializer.rb | 4 ++ .../suppliers/section_element_serializer.rb | 3 +- .../suppliers/section_serializer.rb | 3 ++ .../user_extended_list_serializer.rb | 2 + config/locales/supplier.en.yml | 1 + config/locales/supplier.nl.yml | 1 + .../suppliers/order_serializer_spec.rb | 13 ++++++ ..._serializer.rb => list_serializer_spec.rb} | 0 ...serializer.rb => order_serializer_spec.rb} | 0 ...serializer.rb => table_serializer_spec.rb} | 0 37 files changed, 86 insertions(+), 133 deletions(-) create mode 100644 app/assets/images/supplier/unknown-avatar.png delete mode 100644 app/assets/stylesheets/supplier/base1-shared/active_lists.sass create mode 100644 app/assets/stylesheets/supplier/foundation1/components/_buttons.sass delete mode 100644 app/assets/stylesheets/supplier/foundation1/components/_product_categories.sass delete mode 100644 app/assets/stylesheets/supplier/foundation1/components/_products_preview.sass rename app/assets/stylesheets/supplier/foundation1/components/{suppliers-switcher.sass => _suppliers-switcher.sass} (100%) rename app/assets/stylesheets/supplier/foundation1/{components => resources}/_dashboard.sass (60%) rename app/assets/stylesheets/supplier/foundation1/{components => resources}/_section_areas.sass (100%) rename app/assets/stylesheets/supplier/foundation1/{components => resources}/_section_elements.sass (100%) rename app/assets/stylesheets/supplier/foundation1/{components => resources}/_section_tables.sass (100%) rename app/assets/stylesheets/supplier/foundation1/{components => resources}/_sections_header.sass (100%) delete mode 100644 app/serializers/product_variant_serializer.rb create mode 100644 app/serializers/suppliers/product_variant_serializer.rb create mode 100644 spec/serializers/suppliers/order_serializer_spec.rb rename spec/serializers/users/{list_serializer.rb => list_serializer_spec.rb} (100%) rename spec/serializers/users/{order_serializer.rb => order_serializer_spec.rb} (100%) rename spec/serializers/users/{table_serializer.rb => table_serializer_spec.rb} (100%) diff --git a/app/assets/images/supplier/unknown-avatar.png b/app/assets/images/supplier/unknown-avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..5616aab2cbee3bf94427c9376998f38c696a1ef8 GIT binary patch literal 1256 zcmVP)?I$j=q)A7mif6*tW zFHW6tyi_dqB0}mA6qth6K};ajFii-C1_{6S}71ubCM{ zXKx~x%|caG9B6LFp_UdXs&@;{vHLn%eq}{LG!j8@Ab>mr zxD}n_P76W^ZYLK}D6G2!q7~L*=(;1Nn}H#p$+~nRj&y*{QvtX-J)cHo1)|59DTgsY zt*vzjMDTdvj^_#WK@RaITmh*m)N=~FNagA2qk40N3IL+8*N7l>Ih@zlX) z?Ag1Q3#7KT7VXE5p;#=s*V!3kc-h~D;x3Aa zE#Hz|%b?!Zz*Vsv0il%Q#`SUh`28icwjaT3@4S82QznFf5CX>7U7cH!BwYTs7r&2B z;KVCEc*)-llSA-aAiAdEYVSpar=}oD5{ia_x`ukZ*x89g&$QsNefvNt-DumJzCD>( zz|C+N6Jyu0nqGk@iqLf(2M-^{nK#bDTccJNgc5>tAAf??mGu1!fGnfl*8s(Np2O{A($X2;nNpO{jp^_K<@k}hI=uVA`?kG5 zS0B03`yG~3DO>iI5CTf+hG!wxddp?Axb)2hlsi_J1tJInV$moL{cSzs`B-e*yIt;6p#+I|+?mu`N~K&o z5kd%7m(!LzFG~>9G?CBd;AX6^=PXBjOAxmCKG4n33cBS^)3Tnj&HWY6s)iqA9fT1+ z5K1YIcXc6~S#u4vh`z0000 "list-row-#{@get('list.id')}" + actions: + showList: (list)-> + @get('targetObject').transitionToRoute 'list', list diff --git a/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee index 56987228..e44e8349 100644 --- a/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee @@ -31,6 +31,3 @@ App.IndexController = Ember.Controller.extend actions: toggleDashboardLists: -> @set 'show_lists', !@get('show_lists') toggleDashboardOrders: ->@set 'show_orders', !@get('show_orders') - - showList: (id)-> - @transitionToRoute 'list', id diff --git a/app/assets/javascripts/supplier/app/models/order.js.coffee b/app/assets/javascripts/supplier/app/models/order.js.coffee index 8929bf2a..e32e4943 100644 --- a/app/assets/javascripts/supplier/app/models/order.js.coffee +++ b/app/assets/javascripts/supplier/app/models/order.js.coffee @@ -1,11 +1,12 @@ attr = DS.attr App.Order = DS.Model.extend state: attr('string') - list: DS.belongsTo('list') price: attr('number') - section: DS.belongsTo('section') - section_id: attr('string') - product_orders: DS.hasMany('product_order') + + list: DS.belongsTo('list', async: false) + section: DS.belongsTo('section', async: false) + product_orders: DS.hasMany('product_order', async: false) + user: DS.belongsTo 'user', async: false active: (-> @get('state') == 'active').property('state') delivered: (-> @get('state') == 'delivered').property('state') diff --git a/app/assets/javascripts/supplier/app/models/user.js.coffee b/app/assets/javascripts/supplier/app/models/user.js.coffee index c43e475f..77e2efbc 100644 --- a/app/assets/javascripts/supplier/app/models/user.js.coffee +++ b/app/assets/javascripts/supplier/app/models/user.js.coffee @@ -6,8 +6,7 @@ App.User= DS.Model.extend avatar: attr('string') list: DS.belongsTo('list') # in ember scope not many to many (yet) join_requests: DS.hasMany('join_request') - avatar_tag: (-> - return unless avatar = @get('avatar') + avatar_tag: Ember.computed 'avatar', 'name', -> + avatar = @get('avatar') || "#{$asset_path}/supplier/unknown-avatar.png" name = @get('name') - "#{name}".htmlSafe() - ).property('avatar', 'name') + "#{name}".htmlSafe() diff --git a/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb b/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb index a85b7f72..a3b0c0ff 100644 --- a/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb +++ b/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb @@ -17,7 +17,7 @@ App.ApplicationRoute = Ember.Route.extend #@sections = @store.findAll 'section' #Ember.RSVP.all([@product_categories, @sections]).then (results)=> @supplier.reload().then => - @store.findAll('list', state: 'active') #.then (lists) -> lists.invoke('get', 'table') + @store.query('list', state: 'active') #.then (lists) -> lists.invoke('get', 'table') #@lists = @store.peekAll 'list' # product_categories = controller.set 'product_categories', @store.peekAll('product_category') #@store.findAll 'order', state: 'active' included in list diff --git a/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem b/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem index 34a78154..8cd58f20 100644 --- a/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem +++ b/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem @@ -1,7 +1,6 @@ td.user-info.show-for-large-up - h3= list.users.length each list.users as |user| - = user.avatar_tag + = user.avatar_tag td.status-icons if list.needs_help span.icon.needs-help @@ -12,16 +11,7 @@ td.numeric.table_number= table-number-with-info list=list td.section_title: link-to 'section' list.table.section.id: span=list.table.section.title td.currency.total_list_amount=currency list.total td.actions - / if list.needs_help - button.mark-list-as-helped-button{ action "markListAsHelped" list.id} - span.fa-stack.fa-2x.fa-stack-sized - i.fa.fa-bell.fa-stack-small - i.fa.fa-ban.revoke - /= view "mark-list-helped-button" content=list = button-mark-list-helped content=list = button-remove-list-needs-payment content=list - /= view "remove-list-needs-payment" content=list - /= view "close-list-button" content=list = button-close-list content=list - - button.show-list.button{action "showList" list.id}: span + button.show-list.button{action "showList" list}: span diff --git a/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem b/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem index 44458e19..0f536b7f 100644 --- a/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem +++ b/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem @@ -1,9 +1,7 @@ -td.user-info.show-for-large-up - each order.list.users as |user| - = user.avatar_tag +td.user-info.show-for-large-up= order.user.avatar_tag td.status-icons if order.active - span.active-order.fa.fa-check.fa-lg + span.active-order td= order.display td.numeric.table_number= table-number-with-info list=order.list td.section_title= link-to 'section' order.list.table.section.id: span=order.list.table.section.title diff --git a/app/assets/javascripts/supplier/app/templates/index.emblem b/app/assets/javascripts/supplier/app/templates/index.emblem index 85d5dabc..6b31636a 100644 --- a/app/assets/javascripts/supplier/app/templates/index.emblem +++ b/app/assets/javascripts/supplier/app/templates/index.emblem @@ -28,8 +28,6 @@ th.actions tbody each active_lists as |list| - tr - td= list.users.length = dashboard-active-list list=list .page-header if active_orders.length diff --git a/app/assets/stylesheets/supplier/base1-shared/active_lists.sass b/app/assets/stylesheets/supplier/base1-shared/active_lists.sass deleted file mode 100644 index d58cbfa8..00000000 --- a/app/assets/stylesheets/supplier/base1-shared/active_lists.sass +++ /dev/null @@ -1,27 +0,0 @@ -.button-text - // Only icons for now - display: none -.active-orders-table - .status-icons - span - display: none - .active - .status-icons - .active-order - display: inline-block -.table-number-with-info - position: relative - .extra-list-info - // Facebook profiles - display: none - $extra-info-width: 220px - position: absolute - width: $extra-info-width - // 7px is padding + border, 5px is extra spacing - right: -$extra-info-width - 7px*2 - 5px - top: -7px*2 - padding: 4px - border: 3px solid #aaa - border-radius: 3px - background-color: white - text-align: left diff --git a/app/assets/stylesheets/supplier/foundation1/_qconstants.sass b/app/assets/stylesheets/supplier/foundation1/_qconstants.sass index 809d7c62..efdfe140 100644 --- a/app/assets/stylesheets/supplier/foundation1/_qconstants.sass +++ b/app/assets/stylesheets/supplier/foundation1/_qconstants.sass @@ -5,3 +5,4 @@ $wood: image-url('textures/theme1.jpg') $background-brown: #57351f $current-color: #fc3 $active-color: #fc3 +$button-spacing: 8px diff --git a/app/assets/stylesheets/supplier/foundation1/application.sass b/app/assets/stylesheets/supplier/foundation1/application.sass index 744813b2..e68f64de 100644 --- a/app/assets/stylesheets/supplier/foundation1/application.sass +++ b/app/assets/stylesheets/supplier/foundation1/application.sass @@ -1,5 +1,4 @@ //= require qtip -//= require_directory ../base1-shared //= require pickdate //= require fullcalendar // bourbon for animation @@ -13,6 +12,7 @@ @import ./qdisplays @import ./form_actions @import ./components/* +@import ./resources/* @import ./qsections @import ./section_tab_headers @import ./qlists diff --git a/app/assets/stylesheets/supplier/foundation1/components/_buttons.sass b/app/assets/stylesheets/supplier/foundation1/components/_buttons.sass new file mode 100644 index 00000000..4b4c6f29 --- /dev/null +++ b/app/assets/stylesheets/supplier/foundation1/components/_buttons.sass @@ -0,0 +1,3 @@ +.button-text + // Only icons for now + display: none diff --git a/app/assets/stylesheets/supplier/foundation1/components/_product_categories.sass b/app/assets/stylesheets/supplier/foundation1/components/_product_categories.sass deleted file mode 100644 index e0ff0bdf..00000000 --- a/app/assets/stylesheets/supplier/foundation1/components/_product_categories.sass +++ /dev/null @@ -1,44 +0,0 @@ -//DEPRICATED -#product-category-list - list-style: none - li - clear: both - margin-bottom: 8px - .name - padding: 5px 5px -#week_days-group - display: inline-block - .week-day-toggle - margin: 0 - &.active - // nothing for now - &.inactive - opacity: 0.4 -#full_day-controller - line-height: 34px - vertical-align: top - // height: 34px - display: inline-block - span - @extend .fa - @extend .fa-clock-o - margin: 0 10px - color: #444 - &.active - span - color: #f70 -#sub-day-container - display: inline-block - vertical-align: top - &.hide - display: none - select - width: 70px - margin-right: 14px - margin-bottom: 0 -.product-category-visible-never - @extend .fa - @extend .fa-times -.product-category-visible-always - @extend .fa - @extend .fa-circle-o-notch diff --git a/app/assets/stylesheets/supplier/foundation1/components/_products_preview.sass b/app/assets/stylesheets/supplier/foundation1/components/_products_preview.sass deleted file mode 100644 index 4e8911a0..00000000 --- a/app/assets/stylesheets/supplier/foundation1/components/_products_preview.sass +++ /dev/null @@ -1,19 +0,0 @@ -.products_preview-date - .products_preview-time-container - float: left - input - width: 120px -.products_preview-hour - float: left - margin-left: 10px - select - width: 70px - &:after - content: " :" -.products_preview-minute - float: left - margin-left: 10px - select - width: 70px -#products-table - width: 100% diff --git a/app/assets/stylesheets/supplier/foundation1/components/suppliers-switcher.sass b/app/assets/stylesheets/supplier/foundation1/components/_suppliers-switcher.sass similarity index 100% rename from app/assets/stylesheets/supplier/foundation1/components/suppliers-switcher.sass rename to app/assets/stylesheets/supplier/foundation1/components/_suppliers-switcher.sass diff --git a/app/assets/stylesheets/supplier/foundation1/components/_dashboard.sass b/app/assets/stylesheets/supplier/foundation1/resources/_dashboard.sass similarity index 60% rename from app/assets/stylesheets/supplier/foundation1/components/_dashboard.sass rename to app/assets/stylesheets/supplier/foundation1/resources/_dashboard.sass index bfdffe92..3bd257e4 100644 --- a/app/assets/stylesheets/supplier/foundation1/components/_dashboard.sass +++ b/app/assets/stylesheets/supplier/foundation1/resources/_dashboard.sass @@ -1,4 +1,9 @@ -$button-spacing: 8px +.active-orders-table + .status-icons + .active-order + @extend .fa + @extend .fa-check + @extend .fa-lg .dashboard-lists-header, .dashboard-orders-header cursor: pointer .icon @@ -36,3 +41,20 @@ $button-spacing: 8px span @extend .fa @extend .fa-list-alt + +.table-number-with-info + position: relative + .extra-list-info + // Facebook profiles + display: none + $extra-info-width: 220px + position: absolute + width: $extra-info-width + // 7px is padding + border, 5px is extra spacing + right: -$extra-info-width - 7px*2 - 5px + top: -7px*2 + padding: 4px + border: 3px solid #aaa + border-radius: 3px + background-color: white + text-align: left diff --git a/app/assets/stylesheets/supplier/foundation1/components/_section_areas.sass b/app/assets/stylesheets/supplier/foundation1/resources/_section_areas.sass similarity index 100% rename from app/assets/stylesheets/supplier/foundation1/components/_section_areas.sass rename to app/assets/stylesheets/supplier/foundation1/resources/_section_areas.sass diff --git a/app/assets/stylesheets/supplier/foundation1/components/_section_elements.sass b/app/assets/stylesheets/supplier/foundation1/resources/_section_elements.sass similarity index 100% rename from app/assets/stylesheets/supplier/foundation1/components/_section_elements.sass rename to app/assets/stylesheets/supplier/foundation1/resources/_section_elements.sass diff --git a/app/assets/stylesheets/supplier/foundation1/components/_section_tables.sass b/app/assets/stylesheets/supplier/foundation1/resources/_section_tables.sass similarity index 100% rename from app/assets/stylesheets/supplier/foundation1/components/_section_tables.sass rename to app/assets/stylesheets/supplier/foundation1/resources/_section_tables.sass diff --git a/app/assets/stylesheets/supplier/foundation1/components/_sections_header.sass b/app/assets/stylesheets/supplier/foundation1/resources/_sections_header.sass similarity index 100% rename from app/assets/stylesheets/supplier/foundation1/components/_sections_header.sass rename to app/assets/stylesheets/supplier/foundation1/resources/_sections_header.sass diff --git a/app/controllers/suppliers/lists_controller.rb b/app/controllers/suppliers/lists_controller.rb index 17af00b0..b301971f 100644 --- a/app/controllers/suppliers/lists_controller.rb +++ b/app/controllers/suppliers/lists_controller.rb @@ -19,13 +19,13 @@ module Suppliers else @lists = List.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25) end - @lists.include_relation(:table, :users, orders: {product_orders: :product}) + @lists.include_relation(:table, :users, orders: {user: nil, product_orders: :product}) render json: JSONAPI::Serializer.serialize(@lists, serializer: Suppliers::ListSerializer, is_collection: true, include: %w[ orders orders.list + orders.user orders.product_orders - orders.product_orders.order orders.product_orders.product users join_requests diff --git a/app/controllers/suppliers/suppliers_controller.rb b/app/controllers/suppliers/suppliers_controller.rb index d88aed22..5ed0e502 100644 --- a/app/controllers/suppliers/suppliers_controller.rb +++ b/app/controllers/suppliers/suppliers_controller.rb @@ -5,8 +5,16 @@ module Suppliers end def show - [current_supplier].include_relations(sections: :tables, product_categories: {products: :product_variants}) - render json: JSONAPI::Serializer.serialize(current_supplier, serializer: Suppliers::SupplierSerializer) #.new(current_supplier).as_json + current_supplier.sections.include_relations(:tables, :section_areas, :section_elements, product_categories: {products: :product_variants}) + render json: JSONAPI::Serializer.serialize(current_supplier, serializer: Suppliers::SupplierSerializer, include: %w[ + sections + sections.tables + sections.section_areas + sections.section_elements + product_categories + product_categories.products + product_categories.products.product_variants + ]) #.new(current_supplier).as_json end def update diff --git a/app/models/user.rb b/app/models/user.rb index d09ca01e..f87ec27a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -81,7 +81,7 @@ class User # This is the user name as it is shown to the supplier def supplier_name - auth_data['info']['name'] rescue I18n.t('user.unknown_supplier_name') + auth_data['info']['name'] rescue I18n.t('supplier.unknown_user_name') end # This is the user name as it is shown to other users diff --git a/app/serializers/product_variant_serializer.rb b/app/serializers/product_variant_serializer.rb deleted file mode 100644 index a6c72831..00000000 --- a/app/serializers/product_variant_serializer.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ProductVariantSerializer < Qwaiter::Serializer - root 'product_variant' - attributes :name -end diff --git a/app/serializers/suppliers/order_serializer.rb b/app/serializers/suppliers/order_serializer.rb index 30053c30..dd7506ca 100644 --- a/app/serializers/suppliers/order_serializer.rb +++ b/app/serializers/suppliers/order_serializer.rb @@ -4,5 +4,6 @@ class Suppliers::OrderSerializer has_one :list, serializer: Suppliers::ListSerializer has_many :product_orders, serializer: Suppliers::ProductOrderSerializer + has_one :user, serializer: Suppliers::UserSerializer end diff --git a/app/serializers/suppliers/product_serializer.rb b/app/serializers/suppliers/product_serializer.rb index 12b26120..e42d97d3 100644 --- a/app/serializers/suppliers/product_serializer.rb +++ b/app/serializers/suppliers/product_serializer.rb @@ -1,6 +1,6 @@ class Suppliers::ProductSerializer include Qwaiter::SupplierBaseSerializer - attributes :name, :price, :description, :code, :position, :visible, :active, :product_category_id + attributes :name, :price, :description, :code, :position, :visible, :active attribute :image do if object.image.present? {small: object.image.url(:small)} @@ -10,4 +10,5 @@ class Suppliers::ProductSerializer end has_many :product_variants, serializer: Suppliers::ProductVariantSerializer + has_one :product_category, serializer: Suppliers::ProductSerializer end diff --git a/app/serializers/suppliers/product_variant_serializer.rb b/app/serializers/suppliers/product_variant_serializer.rb new file mode 100644 index 00000000..b6255eba --- /dev/null +++ b/app/serializers/suppliers/product_variant_serializer.rb @@ -0,0 +1,4 @@ +class Suppliers::ProductVariantSerializer + include Qwaiter::SupplierBaseSerializer + attributes :name +end diff --git a/app/serializers/suppliers/section_element_serializer.rb b/app/serializers/suppliers/section_element_serializer.rb index 732c24d9..67a6a103 100644 --- a/app/serializers/suppliers/section_element_serializer.rb +++ b/app/serializers/suppliers/section_element_serializer.rb @@ -1,4 +1,5 @@ -class Suppliers::SectionElementSerializer < Qwaiter::Serializer +class Suppliers::SectionElementSerializer + include Qwaiter::SupplierBaseSerializer attributes :name, :box_width, :box_height, :dpm, :svg, :position_x, :position_y, :rotation has_one :section, serializer: Suppliers::SectionSerializer end diff --git a/app/serializers/suppliers/section_serializer.rb b/app/serializers/suppliers/section_serializer.rb index 9c25bce9..24ffbaf9 100644 --- a/app/serializers/suppliers/section_serializer.rb +++ b/app/serializers/suppliers/section_serializer.rb @@ -1,4 +1,7 @@ class Suppliers::SectionSerializer include Qwaiter::SupplierBaseSerializer attributes :title, :path, :width, :height + has_many :tables, serializer: Suppliers::TableSerializer + has_many :section_areas, serializer: Suppliers::SectionAreaSerializer + has_many :section_elements, serializer: Suppliers::SectionElementSerializer end diff --git a/app/serializers/user_extended_list_serializer.rb b/app/serializers/user_extended_list_serializer.rb index 6eea9d05..75c90ea6 100644 --- a/app/serializers/user_extended_list_serializer.rb +++ b/app/serializers/user_extended_list_serializer.rb @@ -5,6 +5,7 @@ #.merge(ActiveModel::ArraySerializer.new(list.supplier.product_categories, each_serializer: ProductCategorySerializer, root: :product_categories).as_json) #.merge(ActiveModel::ArraySerializer.new(list.orders, each_serializer: OrderSerializer, root: :orders).as_json) #end +=begin class UserExtendedListSerializer < Qwaiter::Serializer # user ids for facebook pictures self.root = :list @@ -30,3 +31,4 @@ class UserExtendedListSerializer < Qwaiter::Serializer true end end +=end diff --git a/config/locales/supplier.en.yml b/config/locales/supplier.en.yml index 7af48cbc..15e8741c 100644 --- a/config/locales/supplier.en.yml +++ b/config/locales/supplier.en.yml @@ -248,3 +248,4 @@ en: link: My schedule schedule: title: Schedule for %{name} + unknown_user_name: "?" diff --git a/config/locales/supplier.nl.yml b/config/locales/supplier.nl.yml index 4a111eee..04f3a5b6 100644 --- a/config/locales/supplier.nl.yml +++ b/config/locales/supplier.nl.yml @@ -251,3 +251,4 @@ nl: link: Mijn schema schedule: title: Schema voor %{name} + unknown_user_name: "?" diff --git a/spec/serializers/suppliers/order_serializer_spec.rb b/spec/serializers/suppliers/order_serializer_spec.rb new file mode 100644 index 00000000..214ee604 --- /dev/null +++ b/spec/serializers/suppliers/order_serializer_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe Suppliers::OrderSerializer, type: :serializer do + it "works" do + user = create :user + order = create :order, user: user + order.product_orders # preload empty + result = nil + expect{ result = JSONAPI::Serializer.serialize order, serializer: described_class, include: %w[user user.order] }.not_to perform_any_queries + result[:included].size.should eq 4 + end + +end diff --git a/spec/serializers/users/list_serializer.rb b/spec/serializers/users/list_serializer_spec.rb similarity index 100% rename from spec/serializers/users/list_serializer.rb rename to spec/serializers/users/list_serializer_spec.rb diff --git a/spec/serializers/users/order_serializer.rb b/spec/serializers/users/order_serializer_spec.rb similarity index 100% rename from spec/serializers/users/order_serializer.rb rename to spec/serializers/users/order_serializer_spec.rb diff --git a/spec/serializers/users/table_serializer.rb b/spec/serializers/users/table_serializer_spec.rb similarity index 100% rename from spec/serializers/users/table_serializer.rb rename to spec/serializers/users/table_serializer_spec.rb