Rebuild rubocop TODOs after auto-correcting

This commit is contained in:
James Mason 2018-04-04 10:18:51 -07:00
parent 31c50255e9
commit 84dbb52d11
No known key found for this signature in database
GPG key ID: 1B3951886C449023
580 changed files with 3689 additions and 3133 deletions

View file

@ -1,24 +1,24 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::BoothsController do
let(:admin) { create(:admin) }
let(:conference) { create(:conference) }
let(:booth) { create(:booth, title: 'Title', conference: conference) }
let(:admin) { create(:admin) }
context 'not logged in user' do
describe 'GET index' do
it 'does not render admin/booths#index' do
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
expect(response).to redirect_to(user_session_path)
end
end
describe 'GET show' do
it 'does not render admin/booths#show' do
get :show, id: booth.id, conference_id: conference.short_title
get :show, params: { id: booth.id, conference_id: conference.short_title }
expect(response).to redirect_to(user_session_path)
end
end
@ -30,7 +30,7 @@ describe Admin::BoothsController do
end
describe 'GET index' do
before { get :index, conference_id: conference.short_title }
before { get :index, params: { conference_id: conference.short_title } }
it 'assigns attributes for booths' do
expect(assigns(:booths)).to eq([booth])
@ -42,7 +42,7 @@ describe Admin::BoothsController do
end
describe 'GET new' do
before { get :new, conference_id: conference.short_title }
before { get :new, params: { conference_id: conference.short_title } }
it 'assigns attributes for booths' do
expect(assigns(:booth)).to be_a_new(Booth)
@ -55,11 +55,11 @@ describe Admin::BoothsController do
describe 'POST #create' do
context 'successfully created' do
before { post :create, booth: attributes_for(:booth), conference_id: conference.short_title }
before { post :create, params: { booth: attributes_for(:booth), conference_id: conference.short_title } }
it 'creates a new booth' do
expected = expect do
post :create, booth: attributes_for(:booth), conference_id: conference.short_title
post :create, params: { booth: attributes_for(:booth), conference_id: conference.short_title }
end
expected.to change { Booth.count }.by(1)
end
@ -78,11 +78,11 @@ describe Admin::BoothsController do
end
context 'create action fails' do
before { post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title }
before { post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } }
it 'does not create any record' do
expected = expect do
post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title
post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title }
end
expected.to_not change(Booth, :count)
end
@ -98,7 +98,7 @@ describe Admin::BoothsController do
end
describe 'GET #edit' do
before { get :edit, id: booth.id, conference_id: conference.short_title }
before { get :edit, params: { id: booth.id, conference_id: conference.short_title } }
it 'renders edit template' do
expect(response).to render_template('edit')
@ -111,7 +111,7 @@ describe Admin::BoothsController do
describe 'PATCH #update' do
context 'updates suchessfully' do
before { patch :update, id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title }
before { patch :update, params: { id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title } }
it 'redirects to admin booth index path' do
expect(response).to redirect_to admin_conference_booths_path
end

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::CommentsController, type: :controller do
# It is necessary to use bang version of let to build roles before user
let(:conference) { create(:conference) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }

View file

@ -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

View file

