2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-03-31 14:55:19 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe Api::V1::SpeakersController do
|
|
|
|
|
let!(:conference) { create(:conference) }
|
|
|
|
|
let!(:event) { create(:event_full) }
|
|
|
|
|
let!(:conference_event) { create(:event_full, program: conference.program) }
|
|
|
|
|
|
|
|
|
|
let(:speaker) { create(:user, name: 'Speaker') }
|
|
|
|
|
let(:conference_speaker) { create(:user, name: 'Conf_Speaker') }
|
|
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
|
|
|
|
before do
|
2017-02-02 16:34:59 +02:00
|
|
|
event.speakers = [speaker]
|
|
|
|
|
conference_event.speakers = [conference_speaker]
|
2016-03-31 14:55:19 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'without conference scope' do
|
|
|
|
|
it 'returns all speakers' do
|
|
|
|
|
|
2019-05-13 17:42:09 +02:00
|
|
|
get :index, params: { format: :json }
|
2016-03-31 14:55:19 +05:30
|
|
|
json = JSON.parse(response.body)['speakers']
|
|
|
|
|
expect(response).to be_success
|
2020-04-01 08:53:01 -07:00
|
|
|
expect(json.pluck('name')).to contain_exactly('Conf_Speaker', 'Speaker')
|
2016-03-31 14:55:19 +05:30
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with conference scope' do
|
|
|
|
|
it 'returns all speakers of conference' do
|
|
|
|
|
|
2019-05-13 17:42:09 +02:00
|
|
|
get :index, params: { conference_id: conference.short_title, format: :json }
|
2016-03-31 14:55:19 +05:30
|
|
|
json = JSON.parse(response.body)['speakers']
|
|
|
|
|
|
|
|
|
|
expect(response).to be_success
|
|
|
|
|
|
|
|
|
|
expect(json.length).to eq(1)
|
|
|
|
|
expect(json[0]['name']).to eq('Conf_Speaker')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|