Files
osem/spec/controllers/api/v1/tracks_controller_spec.rb
Nishanth Vijayan 3da04c0f7c Update active_model_serializers.Fix conference serializer and api tests
The controllers are not using the serializers, because of a bug in active_model_serializer.
Hence the update.API tests are fixed to work with the new API response structure.
Fixes bugs in conference serializer.
2016-03-15 12:38:13 +05:30

37 lines
1.0 KiB
Ruby

require 'spec_helper'
describe Api::V1::TracksController do
let!(:conference) { create(:conference) }
let!(:conference_track) { create(:track, name: 'Conference Track', program_id: conference.program.id) }
let!(:track) { create(:track, name: 'Test Track') }
describe 'GET #index' do
context 'without conference scope' do
it 'returns all tracks' do
get :index, format: :json
json = JSON.parse(response.body)['tracks']
expect(response).to be_success
expect(json.length).to eq(2)
expect(json[0]['name']).to eq('Conference Track')
expect(json[1]['name']).to eq('Test Track')
end
end
context 'with conference scope' do
it 'returns all rooms of conference' do
get :index, conference_id: conference.short_title, format: :json
json = JSON.parse(response.body)['tracks']
expect(response).to be_success
expect(json.length).to eq(1)
expect(json[0]['name']).to eq('Conference Track')
end
end
end
end