Skip to content

Commit

Permalink
Merge pull request #1692 from beauby/fix-jsonapi-tests
Browse files Browse the repository at this point in the history
Fix tests to comply with the JSON API spec.
  • Loading branch information
NullVoxPopuli committed Apr 21, 2016
2 parents 7485c84 + ebda34b commit f0fa743
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions test/adapter/json_api/has_many_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ def test_has_many_with_virtual_value
id: '1',
type: 'virtual-values',
relationships: {
maker: { data: { id: 1 } },
reviews: { data: [{ id: 1 }, { id: 2 }] }
maker: { data: { type: 'makers', id: '1' } },
reviews: { data: [{ type: 'reviews', id: '1' },
{ type: 'reviews', id: '2' }] }
}
}
}, adapter.serializable_hash)
Expand Down
5 changes: 3 additions & 2 deletions test/adapter/json_api/has_one_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def test_has_one_with_virtual_value
id: '1',
type: 'virtual-values',
relationships: {
maker: { data: { id: 1 } },
reviews: { data: [{ id: 1 }, { id: 2 }] }
maker: { data: { type: 'makers', id: '1' } },
reviews: { data: [{ type: 'reviews', id: '1' },
{ type: 'reviews', id: '2' }] }
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/fixtures/poro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ def json_key
VirtualValueSerializer = Class.new(ActiveModel::Serializer) do
attributes :id

has_many :reviews, virtual_value: [{ id: 1 }, { id: 2 }]
has_one :maker, virtual_value: { id: 1 }
has_many :reviews, virtual_value: [{ type: 'reviews', id: '1' },
{ type: 'reviews', id: '2' }]
has_one :maker, virtual_value: { type: 'makers', id: '1' }

def reviews
end
Expand Down

0 comments on commit f0fa743

Please sign in to comment.