2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-08-08 18:01:35 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe Admin::SchedulesController do
|
|
|
|
|
let(:conference) { create(:conference) }
|
|
|
|
|
let(:schedule) { create(:schedule, program: conference.program)}
|
2019-03-13 10:31:42 +01:00
|
|
|
let!(:organizer) { create(:organizer, resource: conference) }
|
2016-08-08 18:01:35 +02:00
|
|
|
|
|
|
|
|
context 'logged in as an organizer' do
|
|
|
|
|
before :each do
|
|
|
|
|
sign_in(organizer)
|
|
|
|
|
schedule
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
|
|
|
|
it 'renders the index template' do
|
2019-05-13 17:42:09 +02:00
|
|
|
get :index, params: { conference_id: conference.short_title }
|
2016-08-08 18:01:35 +02:00
|
|
|
expect(response).to render_template :index
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'POST #create' do
|
2019-05-13 17:42:09 +02:00
|
|
|
let(:create_action){ post :create, params: { conference_id: conference.short_title } }
|
2016-08-09 16:23:38 +02:00
|
|
|
|
2016-08-08 18:01:35 +02:00
|
|
|
it 'saves the schedule to the database' do
|
2016-08-09 16:23:38 +02:00
|
|
|
expect{ create_action }.to change { Schedule.count }.by 1
|
2016-08-08 18:01:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'redirects to schedules#show' do
|
2016-08-09 16:23:38 +02:00
|
|
|
create_action
|
2016-08-08 18:01:35 +02:00
|
|
|
expect(response).to redirect_to admin_conference_schedule_path(
|
|
|
|
|
conference.short_title, assigns[:schedule])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
2019-05-13 17:42:09 +02:00
|
|
|
let(:show_action){ get :show, params: { id: schedule.id, conference_id: conference.short_title } }
|
2016-08-09 16:23:38 +02:00
|
|
|
|
2016-08-08 18:01:35 +02:00
|
|
|
it 'assigns the requested schedule to schedule' do
|
2016-08-09 16:23:38 +02:00
|
|
|
show_action
|
2016-08-08 18:01:35 +02:00
|
|
|
expect(assigns(:schedule)).to eq schedule
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'renders the show template' do
|
2016-08-09 16:23:38 +02:00
|
|
|
show_action
|
2016-08-08 18:01:35 +02:00
|
|
|
expect(response).to render_template :show
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'DELETE #destroy' do
|
2019-05-13 17:42:09 +02:00
|
|
|
let(:destroy_action){ delete :destroy, params: { id: schedule.id, conference_id: conference.short_title } }
|
2016-08-09 16:23:38 +02:00
|
|
|
|
2016-08-08 18:01:35 +02:00
|
|
|
it 'deletes the schedule' do
|
2016-08-09 16:23:38 +02:00
|
|
|
expect{ destroy_action }.to change { Schedule.count }.by(-1)
|
2016-08-08 18:01:35 +02:00
|
|
|
end
|
2016-08-09 16:23:38 +02:00
|
|
|
|
2016-08-08 18:01:35 +02:00
|
|
|
it 'redirects to schedules#index' do
|
2016-08-09 16:23:38 +02:00
|
|
|
destroy_action
|
2016-08-08 18:01:35 +02:00
|
|
|
expect(response).to redirect_to admin_conference_schedules_path(conference.short_title)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|