2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-04-01 20:42:56 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe Api::V1::ConferencesController do
|
|
|
|
|
let!(:conf_one) { create(:conference, short_title: 'conf_one') }
|
|
|
|
|
let!(:conf_two) { create(:conference, short_title: 'conf_two') }
|
|
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
|
|
|
|
before(:each) do
|
2019-05-13 17:42:09 +02:00
|
|
|
get :index, params: { format: :json }
|
2016-04-01 20:42:56 +05:30
|
|
|
@json = JSON.parse(response.body)['conferences']
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns successful response' do
|
|
|
|
|
expect(response).to be_success
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns all conferences' do
|
|
|
|
|
expect(@json.length).to eq(2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns correct conferences' do
|
2020-03-20 06:24:47 -07:00
|
|
|
expect(@json.map { |c| c['short_title'] }).to contain_exactly('conf_one', 'conf_two')
|
2016-04-01 20:42:56 +05:30
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
|
|
|
|
before(:each) do
|
2019-05-13 17:42:09 +02:00
|
|
|
get :show, params: { id: 'conf_two', format: :json }
|
2016-04-01 20:42:56 +05:30
|
|
|
@json = JSON.parse(response.body)['conferences']
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns successful response' do
|
|
|
|
|
expect(response).to be_success
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns only one conference' do
|
|
|
|
|
expect(@json.length).to eq(1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the correct conference' do
|
|
|
|
|
expect(@json[0]['short_title']).to eq('conf_two')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|