@ -1,11 +1,13 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::EventSchedulesController do
let(:venue) { create(:venue) }
let(:conference) { create(:conference, venue: venue) }
let(:room) { create(:room, venue: venue) }
let(:schedule) { create(:schedule, program: conference.program)}
let(:event_schedule) { create(:event_schedule, schedule: schedule)}
let(:schedule) { create(:schedule, program: conference.program) }
let(:event_schedule) { create(:event_schedule, schedule: schedule) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
let(:organizer) { create(:user, role_ids: organizer_role.id) }
@ -18,16 +20,16 @@ describe Admin::EventSchedulesController do
describe 'POST #create' do
context 'with valid attributes' do
let(:create_action) do
post :create, conference_id: conference.short_title, event_schedule:
post :create, params: { 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)
start_time: conference.start_date + conference.start_hour.hours) }
end
it 'saves the event schedule to the database' do
expect{ create_action }.to change { EventSchedule.count }.by 1
expect { create_action }.to change { EventSchedule.count }.by 1
end
it 'has 200 status code' do
@ -37,18 +39,17 @@ describe Admin::EventSchedulesController do
end
context 'with invalid attributes' do
let(:create_action) do
post :create, conference_id: conference.short_title, event_schedule:
post :create, params: { conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: nil,
room_id: nil,
start_time: nil)
start_time: nil) }
end
it 'does not save the event schedule to the database' do
expect{ create_action }.to_not change { EventSchedule.count }
expect { create_action }.to_not change { EventSchedule.count }
end
it 'has 422 status code' do
@ -61,12 +62,12 @@ describe Admin::EventSchedulesController do
describe 'POST #update' do
context 'with valid attributes' do
before :each do
patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule:
patch :update, params: { 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)
start_time: conference.start_date + conference.start_hour.hours) }
event_schedule.reload
end
@ -85,15 +86,15 @@ describe Admin::EventSchedulesController do
context 'with invalid attributes' do
let(:update_action) do
patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule:
patch :update, params: { 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)
start_time: nil) }
end
it 'does not save the event schedule to the database' do
expect{ update_action }.to_not change { event_schedule }
expect { update_action }.to_not change { event_schedule }
end
it 'has 422 status code' do
@ -105,11 +106,11 @@ describe Admin::EventSchedulesController do
describe 'DELETE #destroy' do
let(:destroy_action) do
delete :destroy, id: event_schedule.id, conference_id: conference.short_title
delete :destroy, params: { id: event_schedule.id, conference_id: conference.short_title }
end
it 'deletes the event schedule' do
expect{ destroy_action }.to change { EventSchedule.count }.by(-1)
expect { destroy_action }.to change { EventSchedule.count }.by(-1)
end
it 'has 200 status code' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::EventsController do
@ -16,7 +18,7 @@ describe Admin::EventsController do
describe 'GET #show' do
before :each do
sign_in(organizer)
get :show, id: event_without_commercial.id, conference_id: conference.short_title
get :show, params: { id: event_without_commercial.id, conference_id: conference.short_title }
end
it 'assigns versions' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::OrganizationsController do
@ -35,13 +37,13 @@ describe Admin::OrganizationsController do
describe 'POST #create' do
it 'does not create new organization' do
expected = expect do
post :create, organization: attributes_for(:organization)
post :create, params: { organization: attributes_for(:organization) }
end
expected.to_not change(Organization, :count)
end
it 'redirects to root' do
post :create, organization: attributes_for(:organization)
post :create, params: { organization: attributes_for(:organization) }
expect(flash[:alert]).to eq('You are not authorized to access this page.')
expect(response).to redirect_to(root_path)
@ -51,7 +53,7 @@ describe Admin::OrganizationsController do
describe 'PATCH #update' do
it 'does not update and redirects to root' do
old_name = organization.name
patch :update, id: organization.id, organization: attributes_for(:organization, name: 'new name')
patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: 'new name') }
organization.reload
expect(organization.name).to eq(old_name)
@ -64,13 +66,13 @@ describe Admin::OrganizationsController do
context 'for a valid organization' do
it 'does not destroy a resource' do
expected = expect do
delete :destroy, id: organization.id
delete :destroy, params: { id: organization.id }
end
expected.to_not change(Organization, :count)
end
it 'redirects to root' do
delete :destroy, id: organization.id
delete :destroy, params: { id: organization.id }
expect(flash[:alert]).to eq('You are not authorized to access this page.')
expect(response).to redirect_to(root_path)
@ -102,13 +104,13 @@ describe Admin::OrganizationsController do
context 'with valid attributes' do
it 'creates new organization' do
expected = expect do
post :create, organization: attributes_for(:organization)
post :create, params: { organization: attributes_for(:organization) }
end
expected.to change { Organization.count }.by(1)
end
it 'redirects to index' do
post :create, organization: attributes_for(:organization)
post :create, params: { organization: attributes_for(:organization) }
expect(flash[:notice]).to eq('Organization successfully created')
expect(response).to redirect_to(admin_organizations_path)
@ -118,13 +120,13 @@ describe Admin::OrganizationsController do
context 'with invalid attributes' do
it 'does not create new organization' do
expected = expect do
post :create, organization: attributes_for(:organization, name: '')
post :create, params: { organization: attributes_for(:organization, name: '') }
end
expected.to_not change(Organization, :count)
end
it 'redirects to new' do
post :create, organization: attributes_for(:organization, name: '')
post :create, params: { organization: attributes_for(:organization, name: '') }
expect(flash[:error]).to eq("Name can't be blank")
expect(response).to redirect_to(new_admin_organization_path)
@ -134,7 +136,7 @@ describe Admin::OrganizationsController do
describe 'PATCH #update' do
it 'saves and redirects to index when the attributes are valid' do
patch :update, id: organization.id, organization: attributes_for(:organization, name: 'changed name')
patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: 'changed name') }
organization.reload
expect(organization.name).to eq('changed name')
@ -143,7 +145,7 @@ describe Admin::OrganizationsController do
end
it 'redirects to edit when attributes are invalid' do
patch :update, id: organization.id, organization: attributes_for(:organization, name: '')
patch :update, params: { id: organization.id, organization: attributes_for(:organization, name: '') }
expect(flash[:error]).to eq("Name can't be blank")
expect(response).to redirect_to(edit_admin_organization_path(organization))
@ -154,13 +156,13 @@ describe Admin::OrganizationsController do
context 'for a valid organization' do
it 'should successfully destroy a resource' do
expected = expect do
delete :destroy, id: organization.id
delete :destroy, params: { id: organization.id }
end
expected.to change { Organization.count }.by(-1)
end
it 'redirects to index' do
delete :destroy, id: organization.id
delete :destroy, params: { id: organization.id }
expect(flash[:notice]).to eq('Organization successfully destroyed')
expect(response).to redirect_to(admin_organizations_path)
@ -172,8 +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,
user: { email: user.email }
post :assign_org_admins, params: { id: organization.id, user: { email: user.email } }
end
it 'assigns organization_admin role' do
@ -186,8 +187,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,
user: { email: org_admin_user.email }
delete :unassign_org_admins, params: { id: organization.id, user: { email: org_admin_user.email } }
end
it 'unassigns organization_admin role' do

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::ProgramsController, type: :controller do
# It is necessary to use bang version of let to build roles before user
let(:conference) { create(:conference) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
@ -10,7 +11,7 @@ describe Admin::ProgramsController, type: :controller do
context 'not logged in user' do
describe 'GET #show' do
it 'does not render admin/programs#show' do
get :show, conference_id: conference.short_title
get :show, params: { conference_id: conference.short_title }
expect(response).to redirect_to(user_session_path)
end
end
@ -23,7 +24,7 @@ describe Admin::ProgramsController, type: :controller do
describe 'PATCH #update' do
it 'redirects to admin/programs#index' do
patch :update, conference_id: conference.short_title, program: attributes_for(:program)
patch :update, params: { conference_id: conference.short_title, program: attributes_for(:program) }
conference.program.reload
expect(response).to redirect_to admin_conference_program_path(conference.short_title)
end

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::RegistrationPeriodsController do
# It is necessary to use bang version of let to build roles before user
let(:conference) { create(:conference) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
@ -11,35 +12,33 @@ describe Admin::RegistrationPeriodsController do
let(:participant) { create(:user) }
shared_examples 'access as administration or organizer' do
before do
conference.registration_period = create(:registration_period)
end
describe 'PATCH #update' do
context 'valid attributes' do
it 'locates the requested registration period object' do
patch :update, conference_id: conference.short_title, registration_period: attributes_for(:registration_period)
patch :update, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period) }
expect(assigns(:registration_period)).to eq(conference.registration_period)
end
it 'changes registration period attributes' do
the_date = conference.end_date - 10
patch :update, conference_id: conference.short_title, registration_period:
attributes_for(:registration_period, start_date: the_date)
patch :update, params: { conference_id: conference.short_title, registration_period:
attributes_for(:registration_period, start_date: the_date) }
conference.reload
expect(conference.registration_period.start_date.to_s).to eq(the_date.to_s)
end
it 'redirects to the updated registration period' do
patch :update, conference_id: conference.short_title, registration_period:
attributes_for(:registration_period)
patch :update, params: { conference_id: conference.short_title, registration_period:
attributes_for(:registration_period) }
conference.reload
expect(response).to redirect_to admin_conference_registration_period_path(
conference.short_title)
conference.short_title
)
end
it 'sends email notification on conference registration date update' do
@ -50,10 +49,10 @@ describe Admin::RegistrationPeriodsController do
start_date: Date.today,
end_date: Date.today + 2.days)
patch :update, conference_id: conference.short_title, registration_period:
patch :update, params: { 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
@ -64,41 +63,34 @@ describe Admin::RegistrationPeriodsController do
context 'with valid attributes' do
it 'saves the registration period to the database' do
expected = expect do
post :create,
conference_id: conference.short_title,
registration_period: attributes_for(:registration_period)
post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period) }
end
expected.to change { RegistrationPeriod.count }.by 1
end
it 'redirects to registration_periods#show' do
post :create,
conference_id: conference.short_title,
registration_period: attributes_for(:registration_period)
post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period) }
expect(response).to redirect_to admin_conference_registration_period_path(
assigns[:conference].short_title)
assigns[:conference].short_title
)
end
end
context 'with invalid attributes' do
it 'does not save the registration period to the database' do
expected = expect do
post :create,
conference_id: conference.short_title,
registration_period: attributes_for(:registration_period,
start_date: nil,
end_date: nil)
post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period,
start_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,
registration_period: attributes_for(:registration_period,
start_date: nil,
end_date: nil)
post :create, params: { conference_id: conference.short_title, registration_period: attributes_for(:registration_period,
start_date: nil,
end_date: nil) }
expect(response).to be_success
end
end
@ -106,58 +98,56 @@ describe Admin::RegistrationPeriodsController do
describe 'GET #edit' do
it 'assigns the requested registration period to @registration_period' do
get :edit, conference_id: conference.short_title
get :edit, params: { conference_id: conference.short_title }
expect(assigns(:registration_period)).to eq conference.registration_period
end
it 'renders the show template' do
get :edit, conference_id: conference.short_title
get :edit, params: { conference_id: conference.short_title }
expect(response).to render_template :edit
end
end
describe 'GET #show' do
it 'assigns the requested registration period to @registration_period' do
get :show, conference_id: conference.short_title
get :show, params: { conference_id: conference.short_title }
expect(assigns(:registration_period)).to eq conference.registration_period
end
it 'renders the show template' do
get :show, conference_id: conference.short_title
get :show, params: { conference_id: conference.short_title }
expect(response).to render_template :show
end
end
describe 'GET #new' do
it 'assigns a new registration period to @registration_period' do
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
expect(assigns(:registration_period)).to be_a_new(RegistrationPeriod)
end
it 'renders the :new template' do
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
expect(response).to render_template :new
end
end
describe 'DELETE #destroy' do
it 'it deletes the registration period' do
expect { delete :destroy, conference_id: conference.short_title }.to change(RegistrationPeriod, :count).by(-1)
expect { delete :destroy, params: { conference_id: conference.short_title } }.to change(RegistrationPeriod, :count).by(-1)
end
it 'redirects to users#show' do
delete :destroy, conference_id: conference.short_title
delete :destroy, params: { conference_id: conference.short_title }
expect(response).to redirect_to admin_conference_registration_period_path
end
end
end
describe 'organizer access' do
before(:each) do
sign_in(organizer)
end
it_behaves_like 'access as administration or organizer'
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::RolesController do
@ -12,7 +14,7 @@ describe Admin::RolesController do
describe 'GET #index' do
before :each do
sign_in(admin)
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
end
it 'assigns default value to selection variable' do
@ -43,9 +45,7 @@ describe Admin::RolesController do
describe 'PATCH #update' do
before :each do
sign_in admin
patch :update, conference_id: conference.short_title,
id: 'cfp',
role: { description: 'New description for cfp role!' }
patch :update, params: { conference_id: conference.short_title, id: 'cfp', role: { description: 'New description for cfp role!' } }
end
it 'changes the description of the role' do
@ -56,9 +56,7 @@ describe Admin::RolesController do
describe 'POST #toggle' do
before :each do
sign_in admin
post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io' },
id: 'cfp'
post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io' }, id: 'cfp' }
end
context 'assigns correct values to variables' do
@ -77,17 +75,13 @@ 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'
post :toggle_user, params: { conference_id: conference.short_title, 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'
post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io' }, id: 'organizer' }
expect(user1.roles).to eq [organizer_role, cfp_role]
end
@ -95,23 +89,17 @@ 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'
post :toggle_user, params: { conference_id: conference.short_title, 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'
post :toggle_user, params: { conference_id: conference.short_title, 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'
post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io', state: 'false' }, id: 'cfp' }
user1.reload
expect(user1.roles).to eq [organizer_role]
@ -120,15 +108,11 @@ 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'
post :toggle_user, params: { conference_id: conference.short_title, 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'
post :toggle_user, params: { conference_id: conference.short_title, user: { email: 'user1@osem.io', state: 'false' }, id: 'organizer' }
expect(organizer_role.users).to eq [user1]
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::RoomsController do
@ -10,7 +12,7 @@ describe Admin::RoomsController do
before { sign_in admin }
describe 'GET #index' do
before { get :index, conference_id: conference.short_title }
before { get :index, params: { conference_id: conference.short_title } }
it 'assigns conference, venue and rooms variables' do
expect(assigns(:conference)).to eq conference
@ -24,7 +26,7 @@ describe Admin::RoomsController do
end
describe 'GET #edit' do
before { get :edit, conference_id: conference.short_title, id: room.id }
before { get :edit, params: { conference_id: conference.short_title, id: room.id } }
it 'renders edit template' do
expect(response).to render_template('edit')
@ -36,7 +38,7 @@ describe Admin::RoomsController do
end
describe 'GET #new' do
before { get :new, conference_id: conference.short_title }
before { get :new, params: { conference_id: conference.short_title } }
it 'renders new template' do
expect(response).to render_template('new')
@ -50,7 +52,7 @@ describe Admin::RoomsController do
describe 'POST #create' do
context 'saves successfuly' do
before do
post :create, room: attributes_for(:room), conference_id: conference.short_title
post :create, params: { room: attributes_for(:room), conference_id: conference.short_title }
end
it 'redirects to admin room index path' do
@ -69,7 +71,7 @@ describe Admin::RoomsController do
context 'save fails' do
before do
allow_any_instance_of(Room).to receive(:save).and_return(false)
post :create, room: attributes_for(:room), conference_id: conference.short_title
post :create, params: { room: attributes_for(:room), conference_id: conference.short_title }
end
it 'renders new template' do
@ -89,9 +91,7 @@ describe Admin::RoomsController do
describe 'PATCH #update' do
context 'updates successfully' do
before do
patch :update, room: attributes_for(:room, size: 2),
conference_id: conference.short_title,
id: room.id
patch :update, params: { room: attributes_for(:room, size: 2), conference_id: conference.short_title, id: room.id }
end
it 'redirects to admin room index path' do
@ -111,9 +111,7 @@ 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),
conference_id: conference.short_title,
id: room.id
patch :update, params: { room: attributes_for(:room, size: 2), conference_id: conference.short_title, id: room.id }
end
it 'renders edit template' do
@ -133,7 +131,7 @@ describe Admin::RoomsController do
describe 'DELETE #destroy' do
context 'deletes successfully' do
before { delete :destroy, conference_id: conference.short_title, id: room.id }
before { delete :destroy, params: { conference_id: conference.short_title, id: room.id } }
it 'redirects to admin room index path' do
expect(response).to redirect_to admin_conference_venue_rooms_path(conference_id: conference.short_title)
@ -151,7 +149,7 @@ describe Admin::RoomsController do
context 'delete fails' do
before do
allow_any_instance_of(Room).to receive(:destroy).and_return(false)
delete :destroy, conference_id: conference.short_title, id: room.id
delete :destroy, params: { conference_id: conference.short_title, id: room.id }
end
it 'redirects to admin room index path' do

View file

@ -1,8 +1,10 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::SchedulesController do
let(:conference) { create(:conference) }
let(:schedule) { create(:schedule, program: conference.program)}
let(:schedule) { create(:schedule, program: conference.program) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
let(:organizer) { create(:user, role_ids: organizer_role.id) }
@ -14,27 +16,28 @@ describe Admin::SchedulesController do
describe 'GET #index' do
it 'renders the index template' do
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
expect(response).to render_template :index
end
end
describe 'POST #create' do
let(:create_action){ post :create, conference_id: conference.short_title }
let(:create_action) { post :create, params: { conference_id: conference.short_title } }
it 'saves the schedule to the database' do
expect{ create_action }.to change { Schedule.count }.by 1
expect { create_action }.to change { Schedule.count }.by 1
end
it 'redirects to schedules#show' do
create_action
expect(response).to redirect_to admin_conference_schedule_path(
conference.short_title, assigns[:schedule])
conference.short_title, assigns[:schedule]
)
end
end
describe 'GET #show' do
let(:show_action){ get :show, id: schedule.id, conference_id: conference.short_title }
let(:show_action) { get :show, params: { id: schedule.id, conference_id: conference.short_title } }
it 'assigns the requested schedule to schedule' do
show_action
@ -48,10 +51,10 @@ describe Admin::SchedulesController do
end
describe 'DELETE #destroy' do
let(:destroy_action){ delete :destroy, id: schedule.id, conference_id: conference.short_title }
let(:destroy_action) { delete :destroy, params: { id: schedule.id, conference_id: conference.short_title } }
it 'deletes the schedule' do
expect{ destroy_action }.to change { Schedule.count }.by(-1)
expect { destroy_action }.to change { Schedule.count }.by(-1)
end
it 'redirects to schedules#index' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::SponsorshipLevelsController do
@ -9,7 +11,7 @@ describe Admin::SponsorshipLevelsController do
before { sign_in admin }
describe 'GET #index' do
before { get :index, conference_id: conference.short_title }
before { get :index, params: { conference_id: conference.short_title } }
it 'assigns conference and sponsorship_levels variables' do
expect(assigns(:conference)).to eq conference
@ -22,7 +24,7 @@ describe Admin::SponsorshipLevelsController do
end
describe 'GET #edit' do
before { get :edit, conference_id: conference.short_title, id: sponsorship_level.id }
before { get :edit, params: { conference_id: conference.short_title, id: sponsorship_level.id } }
it 'renders edit template' do
expect(response).to render_template('edit')
@ -34,7 +36,7 @@ describe Admin::SponsorshipLevelsController do
end
describe 'GET #new' do
before { get :new, conference_id: conference.short_title }
before { get :new, params: { conference_id: conference.short_title } }
it 'renders new template' do
expect(response).to render_template('new')
@ -48,8 +50,7 @@ describe Admin::SponsorshipLevelsController do
describe 'POST #create' do
context 'saves successfuly' do
before(:each, run: true) do
post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title
post :create, params: { sponsorship_level: attributes_for(:sponsorship_level), conference_id: conference.short_title }
end
it 'redirects to admin sponsorship_level index path', run: true do
@ -62,17 +63,15 @@ 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
end.to change{ conference.sponsorship_levels.count }.from(0).to(1)
post :create, params: { sponsorship_level: attributes_for(:sponsorship_level), conference_id: conference.short_title }
end.to change { conference.sponsorship_levels.count }.from(0).to(1)
end
end
context 'save fails' 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
post :create, params: { sponsorship_level: attributes_for(:sponsorship_level), conference_id: conference.short_title }
end
it 'renders new template' do
@ -92,9 +91,7 @@ describe Admin::SponsorshipLevelsController do
describe 'PATCH #update' 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
patch :update, params: { sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), conference_id: conference.short_title, id: sponsorship_level.id }
end
it 'redirects to admin sponsorship_level index path' do
@ -114,9 +111,7 @@ describe Admin::SponsorshipLevelsController do
context 'update fails' 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
patch :update, params: { sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), conference_id: conference.short_title, id: sponsorship_level.id }
end
it 'renders edit template' do
@ -137,7 +132,7 @@ describe Admin::SponsorshipLevelsController do
describe 'DELETE #destroy' do
context 'deletes successfully' do
before(:each, run: true) do
delete :destroy, conference_id: conference.short_title, id: sponsorship_level.id
delete :destroy, params: { conference_id: conference.short_title, id: sponsorship_level.id }
end
it 'redirects to admin sponsorship_level index path', run: true do
@ -151,15 +146,15 @@ describe Admin::SponsorshipLevelsController do
it 'deletes the sponsorship_level' do
sponsorship_level
expect do
delete :destroy, conference_id: conference.short_title, id: sponsorship_level.id
end.to change{ conference.sponsorship_levels.count }.from(1).to(0)
delete :destroy, params: { conference_id: conference.short_title, id: sponsorship_level.id }
end.to change { conference.sponsorship_levels.count }.from(1).to(0)
end
end
context 'delete fails' do
before do
allow_any_instance_of(SponsorshipLevel).to receive(:destroy).and_return(false)
delete :destroy, conference_id: conference.short_title, id: sponsorship_level.id
delete :destroy, params: { conference_id: conference.short_title, id: sponsorship_level.id }
end
it 'redirects to admin sponsorship_level index path' do
@ -180,7 +175,7 @@ describe Admin::SponsorshipLevelsController do
before do
sponsorship_level
@second_sponsorship_level = create(:sponsorship_level, conference: conference)
patch :up, conference_id: conference.short_title, id: @second_sponsorship_level.id
patch :up, params: { conference_id: conference.short_title, id: @second_sponsorship_level.id }
end
it 'moves sponsorship_level up by one position' do
@ -195,7 +190,7 @@ describe Admin::SponsorshipLevelsController do
before do
sponsorship_level
@second_sponsorship_level = create(:sponsorship_level, conference: conference)
patch :down, conference_id: conference.short_title, id: sponsorship_level.id
patch :down, params: { conference_id: conference.short_title, id: sponsorship_level.id }
end
it 'moves sponsorship_level down by one position' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::TargetsController, type: :controller do
@ -9,7 +11,7 @@ describe Admin::TargetsController, type: :controller do
before { sign_in admin }
describe 'GET #index' do
before { get :index, conference_id: conference.short_title }
before { get :index, params: { conference_id: conference.short_title } }
it 'renders index template' do
expect(response).to render_template('index')
@ -22,7 +24,7 @@ describe Admin::TargetsController, type: :controller do
end
describe 'GET #new' do
before { get :new, conference_id: conference.short_title }
before { get :new, params: { conference_id: conference.short_title } }
it 'renders new template' do
expect(response).to render_template('new')
@ -36,7 +38,7 @@ describe Admin::TargetsController, type: :controller do
describe 'POST #create' do
context 'saves successfuly' do
before do
post :create, target: attributes_for(:target), conference_id: conference.short_title
post :create, params: { target: attributes_for(:target), conference_id: conference.short_title }
end
it 'redirects to admin target index path' do
@ -55,7 +57,7 @@ describe Admin::TargetsController, type: :controller do
context 'save fails' do
before do
allow_any_instance_of(Target).to receive(:save).and_return(false)
post :create, target: attributes_for(:target), conference_id: conference.short_title
post :create, params: { target: attributes_for(:target), conference_id: conference.short_title }
end
it 'renders new template' do
@ -73,7 +75,7 @@ describe Admin::TargetsController, type: :controller do
end
describe 'GET #edit' do
before { get :edit, conference_id: conference.short_title, id: target.id }
before { get :edit, params: { conference_id: conference.short_title, id: target.id } }
it 'renders edit template' do
expect(response).to render_template('edit')
@ -87,9 +89,7 @@ describe Admin::TargetsController, type: :controller do
describe 'PATCH #update' do
context 'updates successfully' do
before do
patch :update, target: attributes_for(:target, target_count: 2),
conference_id: conference.short_title,
id: target.id
patch :update, params: { target: attributes_for(:target, target_count: 2), conference_id: conference.short_title, id: target.id }
end
it 'redirects to admin target index path' do
@ -109,9 +109,7 @@ describe Admin::TargetsController, type: :controller do
context 'update fails' do
before do
allow_any_instance_of(Target).to receive(:save).and_return(false)
patch :update, target: attributes_for(:target, target_count: 2),
conference_id: conference.short_title,
id: target.id
patch :update, params: { target: attributes_for(:target, target_count: 2), conference_id: conference.short_title, id: target.id }
end
it 'renders edit template' do
@ -130,7 +128,7 @@ describe Admin::TargetsController, type: :controller do
describe 'DELETE #destroy' do
context 'deletes successfully' do
before { delete :destroy, conference_id: conference.short_title, id: target.id }
before { delete :destroy, params: { conference_id: conference.short_title, id: target.id } }
it 'redirects to admin target index path' do
expect(response).to redirect_to admin_conference_targets_path(conference_id: conference.short_title)
@ -148,7 +146,7 @@ describe Admin::TargetsController, type: :controller do
context 'delete fails' do
before do
allow_any_instance_of(Target).to receive(:destroy).and_return(false)
delete :destroy, conference_id: conference.short_title, id: target.id
delete :destroy, params: { conference_id: conference.short_title, id: target.id }
end
it 'redirects to admin target index path' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::TicketScanningsController do
@ -16,13 +18,13 @@ describe Admin::TicketScanningsController do
describe 'POST #create' do
it 'does not create new ticket scanning' do
expected = expect do
post :create, physical_ticket_id: physical_ticket.token
post :create, params: { physical_ticket_id: physical_ticket.token }
end
expected.to_not change(TicketScanning, :count)
end
it 'redirects to root' do
post :create, physical_ticket_id: physical_ticket.token
post :create, params: { physical_ticket_id: physical_ticket.token }
expect(flash[:alert]).to eq('You are not authorized to access this page.')
expect(response).to redirect_to(root_path)
end
@ -37,13 +39,13 @@ describe Admin::TicketScanningsController do
context 'with valid physical_ticket' do
it 'creates new ticket scanning' do
expected = expect do
post :create, physical_ticket_id: physical_ticket.token
post :create, params: { physical_ticket_id: physical_ticket.token }
end
expected.to change { TicketScanning.count }.by(1)
end
it 'redirects to index' do
post :create, physical_ticket_id: physical_ticket.token
post :create, params: { physical_ticket_id: physical_ticket.token }
expect(flash[:notice]).to eq("Ticket with token #{physical_ticket.token} successfully scanned.")
expect(response).to redirect_to(conferences_path)
end
@ -52,7 +54,7 @@ describe Admin::TicketScanningsController do
context 'with Invalid physical_ticket' do
it 'raises exception' do
expected = expect do
post :create, physical_ticket_id: 'XXXX'
post :create, params: { physical_ticket_id: 'XXXX' }
end
expected.to raise_exception(ActiveRecord::RecordNotFound)
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::TracksController do
@ -15,7 +17,7 @@ describe Admin::TracksController do
describe 'GET #index' do
before :each do
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
end
it 'assigns @tracks with the correct values' do
@ -31,7 +33,7 @@ describe Admin::TracksController do
describe 'GET #show' do
before :each do
get :show, conference_id: conference.short_title, id: track.short_name
get :show, params: { conference_id: conference.short_title, id: track.short_name }
end
it 'assigns the correct track' do
@ -45,7 +47,7 @@ describe Admin::TracksController do
describe 'GET #new' do
before :each do
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
end
it 'assigns a new track with the correct conference' do
@ -62,7 +64,7 @@ describe Admin::TracksController do
describe 'POST #create' do
context 'saves successfuly' do
before :each do
post :create, track: attributes_for(:track), conference_id: conference.short_title
post :create, params: { track: attributes_for(:track), conference_id: conference.short_title }
end
it 'assigns a new track with the correct conference' do
@ -92,7 +94,7 @@ describe Admin::TracksController do
context 'save fails' do
before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false)
post :create, track: attributes_for(:track, short_name: 'my_track'), conference_id: conference.short_title
post :create, params: { track: attributes_for(:track, short_name: 'my_track'), conference_id: conference.short_title }
end
it 'assigns a new track with the correct conference' do
@ -117,7 +119,7 @@ describe Admin::TracksController do
describe 'GET #edit' do
before :each do
get :edit, conference_id: conference.short_title, id: track.short_name
get :edit, params: { conference_id: conference.short_title, id: track.short_name }
end
it 'assigns the correct track' do
@ -132,9 +134,7 @@ describe Admin::TracksController do
describe 'PATCH #update' do
context 'updates successfully' do
before :each do
patch :update, track: attributes_for(:track, color: '#FF0000'),
conference_id: conference.short_title,
id: track.short_name
patch :update, params: { track: attributes_for(:track, color: '#FF0000'), conference_id: conference.short_title, id: track.short_name }
end
it 'assigns the correct track' do
@ -158,9 +158,7 @@ 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'),
conference_id: conference.short_title,
id: track.short_name
patch :update, params: { track: attributes_for(:track, color: '#FF0000'), conference_id: conference.short_title, id: track.short_name }
end
it 'assigns the correct track' do
@ -185,7 +183,7 @@ describe Admin::TracksController do
describe 'DELETE #destroy' do
context 'deletes successfully' do
before :each do
delete :destroy, conference_id: conference.short_title, id: track.short_name
delete :destroy, params: { conference_id: conference.short_title, id: track.short_name }
end
it 'redirects to admin tracks index path' do
@ -204,7 +202,7 @@ describe Admin::TracksController do
context 'delete fails' do
before :each do
allow_any_instance_of(Track).to receive(:destroy).and_return(false)
delete :destroy, conference_id: conference.short_title, id: track.short_name
delete :destroy, params: { conference_id: conference.short_title, id: track.short_name }
end
it 'assigns the correct track' do
@ -234,7 +232,7 @@ describe Admin::TracksController do
context 'toggles successfully' do
before :each do
patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js
patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js }
self_organized_track.reload
end
@ -254,7 +252,7 @@ describe Admin::TracksController do
context 'save fails' do
before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false)
patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js
patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js }
self_organized_track.reload
end
@ -280,7 +278,7 @@ describe Admin::TracksController do
context 'toggles successfully' do
before :each do
patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js
patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js }
self_organized_track.reload
end
@ -300,7 +298,7 @@ describe Admin::TracksController do
context 'save fails' do
before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false)
patch :toggle_cfp_inclusion, conference_id: conference.short_title, id: self_organized_track.short_name, format: :js
patch :toggle_cfp_inclusion, params: { conference_id: conference.short_title, id: self_organized_track.short_name, format: :js }
self_organized_track.reload
end
@ -323,7 +321,7 @@ describe Admin::TracksController do
before :each do
self_organized_track.state = 'canceled'
self_organized_track.save!
patch :restart, conference_id: conference.short_title, id: self_organized_track.short_name
patch :restart, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -342,7 +340,7 @@ describe Admin::TracksController do
describe 'PATCH #to_accept' do
before :each do
patch :to_accept, conference_id: conference.short_title, id: self_organized_track.short_name
patch :to_accept, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -362,7 +360,7 @@ describe Admin::TracksController do
describe 'PATCH #accept' do
shared_examples 'fails to accept' do
before :each do
patch :accept, conference_id: conference.short_title, id: self_organized_track.short_name
patch :accept, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
end
it 'assigns the correct track' do
@ -380,7 +378,7 @@ describe Admin::TracksController do
context 'has start_date, end_date and room' do
before :each do
patch :accept, conference_id: conference.short_title, id: self_organized_track.short_name
patch :accept, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -470,7 +468,7 @@ describe Admin::TracksController do
before :each do
self_organized_track.state = 'accepted'
self_organized_track.save!
patch :confirm, conference_id: conference.short_title, id: self_organized_track.short_name
patch :confirm, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -489,7 +487,7 @@ describe Admin::TracksController do
describe 'PATCH #to_reject' do
before :each do
patch :to_reject, conference_id: conference.short_title, id: self_organized_track.short_name
patch :to_reject, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -508,7 +506,7 @@ describe Admin::TracksController do
describe 'PATCH #reject' do
before :each do
patch :reject, conference_id: conference.short_title, id: self_organized_track.short_name
patch :reject, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -529,7 +527,7 @@ describe Admin::TracksController do
before :each do
self_organized_track.state = 'confirmed'
self_organized_track.save!
patch :cancel, conference_id: conference.short_title, id: self_organized_track.short_name
patch :cancel, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::UsersController do
let(:admin) { create(:admin) }
@ -21,12 +23,12 @@ describe Admin::UsersController do
describe 'PATCH #toggle_confirmation' do
it 'confirms user' do
user_to_confirm = create(:user, email: 'unconfirmed_user@osem.io', confirmed_at: nil)
patch :toggle_confirmation, id: user_to_confirm.id, user: { to_confirm: 'true' }
patch :toggle_confirmation, params: { id: user_to_confirm.id, user: { to_confirm: 'true' } }
user_to_confirm.reload
expect(user_to_confirm.confirmed?).to eq true
end
it 'undo confirmation of user' do
patch :toggle_confirmation, id: user.id, user: { to_confirm: 'false' }
patch :toggle_confirmation, params: { id: user.id, user: { to_confirm: 'false' } }
user.reload
expect(user.confirmed?).to eq false
end
@ -34,7 +36,7 @@ describe Admin::UsersController do
describe 'PATCH #update' do
context 'valid attributes' do
before :each do
patch :update, id: user.id, user: { name: 'new name', email: 'new_email@osem.io' }
patch :update, params: { id: user.id, user: { name: 'new name', email: 'new_email@osem.io' } }
end
it 'locates requested @user' do
@ -42,8 +44,9 @@ describe Admin::UsersController do
end
it 'changes @users attributes' do
expect(build(
:user, email: 'email_new@osem.io', id: user.id).email)
.to eq('email_new@osem.io')
:user, email: 'email_new@osem.io', id: user.id
).email)
.to eq('email_new@osem.io')
end
it 'redirects to the updated user' do
expect(response).to redirect_to admin_users_path
@ -64,7 +67,7 @@ describe Admin::UsersController do
describe 'POST #create' do
context 'saves successfuly' do
before do
post :create, user: attributes_for(:user)
post :create, params: { user: attributes_for(:user) }
end
it 'redirects to admin users index path' do
@ -83,7 +86,7 @@ describe Admin::UsersController do
context 'save fails' do
before do
allow_any_instance_of(User).to receive(:save).and_return(false)
post :create, user: attributes_for(:user)
post :create, params: { user: attributes_for(:user) }
end
it 'renders new template' do
@ -96,8 +99,8 @@ describe Admin::UsersController do
it 'does not create new user' do
expect do
post :create, user: attributes_for(:user)
end.not_to change{ Event.count }
post :create, params: { user: attributes_for(:user) }
end.not_to change { Event.count }
end
end
end

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'spec_helper'
describe Admin::VersionsController do
let!(:conference) { create(:conference, short_title: 'exampletitle', description: 'Example Description') }
let(:admin) { create(:admin) }
let(:role_organizer) { conference.roles.find_by(name: 'organizer') }
@ -15,8 +16,8 @@ describe Admin::VersionsController do
end
it 'reverts all changes for update actions' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
get :revert_object, id: PaperTrail::Version.last.id
conference.update(short_title: 'testtitle', description: 'Some random text')
get :revert_object, params: { id: PaperTrail::Version.last.id }
conference.reload
expect(conference.short_title).to eq 'exampletitle'
expect(conference.description).to eq 'Example Description'
@ -25,14 +26,14 @@ describe Admin::VersionsController do
it 'shows correct flash on trying to revert create event of a deleted object' do
creation_version_id = conference.program.event_types.first.versions.first.id
conference.program.event_types.first.destroy
get :revert_object, id: creation_version_id
get :revert_object, params: { id: creation_version_id }
expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to')
end
it 'reverting deletion of object creates it again' do
conference.program.event_types.first.destroy
event_types_count = conference.program.event_types.count
get :revert_object, id: PaperTrail::Version.last.id
get :revert_object, params: { id: PaperTrail::Version.last.id }
conference.reload
expect(PaperTrail::Version.last.event).to eq 'create'
expect(conference.program.event_types.count).to eq(event_types_count + 1)
@ -40,14 +41,14 @@ describe Admin::VersionsController do
it 'reverting creation of object deletes it ' do
create(:lodging, conference: conference)
get :revert_object, id: PaperTrail::Version.last.id
get :revert_object, params: { id: PaperTrail::Version.last.id }
expect(PaperTrail::Version.last.event).to eq 'destroy'
expect(Lodging.count).to eq 0
end
it 'reverting creation of conference is not permitted' do
conference_count_before = Conference.count
get :revert_object, id: conference.versions.first.id
get :revert_object, params: { id: conference.versions.first.id }
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
expect(Conference.count).to eq(conference_count_before)
end
@ -59,40 +60,40 @@ describe Admin::VersionsController do
end
it 'reverts specified change for update actions' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
get :revert_attribute, id: PaperTrail::Version.last.id, attribute: 'short_title'
conference.update(short_title: 'testtitle', description: 'Some random text')
get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'short_title' }
conference.reload
expect(conference.short_title).to eq 'exampletitle'
expect(conference.description).to eq 'Some random text'
end
it 'shows correct flash on trying to revert to the current state' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update_attributes(short_title: 'exampletitle')
get :revert_attribute, id: PaperTrail::Version.all[-2].id, attribute: 'short_title'
conference.update(short_title: 'testtitle', description: 'Some random text')
conference.update(short_title: 'exampletitle')
get :revert_attribute, params: { id: PaperTrail::Version.all[-2].id, attribute: 'short_title' }
expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to')
expect(conference.short_title).to eq 'exampletitle'
end
it 'fails on trying to revert deleted object' do
conference.program.event_types.first.update_attributes(title: 'New Event Title')
conference.program.event_types.first.update(title: 'New Event Title')
conference.program.event_types.first.destroy
get :revert_attribute, id: PaperTrail::Version.all[-2].id, attribute: 'title'
get :revert_attribute, params: { id: PaperTrail::Version.all[-2].id, attribute: 'title' }
conference.reload
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
end
it 'fails on trying to revert creation event' do
create(:lodging, conference: conference)
get :revert_attribute, id: PaperTrail::Version.last.id, attribute: 'name'
get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'name' }
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
end
it 'revert fails when attribute is invalid' do
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update(short_title: 'testtitle', description: 'Some random text')
before_conference_title = conference.title
# Note: even though title is a valid attribute of conference, it was not updated in the change we are trying to revert
get :revert_attribute, id: PaperTrail::Version.last.id, attribute: 'title'
get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'title' }
conference.reload
expect(conference.short_title).to eq 'testtitle'
expect(conference.description).to eq 'Some random text'
@ -105,7 +106,7 @@ describe Admin::VersionsController do
it 'raises error if user is not of any role' do
user = create(:user)
sign_in user
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
expect(flash[:alert]).to match('You are not authorized to access this page.')
end
@ -113,19 +114,19 @@ describe Admin::VersionsController do
before :each do
@user = create(:user)
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
conference.update(short_title: 'testtitle', description: 'Some random text')
@version_organizer = PaperTrail::Version.last
create(:cfp, program: conference.program)
@version_cfp = PaperTrail::Version.last
registration = create(:registration, conference: conference)
registration.update_attributes(attended: true)
registration.update(attended: true)
@version_info_desk = PaperTrail::Version.last
end
it 'when user has role cfp' do
@user.roles = [role_cfp]
sign_in @user
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
expect(assigns(:versions).include?(@version_cfp)).to eq true
expect(assigns(:versions).include?(@version_organizer)).to eq false
@ -134,7 +135,7 @@ describe Admin::VersionsController do
it 'when user has role info_desk' do
@user.roles = [role_info_desk]
sign_in @user
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
expect(assigns(:versions).include?(@version_info_desk)).to eq true
expect(assigns(:versions).include?(@version_organizer)).to eq false
@ -144,7 +145,7 @@ describe Admin::VersionsController do
it 'when user has role organizer' do
@user.roles = [role_organizer]
sign_in @user
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
expect(assigns(:versions).include?(@version_organizer)).to eq true
expect(assigns(:versions).include?(@version_cfp)).to eq true

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Api::V1::ConferencesController do
@ -26,7 +28,7 @@ describe Api::V1::ConferencesController do
describe 'GET #show' do
before(:each) do
get :show, id: 'conf_two', format: :json
get :show, params: { id: 'conf_two', format: :json }
@json = JSON.parse(response.body)['conferences']
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Api::V1::EventsController do
@ -8,7 +10,6 @@ describe Api::V1::EventsController do
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
@ -21,8 +22,7 @@ describe Api::V1::EventsController do
context 'with conference scope' do
it 'returns all confirmed events of conference' do
get :index, conference_id: conference.short_title, format: :json
get :index, params: { conference_id: conference.short_title, format: :json }
json = JSON.parse(response.body)['events']
expect(response).to be_success

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Api::V1::RoomsController do
@ -9,7 +11,6 @@ describe Api::V1::RoomsController do
describe 'GET #index' do
context 'without conference scope' do
it 'returns all rooms' do
get :index, format: :json
json = JSON.parse(response.body)['rooms']
@ -23,8 +24,7 @@ describe Api::V1::RoomsController do
context 'with conference scope' do
it 'returns all rooms of conference' do
get :index, conference_id: conference.short_title, format: :json
get :index, params: { conference_id: conference.short_title, format: :json }
json = JSON.parse(response.body)['rooms']
expect(response).to be_success

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Api::V1::SpeakersController do
@ -16,7 +18,6 @@ describe Api::V1::SpeakersController do
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
@ -28,8 +29,7 @@ describe Api::V1::SpeakersController do
context 'with conference scope' do
it 'returns all speakers of conference' do
get :index, conference_id: conference.short_title, format: :json
get :index, params: { conference_id: conference.short_title, format: :json }
json = JSON.parse(response.body)['speakers']
expect(response).to be_success

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Api::V1::TracksController do
@ -8,7 +10,6 @@ describe Api::V1::TracksController do
describe 'GET #index' do
context 'without conference scope' do
it 'returns all tracks' do
get :index, format: :json
json = JSON.parse(response.body)['tracks']
@ -22,8 +23,7 @@ describe Api::V1::TracksController do
context 'with conference scope' do
it 'returns all rooms of conference' do
get :index, conference_id: conference.short_title, format: :json
get :index, params: { conference_id: conference.short_title, format: :json }
json = JSON.parse(response.body)['tracks']
expect(response).to be_success

View file

@ -1,10 +1,11 @@
# frozen_string_literal: true
require 'spec_helper'
describe ApplicationController, type: :controller do
let(:conference) { create(:conference) }
describe 'user is signed in' do
describe 'as admin' do
let(:admin) { create(:admin) }
before { sign_in(admin) }
@ -31,16 +32,13 @@ describe ApplicationController, type: :controller do
end
end
end
end
end
describe ApplicationController, type: :request do
let(:conference) { create(:conference) }
describe 'Skylight link' do
around do |example|
original_value = ENV['SKYLIGHT_PUBLIC_DASHBOARD_URL']
example.run
@ -70,7 +68,5 @@ describe ApplicationController, type: :request do
expect(response.body).to_not match(/skylight/i)
end
end
end
end

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'spec_helper'
describe BoothsController do
let(:user) { create(:user) }
let(:conference) { create(:conference) }
let(:booth) { create(:booth, title: 'Title', conference: conference) }
@ -13,7 +14,7 @@ describe BoothsController do
end
describe 'GET index' do
before { get :index, conference_id: conference.short_title }
before { get :index, params: { conference_id: conference.short_title } }
it 'assigns attributes for booths' do
expect(assigns(:booths)).to eq([booth])
@ -25,7 +26,7 @@ describe BoothsController do
end
describe 'GET #new' do
before { get :new, conference_id: conference.short_title }
before { get :new, params: { conference_id: conference.short_title } }
it 'assigns attributes for booths' do
expect(assigns(:booth)).to be_a_new(Booth)
@ -38,7 +39,7 @@ describe BoothsController do
describe 'POST #create' do
context 'successfully created' do
before { post :create, booth: attributes_for(:booth), conference_id: conference.short_title }
before { post :create, params: { booth: attributes_for(:booth), conference_id: conference.short_title } }
it 'creates a new booth' do
expect(Booth.count).to_not eq(0)
@ -58,11 +59,11 @@ describe BoothsController do
end
context 'create action fails' do
before { post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title }
before { post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title } }
it 'does not create any record' do
expected = expect do
post :create, booth: attributes_for(:booth, title: ''), conference_id: conference.short_title
post :create, params: { booth: attributes_for(:booth, title: ''), conference_id: conference.short_title }
end
expected.to_not change(Booth, :count)
end
@ -78,7 +79,7 @@ describe BoothsController do
end
describe 'GET #edit' do
before { get :edit, id: booth.id, conference_id: conference.short_title }
before { get :edit, params: { id: booth.id, conference_id: conference.short_title } }
it 'renders edit template' do
expect(response).to render_template('edit')
@ -91,7 +92,7 @@ describe BoothsController do
describe 'PATCH #update' do
context 'updates suchessfully' do
before { patch :update, id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title }
before { patch :update, params: { id: booth.id, booth: attributes_for(:booth, title: 'different'), conference_id: conference.short_title } }
it 'redirects to booth index path' do
expect(response).to redirect_to conference_booths_path

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe ConferenceRegistrationsController, type: :controller do
@ -11,7 +13,7 @@ describe ConferenceRegistrationsController, type: :controller do
before :each do
sign_in send(user) if user
stub_const('ENV', ENV.to_hash.merge('OSEM_ICHAIN_ENABLED' => ichain))
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
end
it 'redirects' do
@ -27,7 +29,7 @@ describe ConferenceRegistrationsController, type: :controller do
before :each do
sign_in send(user) if user
stub_const('ENV', ENV.to_hash.merge('OSEM_ICHAIN_ENABLED' => ichain))
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
end
it 'user variable exists' do
@ -229,7 +231,7 @@ describe ConferenceRegistrationsController, type: :controller do
context 'successful request' do
before do
get :show, conference_id: conference.short_title
get :show, params: { conference_id: conference.short_title }
end
it 'assigns variables' do
@ -248,7 +250,7 @@ describe ConferenceRegistrationsController, type: :controller do
@purchased_ticket = create(:ticket_purchase, conference: conference,
user: user,
ticket: @ticket)
get :show, conference_id: conference.short_title
get :show, params: { conference_id: conference.short_title }
end
it 'does not assign price of purchased tickets to total_price and purchased tickets to tickets without payment' do
@ -258,7 +260,7 @@ describe ConferenceRegistrationsController, type: :controller do
context 'user has not purchased any ticket' do
before do
get :show, conference_id: conference.short_title
get :show, params: { conference_id: conference.short_title }
end
it 'assigns 0 dollars to total_price and empty array to tickets variables' do
@ -271,7 +273,7 @@ describe ConferenceRegistrationsController, type: :controller do
describe 'GET #edit' do
before do
@registration = create(:registration, conference: conference, user: user)
get :edit, conference_id: conference.short_title
get :edit, params: { conference_id: conference.short_title }
end
it 'assigns conference and registration variable' do
@ -289,13 +291,12 @@ describe ConferenceRegistrationsController, type: :controller do
@registration = create(:registration,
conference: conference,
user: user,
arrival: Date.new(2014, 04, 25))
arrival: Date.new(2014, 0o4, 25))
end
context 'updates successfully' do
before do
patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)),
conference_id: conference.short_title
patch :update, params: { registration: attributes_for(:registration, arrival: Date.new(2014, 0o4, 29)), conference_id: conference.short_title }
end
it 'redirects to registration show path' do
@ -308,15 +309,14 @@ describe ConferenceRegistrationsController, type: :controller do
it 'updates the registration' do
@registration.reload
expect(@registration.arrival).to eq Date.new(2014, 04, 29)
expect(@registration.arrival).to eq Date.new(2014, 0o4, 29)
end
end
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)),
conference_id: conference.short_title
patch :update, params: { registration: attributes_for(:registration, arrival: Date.new(2014, 0o4, 27)), conference_id: conference.short_title }
end
it 'renders edit template' do
@ -329,7 +329,7 @@ describe ConferenceRegistrationsController, type: :controller do
it 'does not update the registration' do
@registration.reload
expect(@registration.arrival).to eq Date.new(2014, 04, 25)
expect(@registration.arrival).to eq Date.new(2014, 0o4, 25)
end
end
end
@ -341,7 +341,7 @@ describe ConferenceRegistrationsController, type: :controller do
context 'deletes successfully' do
before(:each, run: true) do
delete :destroy, conference_id: conference.short_title
delete :destroy, params: { conference_id: conference.short_title }
end
it 'redirects to root path', run: true do
@ -354,15 +354,15 @@ describe ConferenceRegistrationsController, type: :controller do
it 'deletes the registration' do
expect do
delete :destroy, conference_id: conference.short_title
end.to change{ Registration.count }.from(2).to(1)
delete :destroy, params: { conference_id: conference.short_title }
end.to change { Registration.count }.from(2).to(1)
end
end
context 'delete fails' do
before do
allow_any_instance_of(Registration).to receive(:destroy).and_return(false)
delete :destroy, conference_id: conference.short_title
delete :destroy, params: { conference_id: conference.short_title }
end
it 'redirects to registration show path' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe ConferencesController do
@ -15,12 +17,12 @@ describe ConferencesController do
describe 'GET #show' do
context 'conference made public' 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
end
@ -46,5 +48,4 @@ describe ConferencesController do
expect(response.response_code).to eq(200)
end
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe ConfirmationsController do
@ -9,7 +11,7 @@ describe ConfirmationsController do
context 'user is not signed in' do
it 'confirms and signs in user' do
get :show, confirmation_token: user.confirmation_token
get :show, params: { confirmation_token: user.confirmation_token }
user.reload
expect(user.confirmed?).to eq true
expect(controller.current_user).to eq user
@ -20,7 +22,7 @@ describe ConfirmationsController do
before { sign_in user }
it 'confirms user' do
get :show, confirmation_token: user.confirmation_token
get :show, params: { confirmation_token: user.confirmation_token }
user.reload
expect(user.confirmed?).to eq true
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe OrganizationsController do
@ -35,7 +37,7 @@ describe OrganizationsController do
describe 'GET #conferences' do
before :each do
get :conferences, id: organization.id
get :conferences, params: { id: organization.id }
end
it 'loads the organization' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe PhysicalTicketsController do
@ -9,7 +11,7 @@ describe PhysicalTicketsController do
describe 'GET #show' do
before :each do
sign_in user
get :show, id: physical_ticket.token, conference_id: conference.short_title
get :show, params: { id: physical_ticket.token, conference_id: conference.short_title }
end
it 'assigns ticket_layout' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe ProposalsController do
@ -11,7 +13,7 @@ describe ProposalsController do
before do
# We allow new proposal only if program has open cfp
create(:cfp, program: conference.program)
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
end
it 'assigns user and url variables' do
@ -29,9 +31,7 @@ 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),
conference_id: conference.short_title,
user: attributes_for(:user)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) }
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end
@ -39,9 +39,7 @@ 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),
conference_id: conference.short_title,
user: @new_user
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: @new_user }
end
it 'creates new user' do
@ -56,9 +54,7 @@ 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),
conference_id: conference.short_title,
user: @new_user
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: @new_user }
end
it 'assigns event variable', run: true do
@ -84,19 +80,15 @@ describe ProposalsController do
it 'creates new event' do
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
end.to change{ Event.count }.by 1
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) }
end.to change { Event.count }.by 1
end
end
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),
conference_id: conference.short_title,
user: attributes_for(:user)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) }
end
it 'renders new template', run: true do
@ -110,10 +102,8 @@ 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),
conference_id: conference.short_title,
user: attributes_for(:user)
end.not_to change{ Event.count }
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) }
end.not_to change { Event.count }
end
end
end
@ -123,25 +113,19 @@ describe ProposalsController do
it 'does not create new user' do
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, 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),
conference_id: conference.short_title,
user: attributes_for(:user)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, 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),
conference_id: conference.short_title,
user: attributes_for(:user)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title, user: attributes_for(:user) }
end
it 'renders new template' do
@ -162,7 +146,7 @@ describe ProposalsController do
end
describe 'GET #index' do
before { get :index, conference_id: conference.short_title }
before { get :index, params: { conference_id: conference.short_title } }
it 'assigns conference, program and events variables' do
expect(assigns(:conference)).to eq conference
@ -177,7 +161,7 @@ describe ProposalsController do
describe 'GET #show' do
before do
get :show, conference_id: conference.short_title, id: event.id
get :show, params: { conference_id: conference.short_title, id: event.id }
end
it 'assigns event variable' do
@ -193,7 +177,7 @@ describe ProposalsController do
before do
# We allow new proposal only if program has open cfp
create(:cfp, program: conference.program)
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
end
it 'assigns user and url variables' do
@ -208,7 +192,7 @@ describe ProposalsController do
describe 'GET #edit' do
before do
get :edit, conference_id: conference.short_title, id: event.id
get :edit, params: { conference_id: conference.short_title, id: event.id }
end
it 'assigns event and url variables' do
@ -226,15 +210,13 @@ 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),
conference_id: conference.short_title
post :create, params: { 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),
conference_id: conference.short_title
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title }
end
it 'assigns event variable', run: true do
@ -260,17 +242,15 @@ describe ProposalsController do
it 'creates new event' do
expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
end.to change{ Event.count }.by 1
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title }
end.to change { Event.count }.by 1
end
end
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),
conference_id: conference.short_title
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title }
end
it 'renders new template', run: true do
@ -284,27 +264,21 @@ 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),
conference_id: conference.short_title
end.not_to change{ Event.count }
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), conference_id: conference.short_title }
end.not_to change { Event.count }
end
end
end
describe 'PATCH #update' do
it 'assigns url variable' do
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title,
id: event.id
patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), conference_id: conference.short_title, 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),
conference_id: conference.short_title,
id: event.id
patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), conference_id: conference.short_title, id: event.id }
end
it 'updates the proposal' do
@ -324,9 +298,7 @@ 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),
conference_id: conference.short_title,
id: event.id
patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), conference_id: conference.short_title, id: event.id }
end
it 'does not update the proposal' do
@ -345,15 +317,14 @@ describe ProposalsController do
end
describe 'PATCH #withdraw' do
it 'assigns url variable' do
patch :withdraw, conference_id: conference.short_title, id: event.id
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
context 'withdraws successfully' do
before do
patch :withdraw, conference_id: conference.short_title, id: event.id
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
end
it 'changes state of event to withdrawn' do
@ -374,7 +345,7 @@ describe ProposalsController do
before do
request.env['HTTP_REFERER'] = '/'
allow_any_instance_of(Event).to receive(:withdraw).and_raise(Transitions::InvalidTransition)
patch :withdraw, conference_id: conference.short_title, id: event.id
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not withdraw event' do
@ -394,7 +365,7 @@ describe ProposalsController do
context 'event save fails' do
before do
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :withdraw, conference_id: conference.short_title, id: event.id
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not withdraw event' do
@ -413,7 +384,7 @@ describe ProposalsController do
end
describe 'PATCH #confirm' do
before { event.update_attributes(state: 'unconfirmed') }
before { event.update(state: 'unconfirmed') }
context 'confirmed successfully' do
describe 'when require_registration is set' do
@ -421,7 +392,7 @@ describe ProposalsController do
event.require_registration = true
event.max_attendees = nil
event.save!
patch :confirm, conference_id: conference.short_title, id: event.id
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'assigns url variable' do
@ -435,7 +406,7 @@ describe ProposalsController do
end
describe 'general actions' do
before { patch :confirm, conference_id: conference.short_title, id: event.id }
before { patch :confirm, params: { conference_id: conference.short_title, id: event.id } }
it 'assigns url variable' do
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
@ -450,7 +421,7 @@ describe ProposalsController do
context 'user has registered for the conference' do
before do
create(:registration, conference: conference, user: event.submitter)
patch :confirm, conference_id: conference.short_title, id: event.id
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'redirects to proposal index path' do
@ -464,7 +435,7 @@ describe ProposalsController do
context 'user has not registered for the conference' do
before do
patch :confirm, conference_id: conference.short_title, id: event.id
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'redirects to new registration path' do
@ -481,7 +452,7 @@ describe ProposalsController do
before do
request.env['HTTP_REFERER'] = '/'
allow_any_instance_of(Event).to receive(:confirm).and_raise(Transitions::InvalidTransition)
patch :confirm, conference_id: conference.short_title, id: event.id
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not confirm event' do
@ -499,9 +470,9 @@ describe ProposalsController do
context 'event save fails' do
before do
event.update_attributes(state: 'unconfirmed')
event.update(state: 'unconfirmed')
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :confirm, conference_id: conference.short_title, id: event.id
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not confirm event' do
@ -519,16 +490,16 @@ describe ProposalsController do
end
describe 'PATCH #restart' do
before { event.update_attributes(state: 'withdrawn') }
before { event.update(state: 'withdrawn') }
it 'assigns url variable' do
patch :restart, conference_id: conference.short_title, id: event.id
patch :restart, params: { conference_id: conference.short_title, id: event.id }
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
context 'resubmits successfully' do
before do
patch :restart, conference_id: conference.short_title, id: event.id
patch :restart, params: { conference_id: conference.short_title, id: event.id }
end
it 'changes state of event to new' do
@ -548,7 +519,7 @@ describe ProposalsController do
context 'event resubmission fails' do
before do
allow_any_instance_of(Event).to receive(:restart).and_raise(Transitions::InvalidTransition)
patch :restart, conference_id: conference.short_title, id: event.id
patch :restart, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not change state of event to new' do
@ -568,7 +539,7 @@ describe ProposalsController do
context 'event save fails' do
before do
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :restart, conference_id: conference.short_title, id: event.id
patch :restart, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not change state of event to new' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe SchedulesController do
@ -11,13 +13,13 @@ describe SchedulesController do
create(:event_scheduled, program: conference.program)
create(:event_scheduled, program: conference.program)
get :show, conference_id: conference.short_title, format: :xml
get :show, params: { conference_id: conference.short_title, format: :xml }
end
it 'assigns variables' do
expect(assigns(:conference)).to eq conference
expect(assigns(:events_xml)).to eq conference.program.selected_event_schedules.map(&:event)
.group_by{ |event| event.time.to_date }
.group_by { |event| event.time.to_date }
end
it 'has 200 status code' do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe SubscriptionsController do
@ -7,7 +9,7 @@ describe SubscriptionsController do
describe 'POST #create' do
context 'when user is a guest' do
it 'redirects to sign in page' do
post :create, conference_id: conference.short_title
post :create, params: { conference_id: conference.short_title }
expect(response).to redirect_to new_user_session_path
end
end
@ -18,17 +20,17 @@ describe SubscriptionsController do
end
it 'redirects to home page' do
post :create, conference_id: conference.short_title
post :create, params: { conference_id: conference.short_title }
expect(response).to redirect_to root_path
end
it 'shows success message in flash notice' do
post :create, conference_id: conference.short_title
post :create, params: { conference_id: conference.short_title }
expect(flash[:notice]).to match("You have subscribed to receive email notifications for #{conference.title}")
end
it 'subscribes user to conference' do
post :create, conference_id: conference.short_title
post :create, params: { conference_id: conference.short_title }
expect(user.subscriptions.pluck(:conference_id)).to include(conference.id)
end
end
@ -37,17 +39,17 @@ describe SubscriptionsController do
describe 'DELETE #destroy' do
before(:each) do
sign_in(user)
post :create, conference_id: conference.short_title
post :create, params: { conference_id: conference.short_title }
end
it 'redirects to home page' do
delete :destroy, conference_id: conference.short_title
delete :destroy, params: { conference_id: conference.short_title }
expect(response).to redirect_to root_path
end
it 'shows success message in flash notice' do
delete :destroy, conference_id: conference.short_title
expect(flash[:notice]).to match("You have unsubscribed and you will not be receiving email notifications for #{conference.title}.")
delete :destroy, params: { conference_id: conference.short_title }
expect(flash[:notice]).to match("You have unsubscribed and you will not be receiving email notifications for #{conference.title}.")
end
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe TracksController do
@ -13,7 +15,7 @@ describe TracksController do
describe 'GET #index' do
before :each do
get :index, conference_id: conference.short_title
get :index, params: { conference_id: conference.short_title }
end
it 'assigns @tracks with the correct values' do
@ -29,7 +31,7 @@ describe TracksController do
describe 'GET #show' do
before :each do
get :show, conference_id: conference.short_title, id: self_organized_track.short_name
get :show, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
end
it 'assigns the correct track' do
@ -43,7 +45,7 @@ describe TracksController do
describe 'GET #new' do
before :each do
get :new, conference_id: conference.short_title
get :new, params: { conference_id: conference.short_title }
end
it 'assigns a new track with the correct conference' do
@ -60,7 +62,7 @@ describe TracksController do
describe 'POST #create' do
context 'saves successfuly' do
before :each do
post :create, track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title
post :create, params: { track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title }
end
it 'redirects to tracks index path' do
@ -86,7 +88,7 @@ describe TracksController do
context 'save fails' do
before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false)
post :create, track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title
post :create, params: { track: attributes_for(:track, :self_organized, short_name: 'my_track'), conference_id: conference.short_title }
end
it 'assigns a new track with the correct conference' do
@ -111,7 +113,7 @@ describe TracksController do
describe 'GET #edit' do
before :each do
get :edit, conference_id: conference.short_title, id: self_organized_track.short_name
get :edit, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
end
it 'assigns the correct track' do
@ -126,9 +128,7 @@ describe TracksController do
describe 'PATCH #update' do
context 'updates successfully' do
before :each do
patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'),
conference_id: conference.short_title,
id: self_organized_track.short_name
patch :update, params: { track: attributes_for(:track, :self_organized, color: '#FF0000'), conference_id: conference.short_title, id: self_organized_track.short_name }
end
it 'assigns the correct track' do
@ -152,9 +152,7 @@ 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'),
conference_id: conference.short_title,
id: self_organized_track.short_name
patch :update, params: { track: attributes_for(:track, :self_organized, color: '#FF0000'), conference_id: conference.short_title, id: self_organized_track.short_name }
end
it 'assigns the correct track' do
@ -180,7 +178,7 @@ describe TracksController do
before :each do
self_organized_track.state = 'withdrawn'
self_organized_track.save!
patch :restart, conference_id: conference.short_title, id: self_organized_track.short_name
patch :restart, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -201,7 +199,7 @@ describe TracksController do
before :each do
self_organized_track.state = 'accepted'
self_organized_track.save!
patch :confirm, conference_id: conference.short_title, id: self_organized_track.short_name
patch :confirm, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end
@ -222,7 +220,7 @@ describe TracksController do
before :each do
self_organized_track.state = 'confirmed'
self_organized_track.save!
patch :withdraw, conference_id: conference.short_title, id: self_organized_track.short_name
patch :withdraw, params: { conference_id: conference.short_title, id: self_organized_track.short_name }
self_organized_track.reload
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe Users::OmniauthCallbacksController do
@ -14,17 +16,17 @@ 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,
username: 'user_google'
},
credentials: {
token: 'google_mock_token',
secret: 'google_mock_secret'
}
provider: 'google',
uid: 'google-test-uid-1',
info: {
name: 'google user',
email: nil,
username: 'user_google'
},
credentials: {
token: 'google_mock_token',
secret: 'google_mock_secret'
}
)
request.env['omniauth.auth'] = env
allow(@controller).to receive(:env).and_return(env)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
describe UsersController do
@ -6,7 +8,7 @@ describe UsersController do
describe 'GET #show' do
before :each do
get :show, id: user.id
get :show, params: { id: user.id }
end
it 'renders show template' do
@ -33,7 +35,7 @@ describe UsersController do
describe 'GET #edit' do
it 'assigns the right value to @user' do
sign_in user
get :edit, id: user.id
get :edit, params: { id: user.id }
expect(assigns(:user)).to eq user
end
end
@ -42,7 +44,7 @@ describe UsersController do
context 'with valid attributes' do
before :each do
sign_in user
patch :update, id: user.id, user: attributes_for(:user, name: 'My Test Name')
patch :update, params: { id: user.id, user: attributes_for(:user, name: 'My Test Name') }
user.reload
end