Rubocop autocorrections

This commit is contained in:
James Mason 2018-11-13 18:01:49 -08:00
parent 299738f58d
commit 43bef689fc
85 changed files with 622 additions and 578 deletions

View file

@ -24,7 +24,7 @@ describe Admin::ConferencesController do
it 'changes conference attributes' do
patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con',
attributes_for(:conference, title: 'Example Con',
short_title: 'ExCon')
conference.reload
expect(conference.title).to eq('Example Con')
@ -52,7 +52,7 @@ describe Admin::ConferencesController do
context 'invalid attributes' do
it 'does not change conference attributes' do
patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con',
attributes_for(:conference, title: 'Example Con',
short_title: nil)
conference.reload
@ -64,7 +64,7 @@ describe Admin::ConferencesController do
it 're-renders the #show template' do
patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con',
attributes_for(:conference, title: 'Example Con',
short_title: nil)
expect(flash[:error])
@ -181,9 +181,9 @@ describe Admin::ConferencesController do
conference
date = Date.new(2014, 05, 26)
create(:cfp,
program: conference.program,
program: conference.program,
start_date: date,
end_date: date + 14)
end_date: date + 14)
get :index
expect(assigns(:cfp_weeks)).to match_array([1, 2, 3])
end
@ -214,14 +214,14 @@ describe Admin::ConferencesController 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)
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)
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
expect(response).to redirect_to admin_conference_path(
assigns[:conference].short_title)
@ -233,7 +233,7 @@ describe Admin::ConferencesController do
volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference)
post :create, conference:
attributes_for(:conference, short_title: 'dps15')
attributes_for(:conference, short_title: 'dps15')
expect(conference.roles.count).to eq 4
@ -245,14 +245,14 @@ describe Admin::ConferencesController 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)
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)
attributes_for(:conference, short_title: nil, organization_id: organization.id)
expect(response).to be_success
end
end
@ -262,7 +262,7 @@ describe Admin::ConferencesController do
conference
expected = expect do
post :create, conference:
attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id)
attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id)
end
expected.to_not change { Conference.count }
end
@ -352,7 +352,7 @@ describe Admin::ConferencesController do
describe 'PATCH #update' do
it 'requires organizer privileges' do
patch :update, id: conference.short_title,
patch :update, id: conference.short_title,
conference: attributes_for(:conference,
short_title: 'ExCon')
expect(response).to redirect_to(send(path))

View file

@ -23,9 +23,9 @@ describe Admin::EventSchedulesController do
post :create, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: create(:event, program: conference.program).id,
room_id: create(:room, venue: venue).id,
start_time: conference.start_date + conference.start_hour.hours)
event_id: create(:event, program: conference.program).id,
room_id: create(:room, venue: venue).id,
start_time: conference.start_date + conference.start_hour.hours)
end
it 'saves the event schedule to the database' do
@ -44,9 +44,9 @@ describe Admin::EventSchedulesController do
post :create, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: nil,
room_id: nil,
start_time: nil)
event_id: nil,
room_id: nil,
start_time: nil)
end
it 'does not save the event schedule to the database' do
@ -66,9 +66,9 @@ describe Admin::EventSchedulesController do
patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: create(:event, program: conference.program).id,
room_id: room.id,
start_time: conference.start_date + conference.start_hour.hours)
event_id: create(:event, program: conference.program).id,
room_id: room.id,
start_time: conference.start_date + conference.start_hour.hours)
event_schedule.reload
end
@ -90,9 +90,9 @@ describe Admin::EventSchedulesController do
patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: nil,
room_id: nil,
start_time: nil)
event_id: nil,
room_id: nil,
start_time: nil)
end
it 'does not save the event schedule to the database' do
expect{ update_action }.to_not change { event_schedule }

View file

@ -174,7 +174,7 @@ describe Admin::OrganizationsController do
let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
before do
post :assign_org_admins, id: organization.id,
post :assign_org_admins, id: organization.id,
user: { email: user.email }
end
@ -188,7 +188,7 @@ describe Admin::OrganizationsController do
let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) }
before do
delete :unassign_org_admins, id: organization.id,
delete :unassign_org_admins, id: organization.id,
user: { email: org_admin_user.email }
end

