Include roots for resources in rabl index views
This commit is contained in:
parent
4e0c422a6f
commit
bdfd0edff0
@ -1,4 +1,4 @@
|
|||||||
collection @playlists
|
collection @playlists, root: :playlists, object_root: false
|
||||||
|
|
||||||
attribute :id
|
attribute :id
|
||||||
attribute :name
|
attribute :name
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
collection @tracks
|
collection @tracks, root: :tracks, object_root: false
|
||||||
|
|
||||||
attribute :id
|
attribute :id
|
||||||
attribute :name
|
attribute :name
|
||||||
|
@ -13,7 +13,7 @@ describe 'API sign in' do
|
|||||||
it 'signs the user in with valid credentials' do
|
it 'signs the user in with valid credentials' do
|
||||||
do_create
|
do_create
|
||||||
|
|
||||||
expect(json).to eq(id: user.id)
|
expect(json).to eq(user: { id: user.id })
|
||||||
end
|
end
|
||||||
|
|
||||||
[:email, :password].each do |attr|
|
[:email, :password].each do |attr|
|
||||||
|
@ -7,33 +7,35 @@ describe 'API playlists' do
|
|||||||
playlist = create :playlist
|
playlist = create :playlist
|
||||||
get api_playlists_path, format: :json
|
get api_playlists_path, format: :json
|
||||||
|
|
||||||
expect(json).to match [
|
expect(json).to eq(
|
||||||
a_hash_including(
|
playlists: [{
|
||||||
id: an_instance_of(Fixnum),
|
id: playlist.id,
|
||||||
name: playlist[:name]
|
name: playlist.name
|
||||||
|
}]
|
||||||
)
|
)
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows a playlist' do
|
it 'shows a playlist' do
|
||||||
playlist = create :playlist
|
playlist = create :playlist
|
||||||
get api_playlist_path playlist, format: :json
|
get api_playlist_path playlist, format: :json
|
||||||
|
|
||||||
expect(json).to match(
|
expect(json).to eq(
|
||||||
|
playlist: {
|
||||||
id: playlist.id,
|
id: playlist.id,
|
||||||
name: playlist.name
|
name: playlist.name
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates playlist' do
|
it 'creates playlist' do
|
||||||
playlist = attributes_for :playlist
|
playlist = attributes_for :playlist
|
||||||
post api_playlists_path,
|
post api_playlists_path, format: :json, playlist: playlist
|
||||||
format: :json,
|
|
||||||
playlist: playlist
|
|
||||||
|
|
||||||
expect(json).to match(
|
expect(json).to match(
|
||||||
|
playlist: {
|
||||||
id: an_instance_of(Fixnum),
|
id: an_instance_of(Fixnum),
|
||||||
name: playlist[:name]
|
name: playlist[:name]
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,8 @@ describe 'API tracks' do
|
|||||||
track_2 = create :track, name: 'Track 2'
|
track_2 = create :track, name: 'Track 2'
|
||||||
get api_tracks_path, format: :json
|
get api_tracks_path, format: :json
|
||||||
|
|
||||||
expect(json).to eq [
|
expect(json).to eq(
|
||||||
|
tracks: [
|
||||||
{
|
{
|
||||||
id: track_1.id,
|
id: track_1.id,
|
||||||
name: 'Track 1',
|
name: 'Track 1',
|
||||||
@ -19,15 +20,18 @@ describe 'API tracks' do
|
|||||||
name: 'Track 2'
|
name: 'Track 2'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows a track' do
|
it 'shows a track' do
|
||||||
track = create :track
|
track = create :track
|
||||||
get api_track_path track, format: :json
|
get api_track_path track, format: :json
|
||||||
|
|
||||||
expect(json).to match(
|
expect(json).to eq(
|
||||||
|
track: {
|
||||||
id: track.id,
|
id: track.id,
|
||||||
name: track.name
|
name: track.name
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user