Skip to content

Commit

Permalink
chore: ignore page property when determining if decorator is for a co…
Browse files Browse the repository at this point in the history
…llection or not
  • Loading branch information
bethesque committed Jun 19, 2023
1 parent 65f66ad commit 7dbf5be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/api/decorators/base_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.eager_load_associations
# Returns true if this class is a decorator for a collection
# @return [true, false]
def self.is_collection_resource?
representable_attrs_without_links = representable_attrs.to_h.without("links")
representable_attrs_without_links = representable_attrs.to_h.without("links", "page")
representable_attrs_without_links.size == 1 &&
representable_attrs_without_links.values.first[:collection] &&
representable_attrs_without_links.values.first[:extend]
Expand All @@ -64,7 +64,7 @@ def self.embedded_and_collection_attribute_names

# @return [Class] The decorator class used to decorate the items in the collection
def self.collection_item_decorator_class
representable_attrs.to_h.without("links").values.first[:extend].call
representable_attrs.to_h.without("links", "page").values.first[:extend].call
end
private_class_method :collection_item_decorator_class
end
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/pact_broker/api/decorators/base_decorator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
require "pact_broker/api/decorators/base_decorator"
require "pact_broker/api/decorators/pagination_links"

module PactBroker
module Api
module Decorators
describe BaseDecorator do
class TestItemDecorator < BaseDecorator
include PactBroker::Api::Decorators::PaginationLinks

collection :children
property :foo, embedded: true

property :bar do
property :name
end

property :other
end

Expand Down

0 comments on commit 7dbf5be

Please sign in to comment.