Skip to content

Commit f0fa743

Browse files
committed
Merge pull request #1692 from beauby/fix-jsonapi-tests
Fix tests to comply with the JSON API spec.
2 parents 7485c84 + ebda34b commit f0fa743

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

test/adapter/json_api/has_many_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ def test_has_many_with_virtual_value
131131
id: '1',
132132
type: 'virtual-values',
133133
relationships: {
134-
maker: { data: { id: 1 } },
135-
reviews: { data: [{ id: 1 }, { id: 2 }] }
134+
maker: { data: { type: 'makers', id: '1' } },
135+
reviews: { data: [{ type: 'reviews', id: '1' },
136+
{ type: 'reviews', id: '2' }] }
136137
}
137138
}
138139
}, adapter.serializable_hash)

test/adapter/json_api/has_one_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ def test_has_one_with_virtual_value
6565
id: '1',
6666
type: 'virtual-values',
6767
relationships: {
68-
maker: { data: { id: 1 } },
69-
reviews: { data: [{ id: 1 }, { id: 2 }] }
68+
maker: { data: { type: 'makers', id: '1' } },
69+
reviews: { data: [{ type: 'reviews', id: '1' },
70+
{ type: 'reviews', id: '2' }] }
7071
}
7172
}
7273
}

test/fixtures/poro.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ def json_key
227227
VirtualValueSerializer = Class.new(ActiveModel::Serializer) do
228228
attributes :id
229229

230-
has_many :reviews, virtual_value: [{ id: 1 }, { id: 2 }]
231-
has_one :maker, virtual_value: { id: 1 }
230+
has_many :reviews, virtual_value: [{ type: 'reviews', id: '1' },
231+
{ type: 'reviews', id: '2' }]
232+
has_one :maker, virtual_value: { type: 'makers', id: '1' }
232233

233234
def reviews
234235
end

0 commit comments

Comments
 (0)