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::EventsController do
|
|
|
|
|
let!(:conference) { create(:conference) }
|
|
|
|
|
let!(:event) { create(:event_full, state: 'confirmed', title: 'Example Event') }
|
|
|
|
|
let!(:conference_event) { create(:event_full, state: 'confirmed', title: 'Conference Event', program: conference.program) }
|
|
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
|
|
|
|
context 'without conference scope' do
|
|
|
|
|
it 'returns all confirmed events' 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)['events']
|
2022-01-23 14:06:02 -08:00
|
|
|
expect(response).to be_successful
|
2016-03-31 14:55:19 +05:30
|
|
|
|
2020-04-01 08:53:01 -07:00
|
|
|
expect(json.pluck('title')).to contain_exactly('Conference Event', 'Example Event')
|
2016-03-31 14:55:19 +05:30
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'with conference scope' do
|
|
|
|
|
it 'returns all confirmed events 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)['events']
|
|
|
|
|
|
2022-01-23 14:06:02 -08:00
|
|
|
expect(response).to be_successful
|
2016-03-31 14:55:19 +05:30
|
|
|
|
|
|
|
|
expect(json.length).to eq(1)
|
|
|
|
|
expect(json[0]['title']).to eq('Conference Event')
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|