Skip to content

Commit

Permalink
Merge pull request #202 from nibynic/master
Browse files Browse the repository at this point in the history
Fix nested resource lookup by type in update requests
  • Loading branch information
richmolj authored Jan 24, 2020
2 parents ca94cab + 857942f commit 13998eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/graphiti/resource/polymorphism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions spec/request_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 13998eb

Please sign in to comment.