View file

@ -50,12 +50,12 @@ describe Admin::RegistrationPeriodsController do
conference.email_settings = create(:email_settings)
conference.registration_period = create(:registration_period,
start_date: Date.today,
end_date: Date.today + 2.days)
end_date: Date.today + 2.days)
patch :update, conference_id: conference.short_title, registration_period:
attributes_for(:registration_period,
start_date: Date.today + 2.days,
end_date: Date.today + 4.days)
end_date: Date.today + 4.days)
conference.reload
allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
end
@ -67,7 +67,7 @@ describe Admin::RegistrationPeriodsController do
it 'saves the registration period to the database' do
expected = expect do
post :create,
conference_id: conference.short_title,
conference_id: conference.short_title,
registration_period: attributes_for(:registration_period)
end
expected.to change { RegistrationPeriod.count }.by 1
@ -75,7 +75,7 @@ describe Admin::RegistrationPeriodsController do
it 'redirects to registration_periods#show' do
post :create,
conference_id: conference.short_title,
conference_id: conference.short_title,
registration_period: attributes_for(:registration_period)
expect(response).to redirect_to admin_conference_registration_period_path(
@ -87,20 +87,20 @@ describe Admin::RegistrationPeriodsController do
it 'does not save the registration period to the database' do
expected = expect do
post :create,
conference_id: conference.short_title,
conference_id: conference.short_title,
registration_period: attributes_for(:registration_period,
start_date: nil,
end_date: nil)
end_date: nil)
end
expected.to_not change { Conference.count }
end
it 're-renders the new template' do
post :create,
conference_id: conference.short_title,
conference_id: conference.short_title,
registration_period: attributes_for(:registration_period,
start_date: nil,
end_date: nil)
end_date: nil)
expect(response).to be_success
end
end

View file

@ -30,7 +30,7 @@ describe Admin::RolesController do
before :each do
sign_in(admin)
xhr :get, :show, conference_id: conference.short_title,
id: 'organizer'
id: 'organizer'
end
it 'assigns correct value to selection variable' do
@ -46,8 +46,8 @@ describe Admin::RolesController do
before :each do
sign_in admin
patch :update, conference_id: conference.short_title,
id: 'cfp',
role: { description: 'New description for cfp role!' }
id: 'cfp',
role: { description: 'New description for cfp role!' }
end
it 'changes the description of the role' do
@ -59,8 +59,8 @@ describe Admin::RolesController do
before :each do
sign_in admin
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io' },
id: 'cfp'
user: { email: 'user1@osem.io' },
id: 'cfp'
end
context 'assigns correct values to variables' do
@ -80,16 +80,16 @@ describe Admin::RolesController do
context 'adds role to user' do
it 'adds second user' do
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user2@osem.io' },
id: 'cfp'
user: { email: 'user2@osem.io' },
id: 'cfp'
expect(user2.roles).to eq [cfp_role]
end
it 'assigns second role to user' do
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io' },
id: 'organizer'
user: { email: 'user1@osem.io' },
id: 'organizer'
expect(user1.roles).to eq [organizer_role, cfp_role]
end
@ -98,22 +98,22 @@ describe Admin::RolesController do
context 'removes role from user' do
it 'removes role from user' do
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'false' },
id: 'cfp'
user: { email: 'user1@osem.io', state: 'false' },
id: 'cfp'
expect(user1.roles).to eq []
end
it 'removes second role from user' do
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io' },
id: 'organizer'
user: { email: 'user1@osem.io' },
id: 'organizer'
expect(user1.roles).to eq [organizer_role, cfp_role]
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'false' },
id: 'cfp'
user: { email: 'user1@osem.io', state: 'false' },
id: 'cfp'
user1.reload
expect(user1.roles).to eq [organizer_role]
@ -123,14 +123,14 @@ describe Admin::RolesController do
it 'does not remove role if user is the last organizer' do
# Add role organizer
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'true' },
id: 'organizer'
user: { email: 'user1@osem.io', state: 'true' },
id: 'organizer'
expect(organizer_role.users).to eq [user1]
# Try to remove role organizer, when there is only 1 user as organizer
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'false' },
id: 'organizer'
user: { email: 'user1@osem.io', state: 'false' },
id: 'organizer'
expect(organizer_role.users).to eq [user1]
end
end

