Skip to content

Commit

Permalink
Revert "Fix a bug with single item arrays (venuu#124)"
Browse files Browse the repository at this point in the history
This reverts commit 9e35eb2.
  • Loading branch information
brianswko authored Oct 2, 2019
1 parent 30c3a25 commit d3dac7f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions lib/jsonapi/authorization/authorizing_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def related_models_with_context
when Hash # polymorphic relationship
resource_class = @resource_klass.resource_for(assoc_value[:type].to_s)
resource_class.find_by_key(assoc_value[:id], context: context)._model
when Array
else
resource_class = resource_class_for_relationship(assoc_name)
resources = resource_class.find_by_keys(assoc_value, context: context)
resources.map(&:_model).tap do |scoped_records|
Expand All @@ -324,9 +324,6 @@ def related_models_with_context
fail JSONAPI::Exceptions::RecordNotFound, related_ids
end
end
else
resource_class = resource_class_for_relationship(assoc_name)
resource_class.find_by_key(assoc_value, context: context)._model
end

{
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/included_resources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
{
relation_type: :to_one,
relation_name: :author,
records: existing_author
records: [existing_author]
},
{
relation_type: :to_many,
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/tricky_operations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
[{
relation_name: :article,
relation_type: :to_one,
records: article
records: [article]
}]
end

Expand Down

0 comments on commit d3dac7f

Please sign in to comment.