File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe FastJsonapi ::ObjectSerializer do
4+ include_context 'movie class'
5+
6+ context 'when setting id' do
7+ subject ( :serializable_hash ) { MovieSerializer . new ( resource ) . serializable_hash }
8+
9+ before ( :all ) do
10+ MovieSerializer . set_id :owner_id
11+ end
12+
13+ context 'when one record is given' do
14+ let ( :resource ) { movie }
15+
16+ it 'returns correct hash which id equals owner_id' do
17+ expect ( serializable_hash [ :data ] [ :id ] . to_i ) . to eq movie . owner_id
18+ end
19+ end
20+
21+ context 'when an array of records is given' do
22+ let ( :resource ) { [ movie , movie ] }
23+
24+ it 'returns correct hash which id equals owner_id' do
25+ expect ( serializable_hash [ :data ] [ 0 ] [ :id ] . to_i ) . to eq movie . owner_id
26+ expect ( serializable_hash [ :data ] [ 1 ] [ :id ] . to_i ) . to eq movie . owner_id
27+ end
28+ end
29+ end
30+ end
You can’t perform that action at this time.
0 commit comments