View file

@ -91,9 +91,9 @@ describe Admin::RoomsController do
describe 'PATCH #update' do
context 'updates successfully' do
before do
patch :update, room: attributes_for(:room, size: 2),
patch :update, room: attributes_for(:room, size: 2),
conference_id: conference.short_title,
id: room.id
id: room.id
end
it 'redirects to admin room index path' do
@ -113,9 +113,9 @@ describe Admin::RoomsController do
context 'update fails' do
before do
allow_any_instance_of(Room).to receive(:save).and_return(false)
patch :update, room: attributes_for(:room, size: 2),
patch :update, room: attributes_for(:room, size: 2),
conference_id: conference.short_title,
id: room.id
id: room.id
end
it 'renders edit template' do

View file

@ -51,7 +51,7 @@ describe Admin::SponsorshipLevelsController do
context 'saves successfuly' do
before(:each, run: true) do
post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title
conference_id: conference.short_title
end
it 'redirects to admin sponsorship_level index path', run: true do
@ -65,7 +65,7 @@ describe Admin::SponsorshipLevelsController do
it 'creates new sponsorship_level' do
expect do
post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title
conference_id: conference.short_title
end.to change{ conference.sponsorship_levels.count }.from(0).to(1)
end
end
@ -74,7 +74,7 @@ describe Admin::SponsorshipLevelsController do
before do
allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false)
post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title
conference_id: conference.short_title
end
it 'renders new template' do
@ -95,8 +95,8 @@ describe Admin::SponsorshipLevelsController do
context 'updates successfully' do
before do
patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'),
conference_id: conference.short_title,
id: sponsorship_level.id
conference_id: conference.short_title,
id: sponsorship_level.id
end
it 'redirects to admin sponsorship_level index path' do
@ -117,8 +117,8 @@ describe Admin::SponsorshipLevelsController do
before do
allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false)
patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'),
conference_id: conference.short_title,
id: sponsorship_level.id
conference_id: conference.short_title,
id: sponsorship_level.id
end
it 'renders edit template' do

View file

@ -134,9 +134,9 @@ describe Admin::TracksController do
describe 'PATCH #update' do
context 'updates successfully' do
before :each do
patch :update, track: attributes_for(:track, color: '#FF0000'),
patch :update, track: attributes_for(:track, color: '#FF0000'),
conference_id: conference.short_title,
id: track.short_name
id: track.short_name
end
it 'assigns the correct track' do
@ -160,9 +160,9 @@ describe Admin::TracksController do
context 'update fails' do
before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false)
patch :update, track: attributes_for(:track, color: '#FF0000'),
patch :update, track: attributes_for(:track, color: '#FF0000'),
conference_id: conference.short_title,
id: track.short_name
id: track.short_name
end
it 'assigns the correct track' do

View file

@ -248,8 +248,8 @@ describe ConferenceRegistrationsController, type: :controller do
before do
@ticket = create(:ticket, conference: conference)
@purchased_ticket = create(:ticket_purchase, conference: conference,
user: user,
ticket: @ticket)
user: user,
ticket: @ticket)
get :show, conference_id: conference.short_title
end
@ -290,13 +290,13 @@ describe ConferenceRegistrationsController, type: :controller do
before do
@registration = create(:registration,
conference: conference,
user: user,
arrival: Date.new(2014, 04, 25))
user: user,
arrival: Date.new(2014, 04, 25))
end
context 'updates successfully' do
before do
patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)),
patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)),
conference_id: conference.short_title
end
@ -317,7 +317,7 @@ describe ConferenceRegistrationsController, type: :controller do
context 'update fails' do
before do
allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false)
patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)),
patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)),
conference_id: conference.short_title
end

