mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add tests for api/v1/events_controller and api/v1/speakers_controller
This commit is contained in:
parent
22714b0f11
commit
f8822b8745
2 changed files with 78 additions and 0 deletions
35
spec/controllers/api/v1/events_controller_spec.rb
Normal file
35
spec/controllers/api/v1/events_controller_spec.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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
|
||||
|
||||
get :index, format: :json
|
||||
json = JSON.parse(response.body)['events']
|
||||
expect(response).to be_success
|
||||
|
||||
expect(json.length).to eq(2)
|
||||
expect(json[0]['title']).to eq('Example Event')
|
||||
expect(json[1]['title']).to eq('Conference Event')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with conference scope' do
|
||||
it 'returns all confirmed events of conference' do
|
||||
|
||||
get :index, conference_id: conference.short_title, format: :json
|
||||
json = JSON.parse(response.body)['events']
|
||||
|
||||
expect(response).to be_success
|
||||
|
||||
expect(json.length).to eq(1)
|
||||
expect(json[0]['title']).to eq('Conference Event')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
43
spec/controllers/api/v1/speakers_controller_spec.rb
Normal file
43
spec/controllers/api/v1/speakers_controller_spec.rb
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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
|
||||
event.event_users << create(:speaker, user: speaker)
|
||||
conference_event.event_users << create(:speaker, user: conference_speaker)
|
||||
end
|
||||
|
||||
context 'without conference scope' do
|
||||
it 'returns all speakers' do
|
||||
|
||||
get :index, format: :json
|
||||
json = JSON.parse(response.body)['speakers']
|
||||
expect(response).to be_success
|
||||
|
||||
expect(json.length).to eq(2)
|
||||
expect(json[0]['name']).to eq('Speaker')
|
||||
expect(json[1]['name']).to eq('Conf_Speaker')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with conference scope' do
|
||||
it 'returns all speakers of conference' do
|
||||
|
||||
get :index, conference_id: conference.short_title, format: :json
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue