diff --git a/lib/graphiti/resource/polymorphism.rb b/lib/graphiti/resource/polymorphism.rb index b4ce54de..bc2bfd78 100644 --- a/lib/graphiti/resource/polymorphism.rb +++ b/lib/graphiti/resource/polymorphism.rb @@ -58,7 +58,7 @@ def children end def resource_for_type(type) - resource = children.find { |c| c.type == type } + resource = children.find { |c| c.type.to_s == type.to_s } if resource.nil? raise Errors::PolymorphicResourceChildNotFound.new(self, type: type) else diff --git a/spec/request_validator_spec.rb b/spec/request_validator_spec.rb index c59afcb8..39da77ab 100644 --- a/spec/request_validator_spec.rb +++ b/spec/request_validator_spec.rb @@ -175,6 +175,20 @@ def self.name expect(instance.errors).to be_blank end + + context "when updating" do + before do + payload["action"] = "update" + payload[:data][:id] = 1 + payload[:filter] = { id: 1 } + end + + it "accepts the child type" do + validate + + expect(instance.errors).to be_blank + end + end end end