View file

@ -31,9 +31,9 @@ describe ProposalsController do
before { create(:cfp, program: conference.program) }
it 'assigns url variables' do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
user: attributes_for(:user)
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end
@ -41,9 +41,9 @@ describe ProposalsController do
describe 'user related actions' do
before do
@new_user = attributes_for(:user)
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: @new_user
user: @new_user
end
it 'creates new user' do
@ -58,9 +58,9 @@ describe ProposalsController do
context 'creates proposal successfully' do
before(:each, run: true) do
@new_user = attributes_for(:user)
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: @new_user
user: @new_user
end
it 'assigns event variable', run: true do
@ -86,9 +86,9 @@ describe ProposalsController do
it 'creates new event' do
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
user: attributes_for(:user)
end.to change{ Event.count }.by 1
end
end
@ -96,9 +96,9 @@ describe ProposalsController do
context 'proposal save fails' do
before(:each, run: true) do
allow_any_instance_of(Event).to receive(:save).and_return(false)
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
user: attributes_for(:user)
end
it 'renders new template', run: true do
@ -112,9 +112,9 @@ describe ProposalsController do
it 'does not create new proposal' do
allow_any_instance_of(Event).to receive(:save).and_return(false)
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
user: attributes_for(:user)
end.not_to change{ Event.count }
end
end
@ -125,25 +125,25 @@ describe ProposalsController do
it 'does not create new user' do
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
user: attributes_for(:user)
end.not_to change { User.count }
end
it 'does not create new event' do
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
user: attributes_for(:user)
end.not_to change { Event.count }
end
describe 'response' do
before do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
user: attributes_for(:user)
end
it 'renders new template' do
@ -228,14 +228,14 @@ describe ProposalsController do
before { create(:cfp, program: conference.program) }
it 'assigns url variables' do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end
context 'creates proposal successfully' do
before(:each, run: true) do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
end
@ -262,7 +262,7 @@ describe ProposalsController do
it 'creates new event' do
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
end.to change{ Event.count }.by 1
end
@ -271,7 +271,7 @@ describe ProposalsController do
context 'proposal save fails' do
before(:each, run: true) do
allow_any_instance_of(Event).to receive(:save).and_return(false)
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
end
@ -286,7 +286,7 @@ describe ProposalsController do
it 'does not create new proposal' do
allow_any_instance_of(Event).to receive(:save).and_return(false)
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
end.not_to change{ Event.count }
end
@ -296,17 +296,17 @@ describe ProposalsController do
describe 'PATCH #update' do
it 'assigns url variable' do
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title,
id: event.id
id: event.id
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
context 'updates successfully' do
before do
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title,
id: event.id
id: event.id
end
it 'updates the proposal' do
@ -326,9 +326,9 @@ describe ProposalsController do
context 'update fails' do
before do
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title,
id: event.id
id: event.id
end
it 'does not update the proposal' do

View file

@ -128,9 +128,9 @@ describe TracksController do
describe 'PATCH #update' do
context 'updates successfully' do
before :each do
patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'),
patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'),
conference_id: conference.short_title,
id: self_organized_track.short_name
id: self_organized_track.short_name
end
it 'assigns the correct track' do
@ -154,9 +154,9 @@ describe TracksController do
context 'update fails' do
before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false)
patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'),
patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'),
conference_id: conference.short_title,
id: self_organized_track.short_name
id: self_organized_track.short_name
end
it 'assigns the correct track' do

View file

@ -16,15 +16,15 @@ end
def stub_env_for_omniauth
request.env['devise.mapping'] = Devise.mappings[:user]
env = OmniAuth::AuthHash.new(
provider: 'google',
uid: 'google-test-uid-1',
info: {
name: 'google user',
email: nil,
provider: 'google',
uid: 'google-test-uid-1',
info: {
name: 'google user',
email: nil,
username: 'user_google'
},
credentials: {
token: 'google_mock_token',
token: 'google_mock_token',
secret: 'google_mock_secret'
}
)