Rebuild rubocop TODOs after auto-correcting
This commit is contained in:
parent
31c50255e9
commit
84dbb52d11
580 changed files with 3689 additions and 3133 deletions
|
|
@ -1,10 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Admin::ConferencesController do
|
||||
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let!(:organization) { create(:organization, name: 'organization') }
|
||||
let!(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 05, 26) + 15) }
|
||||
let!(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 0o5, 26) + 15) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||
let(:organization_admin) { create(:user, role_ids: organization_admin_role.id) }
|
||||
|
|
@ -16,32 +17,33 @@ describe Admin::ConferencesController do
|
|||
describe 'PATCH #update' do
|
||||
context 'valid attributes' do
|
||||
it 'locates the requested conference' do
|
||||
patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con')
|
||||
patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con') }
|
||||
expect(assigns(:conference)).to eq(conference)
|
||||
end
|
||||
|
||||
it 'changes conference attributes' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
patch :update, params: { id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: 'ExCon')
|
||||
short_title: 'ExCon') }
|
||||
conference.reload
|
||||
expect(conference.title).to eq('Example Con')
|
||||
expect(conference.short_title).to eq('ExCon')
|
||||
end
|
||||
|
||||
it 'redirects to the updated conference' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
patch :update, params: { id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con') }
|
||||
conference.reload
|
||||
expect(response).to redirect_to edit_admin_conference_path(
|
||||
conference.short_title)
|
||||
conference.short_title
|
||||
)
|
||||
end
|
||||
|
||||
it 'sends email notification on conference date update' do
|
||||
mailer = double
|
||||
allow(mailer).to receive(:deliver)
|
||||
conference.email_settings = create(:email_settings)
|
||||
patch :update, id: conference.short_title, conference: attributes_for(:conference, start_date: Time.zone.today + 2.days, end_date: Time.zone.today + 4.days)
|
||||
patch :update, params: { id: conference.short_title, conference: attributes_for(:conference, start_date: Time.zone.today + 2.days, end_date: Time.zone.today + 4.days) }
|
||||
conference.reload
|
||||
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
||||
end
|
||||
|
|
@ -49,50 +51,51 @@ describe Admin::ConferencesController do
|
|||
|
||||
context 'invalid attributes' do
|
||||
it 'does not change conference attributes' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
patch :update, params: { id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
short_title: nil) }
|
||||
|
||||
conference.reload
|
||||
expect(flash[:error])
|
||||
.to eq("Updating conference failed. Short title can't be blank.")
|
||||
.to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(conference.title).to eq(conference.title)
|
||||
expect(conference.short_title).to eq(conference.short_title)
|
||||
end
|
||||
|
||||
it 're-renders the #show template' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
patch :update, params: { id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con',
|
||||
short_title: nil)
|
||||
short_title: nil) }
|
||||
|
||||
expect(flash[:error])
|
||||
.to eq("Updating conference failed. Short title can't be blank.")
|
||||
.to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(response).to redirect_to edit_admin_conference_path(
|
||||
conference.short_title)
|
||||
conference.short_title
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested conference to conference' do
|
||||
get :edit, id: conference.short_title
|
||||
get :edit, params: { id: conference.short_title }
|
||||
expect(assigns(:conference)).to eq conference
|
||||
end
|
||||
|
||||
it 'renders the show template' do
|
||||
get :edit, id: conference.short_title
|
||||
get :edit, params: { id: conference.short_title }
|
||||
expect(response).to render_template :edit
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested conference to conference' do
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(assigns(:conference)).to eq conference
|
||||
end
|
||||
|
||||
it 'renders the show template' do
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(response).to render_template :show
|
||||
end
|
||||
|
||||
|
|
@ -101,11 +104,11 @@ describe Admin::ConferencesController do
|
|||
create(:event, program: conference.program)
|
||||
workshop = create(:event_type, title: 'Workshop', color: '#000000', program: conference.program)
|
||||
lecture = create(:event_type, title: 'Lecture', color: '#ffffff', program: conference.program)
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(assigns(:event_type_distribution_withdrawn)).to be_empty
|
||||
create(:event, program: conference.program, state: 'withdrawn', event_type: lecture)
|
||||
create(:event, program: conference.program, state: 'withdrawn', event_type: workshop)
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(assigns(:event_type_distribution_withdrawn)).not_to be_empty
|
||||
result = {}
|
||||
result['Workshop'] = {
|
||||
|
|
@ -122,13 +125,13 @@ describe Admin::ConferencesController do
|
|||
it 'assigns conference withdrawn difficulty level distribution to difficulty_levels_distribution_withdrawn' do
|
||||
conference
|
||||
create(:event, program: conference.program)
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(assigns(:difficulty_levels_distribution_withdrawn)).to be_empty
|
||||
easy = create(:difficulty_level, title: 'Easy', color: '#000000')
|
||||
hard = create(:difficulty_level, title: 'Hard', color: '#ffffff')
|
||||
create(:event, program: conference.program, state: 'withdrawn', difficulty_level: easy)
|
||||
create(:event, program: conference.program, state: 'withdrawn', difficulty_level: hard)
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(assigns(:difficulty_levels_distribution_withdrawn)).not_to be_empty
|
||||
result = {}
|
||||
result['Easy'] = {
|
||||
|
|
@ -145,13 +148,13 @@ describe Admin::ConferencesController do
|
|||
it 'assigns conference withdrawn track distribution to tracks_distribution_withdrawn' do
|
||||
conference
|
||||
create(:event, program: conference.program)
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(assigns(:tracks_distribution_withdrawn)).to be_empty
|
||||
track_one = create(:track, name: 'Track One', color: '#000000', program: conference.program)
|
||||
track_two = create(:track, name: 'Track Two', color: '#FFFFFF', program: conference.program)
|
||||
create(:event, program: conference.program, state: 'withdrawn', track: track_one)
|
||||
create(:event, program: conference.program, state: 'withdrawn', track: track_two)
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(assigns(:tracks_distribution_withdrawn)).not_to be_empty
|
||||
result = {}
|
||||
result['Track One'] = {
|
||||
|
|
@ -177,7 +180,7 @@ describe Admin::ConferencesController do
|
|||
|
||||
it 'assigns cfp_max an array with maximum weeks' do
|
||||
conference
|
||||
date = Date.new(2014, 05, 26)
|
||||
date = Date.new(2014, 0o5, 26)
|
||||
create(:cfp,
|
||||
program: conference.program,
|
||||
start_date: date,
|
||||
|
|
@ -195,9 +198,7 @@ describe Admin::ConferencesController do
|
|||
|
||||
context 'no conferences' do
|
||||
it 'redirect to new conference' do
|
||||
Conference.all.each do |c|
|
||||
c.destroy
|
||||
end
|
||||
Conference.all.each(&:destroy)
|
||||
sign_in create(:admin)
|
||||
get :index
|
||||
expect(response).to redirect_to new_admin_conference_path
|
||||
|
|
@ -211,18 +212,19 @@ describe Admin::ConferencesController do
|
|||
context 'with valid attributes' do
|
||||
it 'saves the conference to the database' do
|
||||
expected = expect do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
|
||||
post :create, params: { conference:
|
||||
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) }
|
||||
end
|
||||
expected.to change { Conference.count }.by 1
|
||||
end
|
||||
|
||||
it 'redirects to conference#show' do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
|
||||
post :create, params: { conference:
|
||||
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) }
|
||||
|
||||
expect(response).to redirect_to admin_conference_path(
|
||||
assigns[:conference].short_title)
|
||||
assigns[:conference].short_title
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates roles for the conference' do
|
||||
|
|
@ -230,8 +232,8 @@ describe Admin::ConferencesController do
|
|||
info_desk_role = Role.find_by(name: 'info_desk', resource: conference)
|
||||
volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference)
|
||||
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: 'dps15')
|
||||
post :create, params: { conference:
|
||||
attributes_for(:conference, short_title: 'dps15') }
|
||||
|
||||
expect(conference.roles.count).to eq 4
|
||||
|
||||
|
|
@ -242,15 +244,15 @@ describe Admin::ConferencesController do
|
|||
context 'with invalid attributes' do
|
||||
it 'does not save the conference to the database' do
|
||||
expected = expect do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: nil, organization_id: organization.id)
|
||||
post :create, params: { conference:
|
||||
attributes_for(:conference, short_title: nil, organization_id: organization.id) }
|
||||
end
|
||||
expected.to_not change { Conference.count }
|
||||
end
|
||||
|
||||
it 're-renders the new template' do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: nil, organization_id: organization.id)
|
||||
post :create, params: { conference:
|
||||
attributes_for(:conference, short_title: nil, organization_id: organization.id) }
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
|
@ -259,15 +261,15 @@ describe Admin::ConferencesController do
|
|||
it 'does not save the conference to the database' do
|
||||
conference
|
||||
expected = expect do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id)
|
||||
post :create, params: { conference:
|
||||
attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) }
|
||||
end
|
||||
expected.to_not change { Conference.count }
|
||||
end
|
||||
|
||||
it 're-renders the new template' do
|
||||
conference
|
||||
post :create, conference: attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id)
|
||||
post :create, params: { conference: attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) }
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
|
@ -300,20 +302,16 @@ describe Admin::ConferencesController do
|
|||
it 'requires organizer privileges' do
|
||||
get :new
|
||||
expect(response).to redirect_to(send(path))
|
||||
if message
|
||||
expect(flash[:alert]).to match(/#{message}/)
|
||||
end
|
||||
expect(flash[:alert]).to match(/#{message}/) if message
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'requires organizer privileges' do
|
||||
post :create, conference: attributes_for(:conference,
|
||||
short_title: 'ExCon', organization_id: organization.id)
|
||||
post :create, params: { conference: attributes_for(:conference,
|
||||
short_title: 'ExCon', organization_id: organization.id) }
|
||||
expect(response).to redirect_to(send(path))
|
||||
if message
|
||||
expect(flash[:alert]).to match(/#{message}/)
|
||||
end
|
||||
expect(flash[:alert]).to match(/#{message}/) if message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -330,11 +328,9 @@ describe Admin::ConferencesController do
|
|||
shared_examples 'access as participant or guest' do |path, message|
|
||||
describe 'GET #show' do
|
||||
it 'requires organizer privileges' do
|
||||
get :show, id: conference.short_title
|
||||
get :show, params: { id: conference.short_title }
|
||||
expect(response).to redirect_to(send(path))
|
||||
if message
|
||||
expect(flash[:alert]).to match(/#{message}/)
|
||||
end
|
||||
expect(flash[:alert]).to match(/#{message}/) if message
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -342,21 +338,16 @@ describe Admin::ConferencesController do
|
|||
it 'requires organizer privileges' do
|
||||
get :index
|
||||
expect(response).to redirect_to(send(path))
|
||||
if message
|
||||
expect(flash[:alert]).to match(/#{message}/)
|
||||
end
|
||||
expect(flash[:alert]).to match(/#{message}/) if message
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
it 'requires organizer privileges' do
|
||||
patch :update, id: conference.short_title,
|
||||
conference: attributes_for(:conference,
|
||||
short_title: 'ExCon')
|
||||
patch :update, params: { id: conference.short_title, conference: attributes_for(:conference,
|
||||
short_title: 'ExCon') }
|
||||
expect(response).to redirect_to(send(path))
|
||||
if message
|
||||
expect(flash[:alert]).to match(/#{message}/)
|
||||
end
|
||||
expect(flash[:alert]).to match(/#{message}/) if message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -371,7 +362,6 @@ describe Admin::ConferencesController do
|
|||
end
|
||||
|
||||
describe 'guest access' do
|
||||
|
||||
it_behaves_like 'access as participant or guest', :new_user_session_path
|
||||
it_behaves_like 'access as organizer, participant or guest', :new_user_session_path
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue