@@ -580,6 +580,7 @@ class PostsController < BaseController
580580
581581 class SpecialError < StandardError ; end
582582 class SubSpecialError < PostsController ::SpecialError ; end
583+ class SerializeError < StandardError ; end
583584
584585 # This is used to test that classes that are whitelisted are reraised by
585586 # the operations dispatcher.
@@ -600,6 +601,20 @@ def handle_exceptions(e)
600601 def self . set_callback_message ( error )
601602 @callback_message = "Sent from method"
602603 end
604+
605+ def resource_serializer_klass
606+ PostSerializer
607+ end
608+ end
609+
610+ class PostSerializer < JSONAPI ::ResourceSerializer
611+ def initialize ( *)
612+ if $PostSerializerRaisesErrors
613+ raise PostsController ::SerializeError
614+ else
615+ super
616+ end
617+ end
603618end
604619
605620class CommentsController < JSONAPI ::ResourceController
@@ -980,12 +995,12 @@ def title=(title)
980995 }
981996
982997 filter :search ,
983- verify : -> ( values , context ) {
998+ verify : -> ( values , context ) {
984999 values . all? { |v | ( v . is_a? ( Hash ) || v . is_a? ( ActionController ::Parameters ) ) } && values
985- } ,
986- apply : -> ( records , values , _options ) {
987- records . where ( title : values . first [ 'title' ] )
988- }
1000+ } ,
1001+ apply : -> ( records , values , _options ) {
1002+ records . where ( title : values . first [ 'title' ] )
1003+ }
9891004
9901005 def self . updatable_fields ( context )
9911006 super ( context ) - [ :author , :subject ]
@@ -1252,7 +1267,7 @@ def subject
12521267
12531268 def custom_links ( options )
12541269 {
1255- link_to_external_api : "http://external-api.com/posts/#{ created_at . year } /#{ created_at . month } /#{ created_at . day } -#{ subject . gsub ( ' ' , '-' ) } "
1270+ link_to_external_api : "http://external-api.com/posts/#{ created_at . year } /#{ created_at . month } /#{ created_at . day } -#{ subject . gsub ( ' ' , '-' ) } "
12561271 }
12571272 end
12581273end
@@ -1513,28 +1528,28 @@ class PurchaseOrderResource < JSONAPI::Resource
15131528
15141529 has_one :customer
15151530 has_many :line_items , relation_name : -> ( options = { } ) {
1516- context = options [ :context ]
1517- current_user = context ? context [ :current_user ] : nil
1518-
1519- unless current_user && current_user . book_admin
1520- :line_items
1521- else
1522- :admin_line_items
1523- end
1524- } ,
1531+ context = options [ :context ]
1532+ current_user = context ? context [ :current_user ] : nil
1533+
1534+ unless current_user && current_user . book_admin
1535+ :line_items
1536+ else
1537+ :admin_line_items
1538+ end
1539+ } ,
15251540 reflect : false
15261541
15271542 has_many :order_flags , acts_as_set : true ,
15281543 relation_name : -> ( options = { } ) {
1529- context = options [ :context ]
1530- current_user = context ? context [ :current_user ] : nil
1531-
1532- unless current_user && current_user . book_admin
1533- :order_flags
1534- else
1535- :admin_order_flags
1536- end
1537- }
1544+ context = options [ :context ]
1545+ current_user = context ? context [ :current_user ] : nil
1546+
1547+ unless current_user && current_user . book_admin
1548+ :order_flags
1549+ else
1550+ :admin_order_flags
1551+ end
1552+ }
15381553 end
15391554
15401555 class OrderFlagResource < JSONAPI ::Resource
0 commit comments