diff --git a/34 b/34 new file mode 100644 index 00000000..7179cd84 --- /dev/null +++ b/34 @@ -0,0 +1,607 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ProposalsController do + let(:user) { create(:user) } + let(:conference) { create(:conference, short_title: 'lama101') } + let(:event) { create(:event, program: conference.program) } + let(:event_type) { create :event_type } + + context 'user is not signed in' do + describe 'GET #new' do + before do + # We allow new proposal only if program has open cfp + create(:cfp, program: conference.program) + get :new, params: { conference_id: conference.short_title } + end + + it 'assigns user and url variables' do + expect(assigns(:user)).to be_instance_of(User) + expect(assigns(:url)).to eq '/conferences/lama101/program/proposals' + end + + it 'renders new template' do + expect(response).to render_template('new') + end + end + + describe 'POST #create' do + # We allow proposal create only if program has open cfp + before { create(:cfp, program: conference.program) } + + it 'assigns url variables' do + 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 + + context 'user is saved successfully' do + describe 'user related actions' do + before do + @new_user = attributes_for(: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 + expect(User.last.username).to eq @new_user[:username] + end + + it 'signs in new user' do + expect(controller.current_user.username).to eq @new_user[:username] + end + end + + context 'creates proposal successfully' do + before(:each, run: true) do + @new_user = attributes_for(: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 + expect(assigns(:event)).not_to be_nil + end + + it 'assigns program to event', run: true do + expect(assigns(:event).program).to eq conference.program + end + + it 'assigns submitter and speaker to event', run: true do + expect(assigns(:event).submitter.username).to eq @new_user[:username] + expect(assigns(:event).speakers.first.username).to eq @new_user[:username] + end + + it 'redirects to proposal index path', run: true do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows success message in flash notice', run: true do + expect(flash[:notice]).to match('Proposal was successfully submitted.') + end + + it 'creates new event' do + expect do + 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, 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 + expect(response).to render_template('new') + end + + it 'shows error in flash message', run: true do + expect(flash[:error]).to match("Could not submit proposal: #{event.errors.full_messages.join(', ')}") + end + + it 'does not create new proposal' do + allow_any_instance_of(Event).to receive(:save).and_return(false) + expect do + 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 + + context 'user save fails' do + before { allow_any_instance_of(User).to receive(:save).and_return(false) } + + it 'does not create new user' do + expect do + 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, 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, 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 + expect(response).to render_template('new') + end + + it 'shows error in flash message' do + expect(flash[:error]).to match "Could not save user: #{user.errors.full_messages.join(', ')}" + end + end + end + end + end + + context 'event submitter is signed in' do + before do + sign_in event.submitter + end + + describe 'GET #index' do + before { get :index, params: { conference_id: conference.short_title } } + + it 'assigns conference, program and events variables' do + expect(assigns(:conference)).to eq conference + expect(assigns(:program)).to eq conference.program + expect(assigns(:events)).to eq [event] + end + + it 'renders index template' do + expect(response).to render_template('index') + end + end + + describe 'GET #show' do + before do + get :show, params: { conference_id: conference.short_title, id: event.id } + end + + it 'assigns event variable' do + expect(assigns(:event)).to eq event + end + + it 'renders show template' do + expect(response).to render_template('show') + end + end + + describe 'GET #new' do + before do + # We allow new proposal only if program has open cfp + create(:cfp, program: conference.program) + get :new, params: { conference_id: conference.short_title } + end + + it 'assigns user and url variables' do + expect(assigns(:user)).to be_instance_of(User) + expect(assigns(:url)).to eq '/conferences/lama101/program/proposals' + end + + it 'renders new template' do + expect(response).to render_template('new') + end + end + + describe 'GET #edit' do + before do + get :edit, params: { conference_id: conference.short_title, id: event.id } + end + + it 'assigns event and url variables' do + expect(assigns(:event)).to eq event + expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}" + end + + it 'renders edit template' do + expect(response).to render_template('edit') + end + end + + describe 'POST #create' do + # We allow proposal create only if program has open cfp + before { create(:cfp, program: conference.program) } + + it 'assigns url variables' do + 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, params: { event: attributes_for(:event, event_type_id: event_type.id), + conference_id: conference.short_title + } + end + + it 'assigns event variable', run: true do + expect(assigns(:event)).not_to be_nil + end + + it 'assigns program to event', run: true do + expect(assigns(:event).program).to eq conference.program + end + + it 'assigns submitter and speaker to event', run: true do + expect(assigns(:event).submitter).to eq event.submitter + expect(assigns(:event).speakers.first).to eq event.submitter + end + + it 'redirects to proposal index path', run: true do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows success message in flash notice', run: true do + expect(flash[:notice]).to match('Proposal was successfully submitted.') + end + + it 'creates new event' do + expect do + 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, params: { event: attributes_for(:event, event_type_id: event_type.id), + conference_id: conference.short_title + } + end + + it 'renders new template', run: true do + expect(response).to render_template('new') + end + + it 'shows error in flash message', run: true do + expect(flash[:error]).to match("Could not submit proposal: #{event.errors.full_messages.join(', ')}") + end + + it 'does not create new proposal' do + allow_any_instance_of(Event).to receive(:save).and_return(false) + expect do + 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, 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, 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 + event.reload + expect(event.title).to eq 'some title' + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows success message in flash notice' do + expect(flash[:notice]).to match('Proposal was successfully updated.') + end + end + + context 'update fails' do + before do + allow_any_instance_of(Event).to receive(:save).and_return(false) + 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 + event.reload + expect(event.title).not_to eq 'some title' + end + + it 'renders edit template' do + expect(response).to render_template('edit') + end + + it 'shows error in flash message', run: true do + expect(flash[:error]).to match("Could not update proposal: #{event.errors.full_messages.join(', ')}") + end + end + end + + describe 'PATCH #withdraw' do + + it 'assigns url variable' do + 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, params: { conference_id: conference.short_title, id: event.id } + end + + it 'changes state of event to withdrawn' do + event.reload + expect(event.withdrawn?).to be true + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows success message in flash notice' do + expect(flash[:notice]).to match('Proposal was successfully withdrawn.') + end + end + + context 'event withdraw fails' do + before do + request.env['HTTP_REFERER'] = '/' + allow_any_instance_of(Event).to receive(:withdraw).and_raise(Transitions::InvalidTransition) + patch :withdraw, params: { conference_id: conference.short_title, id: event.id } + end + + it 'does not withdraw event' do + event.reload + expect(event.withdrawn?).to be false + end + + it 'redirects to previous path' do + expect(response).to redirect_to '/' + end + + it 'shows error in flash message' do + expect(flash[:error]).to match("Event can't be withdrawn") + end + end + + context 'event save fails' do + before do + allow_any_instance_of(Event).to receive(:save).and_return(false) + patch :withdraw, params: { conference_id: conference.short_title, id: event.id } + end + + it 'does not withdraw event' do + event.reload + expect(event.withdrawn?).to be false + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows error in flash message' do + expect(flash[:error]).to match("Could not withdraw proposal: #{event.errors.full_messages.join(', ')}") + end + end + end + + describe 'PATCH #confirm' do + before { event.update_attributes(state: 'unconfirmed') } + + context 'confirmed successfully' do + describe 'when require_registration is set' do + before :each do + event.require_registration = true + event.max_attendees = nil + event.save! + patch :confirm, params: { conference_id: conference.short_title, id: event.id } + end + + it 'assigns url variable' do + expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}" + end + + it 'change state of event to confirmed' do + event.reload + expect(event.confirmed?).to be true + end + end + + describe 'general actions' do + 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}" + end + + it 'change state of event to confirmed' do + event.reload + expect(event.confirmed?).to be true + end + end + + context 'user has registered for the conference' do + before do + create(:registration, conference: conference, user: event.submitter) + patch :confirm, params: { conference_id: conference.short_title, id: event.id } + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows success message in flash notice' do + expect(flash[:notice]).to match('The proposal was confirmed.') + end + end + + context 'user has not registered for the conference' do + before do + patch :confirm, params: { conference_id: conference.short_title, id: event.id } + end + + it 'redirects to new registration path' do + expect(response).to redirect_to new_conference_conference_registration_path conference.short_title + end + + it 'shows flash alert asking user to register' do + expect(flash[:alert]).to match('The proposal was confirmed. Please register to attend the conference.') + end + end + end + + context 'event confirm fails' do + before do + request.env['HTTP_REFERER'] = '/' + allow_any_instance_of(Event).to receive(:confirm).and_raise(Transitions::InvalidTransition) + patch :confirm, params: { conference_id: conference.short_title, id: event.id } + end + + it 'does not confirm event' do + expect(event.confirmed?).to be false + end + + it 'redirects to previous path' do + expect(response).to redirect_to '/' + end + + it 'shows error in flash message' do + expect(flash[:error]).to match("Event can't be confirmed") + end + end + + context 'event save fails' do + before do + event.update_attributes(state: 'unconfirmed') + allow_any_instance_of(Event).to receive(:save).and_return(false) + patch :confirm, params: { conference_id: conference.short_title, id: event.id } + end + + it 'does not confirm event' do + expect(event.confirmed?).to be false + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows error in flash message' do + expect(flash[:error]).to match("Could not confirm proposal: #{event.errors.full_messages.join(', ')}") + end + end + end + + describe 'PATCH #restart' do + before { event.update_attributes(state: 'withdrawn') } + + it 'assigns url variable' do + 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, params: { conference_id: conference.short_title, id: event.id } + end + + it 'changes state of event to new' do + event.reload + expect(event.new?).to be true + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows success message in flash notice' do + expect(flash[:notice]).to match("The proposal was re-submitted. The #{conference.short_title} organizers will review it again.") + end + end + + context 'event resubmission fails' do + before do + allow_any_instance_of(Event).to receive(:restart).and_raise(Transitions::InvalidTransition) + patch :restart, params: { conference_id: conference.short_title, id: event.id } + end + + it 'does not change state of event to new' do + event.reload + expect(event.new?).to be false + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows error in flash message' do + expect(flash[:error]).to match("The proposal can't be re-submitted.") + end + end + + context 'event save fails' do + before do + allow_any_instance_of(Event).to receive(:save).and_return(false) + patch :restart, params: { conference_id: conference.short_title, id: event.id } + end + + it 'does not change state of event to new' do + event.reload + expect(event.new?).to be false + end + + it 'redirects to proposal index path' do + expect(response).to redirect_to conference_program_proposals_path conference.short_title + end + + it 'shows error in flash message' do + expect(flash[:error]).to match("Could not re-submit proposal: #{event.errors.full_messages.join(', ')}") + end + end + end + end +end diff --git a/Gemfile b/Gemfile index 52d9c21f..ab6192c1 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4') end # as web framework -gem 'rails', '~> 5.0.7' +gem 'rails', '~> 5.1.0' # Use Puma as the app server gem 'puma', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index dd24ce29..ad85986b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,27 +13,27 @@ GEM remote: https://rails-assets.org/ specs: Ascii85 (1.0.3) - actioncable (5.0.7.2) - actionpack (= 5.0.7.2) - nio4r (>= 1.2, < 3.0) + actioncable (5.1.7) + actionpack (= 5.1.7) + nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.0.7.2) - actionpack (= 5.0.7.2) - actionview (= 5.0.7.2) - activejob (= 5.0.7.2) + actionmailer (5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.7.2) - actionview (= 5.0.7.2) - activesupport (= 5.0.7.2) + actionpack (5.1.7) + actionview (= 5.1.7) + activesupport (= 5.1.7) rack (~> 2.0) - rack-test (~> 0.6.3) + rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.7.2) - activesupport (= 5.0.7.2) + actionview (5.1.7) + activesupport (= 5.1.7) builder (~> 3.1) - erubis (~> 2.7.0) + erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) active_model_serializers (0.10.9) @@ -41,16 +41,16 @@ GEM activemodel (>= 4.1, < 6) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) - activejob (5.0.7.2) - activesupport (= 5.0.7.2) + activejob (5.1.7) + activesupport (= 5.1.7) globalid (>= 0.3.6) - activemodel (5.0.7.2) - activesupport (= 5.0.7.2) - activerecord (5.0.7.2) - activemodel (= 5.0.7.2) - activesupport (= 5.0.7.2) - arel (~> 7.0) - activesupport (5.0.7.2) + activemodel (5.1.7) + activesupport (= 5.1.7) + activerecord (5.1.7) + activemodel (= 5.1.7) + activesupport (= 5.1.7) + arel (~> 8.0) + activesupport (5.1.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -72,7 +72,7 @@ GEM railties (>= 4.0) archive-zip (0.12.0) io-like (~> 0.3.0) - arel (7.1.4) + arel (8.0.0) ast (2.4.0) autoprefixer-rails (9.5.1) execjs @@ -168,6 +168,7 @@ GEM dotenv-rails (2.7.2) dotenv (= 2.7.2) railties (>= 3.2, < 6.1) + erubi (1.8.0) erubis (2.7.0) execjs (2.7.0) factory_bot (4.11.1) @@ -381,19 +382,19 @@ GEM rack-openid (1.3.1) rack (>= 1.1.0) ruby-openid (>= 2.1.8) - rack-test (0.6.3) - rack (>= 1.0) - rails (5.0.7.2) - actioncable (= 5.0.7.2) - actionmailer (= 5.0.7.2) - actionpack (= 5.0.7.2) - actionview (= 5.0.7.2) - activejob (= 5.0.7.2) - activemodel (= 5.0.7.2) - activerecord (= 5.0.7.2) - activesupport (= 5.0.7.2) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.1.7) + actioncable (= 5.1.7) + actionmailer (= 5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) + activemodel (= 5.1.7) + activerecord (= 5.1.7) + activesupport (= 5.1.7) bundler (>= 1.3.0) - railties (= 5.0.7.2) + railties (= 5.1.7) sprockets-rails (>= 2.0.0) rails-assets-bootstrap (3.3.6) rails-assets-jquery (>= 1.9.1, < 3) @@ -427,9 +428,9 @@ GEM rails-i18n (5.1.3) i18n (>= 0.7, < 2) railties (>= 5.0, < 6) - railties (5.0.7.2) - actionpack (= 5.0.7.2) - activesupport (= 5.0.7.2) + railties (5.1.7) + actionpack (= 5.1.7) + activesupport (= 5.1.7) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) @@ -674,7 +675,7 @@ DEPENDENCIES prawn-qrcode prawn-rails puma (~> 3.0) - rails (~> 5.0.7) + rails (~> 5.1.0) rails-assets-bootstrap-markdown! rails-assets-bootstrap-select! rails-assets-date.format! diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index 0680b436..e361086d 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -45,9 +45,9 @@ module Admin def render_commercial result = Commercial.render_from_url(params[:url]) if result[:error] - render text: result[:error], status: 400 + render plain: result[:error], status: 400 else - render text: result[:html] + render plain: result[:html] end end diff --git a/app/controllers/admin/venue_commercials_controller.rb b/app/controllers/admin/venue_commercials_controller.rb index 3be0ec47..ddd13aa9 100644 --- a/app/controllers/admin/venue_commercials_controller.rb +++ b/app/controllers/admin/venue_commercials_controller.rb @@ -40,9 +40,9 @@ module Admin def render_commercial result = Commercial.render_from_url(params[:url]) if result[:error] - render text: result[:error], status: 400 + render plain: result[:error], status: 400 else - render text: result[:html] + render plain: result[:html] end end diff --git a/app/controllers/commercials_controller.rb b/app/controllers/commercials_controller.rb index 13b9b2d4..1967d0d1 100644 --- a/app/controllers/commercials_controller.rb +++ b/app/controllers/commercials_controller.rb @@ -37,9 +37,9 @@ class CommercialsController < ApplicationController def render_commercial result = Commercial.render_from_url(params[:url]) if result[:error] - render text: result[:error], status: 400 + render plain: result[:error], status: 400 else - render text: result[:html] + render plain: result[:html] end end diff --git a/spec/controllers/admin/booths_controller_spec.rb b/spec/controllers/admin/booths_controller_spec.rb index f9d5358e..11b578a4 100644 --- a/spec/controllers/admin/booths_controller_spec.rb +++ b/spec/controllers/admin/booths_controller_spec.rb @@ -13,14 +13,14 @@ describe Admin::BoothsController 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 @@ -32,7 +32,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]) @@ -44,7 +44,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) @@ -57,11 +57,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 @@ -80,11 +80,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 @@ -100,7 +100,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') @@ -113,7 +113,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 diff --git a/spec/controllers/admin/cfps_controller_spec.rb b/spec/controllers/admin/cfps_controller_spec.rb index d2582f2f..617417a1 100644 --- a/spec/controllers/admin/cfps_controller_spec.rb +++ b/spec/controllers/admin/cfps_controller_spec.rb @@ -14,14 +14,14 @@ describe Admin::CfpsController do describe 'POST #create' do it 'successes' do - post :create, conference_id: conference.short_title, cfp: { cfp_type: 'events', start_date: today, end_date: today + 6.days, description: 'We call for papers, or tabak, or you know what!' } + post :create, params: { conference_id: conference.short_title, cfp: { cfp_type: 'events', start_date: today, end_date: today + 6.days, description: 'We call for papers, or tabak, or you know what!' } } expect(flash[:notice]).to match('Call for papers successfully created.') end end describe 'POST #update' do it 'successes' do - patch :update, conference_id: conference.short_title, id: cfp.id, cfp: { end_date: today + 10.days } + patch :update, params: { conference_id: conference.short_title, id: cfp.id, cfp: { end_date: today + 10.days } } expect(flash[:notice]).to match('Call for papers successfully updated.') end end diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 714910f4..c89b646c 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -18,22 +18,22 @@ 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) @@ -43,7 +43,7 @@ describe Admin::ConferencesController 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 @@ -51,9 +51,9 @@ 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]) @@ -63,9 +63,9 @@ describe Admin::ConferencesController do 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.") @@ -77,24 +77,24 @@ describe Admin::ConferencesController do 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 @@ -103,11 +103,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'] = { @@ -124,13 +124,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'] = { @@ -147,13 +147,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'] = { @@ -202,15 +202,15 @@ 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) @@ -221,8 +221,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 @@ -233,15 +233,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 @@ -250,15 +250,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 @@ -299,8 +299,8 @@ describe Admin::ConferencesController do 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}/) @@ -321,7 +321,7 @@ 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}/) @@ -341,9 +341,9 @@ describe Admin::ConferencesController do 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}/) diff --git a/spec/controllers/admin/event_schedules_controller_spec.rb b/spec/controllers/admin/event_schedules_controller_spec.rb index bb6109ea..e1e31363 100644 --- a/spec/controllers/admin/event_schedules_controller_spec.rb +++ b/spec/controllers/admin/event_schedules_controller_spec.rb @@ -19,12 +19,12 @@ 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 @@ -40,12 +40,12 @@ describe Admin::EventSchedulesController do 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 @@ -62,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 @@ -86,12 +86,12 @@ 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 } @@ -106,7 +106,7 @@ 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 diff --git a/spec/controllers/admin/events_controller_spec.rb b/spec/controllers/admin/events_controller_spec.rb index 104e7044..18850328 100644 --- a/spec/controllers/admin/events_controller_spec.rb +++ b/spec/controllers/admin/events_controller_spec.rb @@ -17,7 +17,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 diff --git a/spec/controllers/admin/organizations_controller_spec.rb b/spec/controllers/admin/organizations_controller_spec.rb index 2b1180c6..4468bb34 100644 --- a/spec/controllers/admin/organizations_controller_spec.rb +++ b/spec/controllers/admin/organizations_controller_spec.rb @@ -37,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) @@ -53,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) @@ -66,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) @@ -104,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) @@ -120,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) @@ -136,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') @@ -145,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)) @@ -156,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) @@ -174,8 +174,8 @@ 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 @@ -188,8 +188,8 @@ 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 diff --git a/spec/controllers/admin/programs_controller_spec.rb b/spec/controllers/admin/programs_controller_spec.rb index 955d1477..5ee48bc0 100644 --- a/spec/controllers/admin/programs_controller_spec.rb +++ b/spec/controllers/admin/programs_controller_spec.rb @@ -11,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 @@ -24,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 diff --git a/spec/controllers/admin/registration_periods_controller_spec.rb b/spec/controllers/admin/registration_periods_controller_spec.rb index 84bcadf1..3d5159b5 100644 --- a/spec/controllers/admin/registration_periods_controller_spec.rb +++ b/spec/controllers/admin/registration_periods_controller_spec.rb @@ -22,22 +22,22 @@ describe Admin::RegistrationPeriodsController 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) @@ -51,10 +51,10 @@ describe Admin::RegistrationPeriodsController do start_date: Date.today, end_date: Date.today + 2.days) - patch :update, conference_id: conference.short_title, registration_period: - attributes_for(:registration_period, - start_date: Date.today + 2.days, - end_date: Date.today + 4.days) + 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) } conference.reload allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer) end @@ -65,17 +65,19 @@ 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) @@ -85,21 +87,23 @@ describe Admin::RegistrationPeriodsController do 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 @@ -107,46 +111,46 @@ 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 diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index af400517..6d36488b 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -25,12 +25,12 @@ describe Admin::ReportsController 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 it 'initialises missing speakers' do - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } expect(assigns(:missing_event_speakers).pluck(:user_id)).to eq [user1.id] end end diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb index 8edb1c30..6a0d7754 100644 --- a/spec/controllers/admin/roles_controller_spec.rb +++ b/spec/controllers/admin/roles_controller_spec.rb @@ -14,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 @@ -29,8 +29,8 @@ describe Admin::RolesController do describe 'GET #show' do before :each do sign_in(admin) - xhr :get, :show, conference_id: conference.short_title, - id: 'organizer' + get :show, params: { conference_id: conference.short_title, + id: 'organizer' } end it 'assigns correct value to selection variable' do @@ -45,9 +45,9 @@ 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 @@ -58,9 +58,9 @@ 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 @@ -79,17 +79,17 @@ 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 @@ -97,23 +97,23 @@ 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] @@ -122,15 +122,15 @@ 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 diff --git a/spec/controllers/admin/rooms_controller_spec.rb b/spec/controllers/admin/rooms_controller_spec.rb index 7c5d6f7c..6272d7d5 100644 --- a/spec/controllers/admin/rooms_controller_spec.rb +++ b/spec/controllers/admin/rooms_controller_spec.rb @@ -12,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 @@ -26,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') @@ -38,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') @@ -52,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 @@ -71,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 @@ -91,9 +91,9 @@ describe Admin::RoomsController do describe 'PATCH #update' do context 'updates successfully' do before do - patch :update, room: attributes_for(:room, size: 2), - 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 @@ -113,9 +113,9 @@ describe Admin::RoomsController do context 'update fails' do before do allow_any_instance_of(Room).to receive(:save).and_return(false) - patch :update, room: attributes_for(:room, size: 2), - 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 @@ -135,7 +135,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) @@ -153,7 +153,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 diff --git a/spec/controllers/admin/schedules_controller_spec.rb b/spec/controllers/admin/schedules_controller_spec.rb index 5432765c..76310398 100644 --- a/spec/controllers/admin/schedules_controller_spec.rb +++ b/spec/controllers/admin/schedules_controller_spec.rb @@ -15,13 +15,13 @@ 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 @@ -35,7 +35,7 @@ describe Admin::SchedulesController do 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 @@ -49,7 +49,7 @@ 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) diff --git a/spec/controllers/admin/sponsorship_levels_controller_spec.rb b/spec/controllers/admin/sponsorship_levels_controller_spec.rb index 98b9da87..d8c01681 100644 --- a/spec/controllers/admin/sponsorship_levels_controller_spec.rb +++ b/spec/controllers/admin/sponsorship_levels_controller_spec.rb @@ -11,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 @@ -24,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') @@ -36,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') @@ -50,8 +50,8 @@ 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 @@ -64,8 +64,8 @@ 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 + 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 @@ -73,8 +73,8 @@ describe Admin::SponsorshipLevelsController do 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 @@ -94,9 +94,9 @@ 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 @@ -116,9 +116,9 @@ 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 @@ -139,7 +139,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 @@ -153,7 +153,7 @@ 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 + 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 @@ -161,7 +161,7 @@ describe Admin::SponsorshipLevelsController do 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 @@ -182,7 +182,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 @@ -197,7 +197,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 diff --git a/spec/controllers/admin/ticket_scannings_controller_spec.rb b/spec/controllers/admin/ticket_scannings_controller_spec.rb index 022800cf..83909a28 100644 --- a/spec/controllers/admin/ticket_scannings_controller_spec.rb +++ b/spec/controllers/admin/ticket_scannings_controller_spec.rb @@ -18,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 @@ -39,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 @@ -54,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 diff --git a/spec/controllers/admin/tracks_controller_spec.rb b/spec/controllers/admin/tracks_controller_spec.rb index 1b8bc231..f51f1dda 100644 --- a/spec/controllers/admin/tracks_controller_spec.rb +++ b/spec/controllers/admin/tracks_controller_spec.rb @@ -17,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 @@ -33,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 @@ -47,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 @@ -64,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 @@ -94,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 @@ -119,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 @@ -134,9 +134,9 @@ describe Admin::TracksController do describe 'PATCH #update' do context 'updates successfully' do before :each do - patch :update, track: attributes_for(:track, color: '#FF0000'), - 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 @@ -160,9 +160,9 @@ describe Admin::TracksController do context 'update fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - patch :update, track: attributes_for(:track, color: '#FF0000'), - 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 @@ -187,7 +187,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 @@ -206,7 +206,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 @@ -236,7 +236,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 @@ -256,7 +256,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 @@ -282,7 +282,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 @@ -302,7 +302,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 @@ -325,7 +325,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 @@ -344,7 +344,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 @@ -364,7 +364,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 @@ -382,7 +382,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 @@ -472,7 +472,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 @@ -491,7 +491,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 @@ -510,7 +510,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 @@ -531,7 +531,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 diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 97c829c8..50eda9b1 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -23,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 @@ -36,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 @@ -66,7 +66,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 @@ -85,7 +85,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 @@ -98,7 +98,7 @@ describe Admin::UsersController do it 'does not create new user' do expect do - post :create, user: attributes_for(:user) + post :create, params: { user: attributes_for(:user) } end.not_to change{ Event.count } end end diff --git a/spec/controllers/admin/versions_controller_spec.rb b/spec/controllers/admin/versions_controller_spec.rb index 0dede517..8c453efd 100644 --- a/spec/controllers/admin/versions_controller_spec.rb +++ b/spec/controllers/admin/versions_controller_spec.rb @@ -18,7 +18,7 @@ describe Admin::VersionsController do 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 + 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' @@ -27,14 +27,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) @@ -42,14 +42,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 @@ -62,7 +62,7 @@ describe Admin::VersionsController do 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' + 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' @@ -71,7 +71,7 @@ describe Admin::VersionsController do 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' + 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 @@ -79,14 +79,14 @@ describe Admin::VersionsController do 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.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 @@ -94,7 +94,7 @@ describe Admin::VersionsController do conference.update_attributes(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' @@ -107,7 +107,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 @@ -127,7 +127,7 @@ describe Admin::VersionsController do 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 @@ -136,7 +136,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 @@ -146,7 +146,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 diff --git a/spec/controllers/api/v1/conferences_controller_spec.rb b/spec/controllers/api/v1/conferences_controller_spec.rb index 330c86d8..b126d87d 100644 --- a/spec/controllers/api/v1/conferences_controller_spec.rb +++ b/spec/controllers/api/v1/conferences_controller_spec.rb @@ -8,7 +8,7 @@ describe Api::V1::ConferencesController do describe 'GET #index' do before(:each) do - get :index, format: :json + get :index, params: { format: :json } @json = JSON.parse(response.body)['conferences'] end @@ -28,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 diff --git a/spec/controllers/api/v1/events_controller_spec.rb b/spec/controllers/api/v1/events_controller_spec.rb index 168d5d8c..1f9b2809 100644 --- a/spec/controllers/api/v1/events_controller_spec.rb +++ b/spec/controllers/api/v1/events_controller_spec.rb @@ -11,7 +11,7 @@ describe Api::V1::EventsController do context 'without conference scope' do it 'returns all confirmed events' do - get :index, format: :json + get :index, params: { format: :json } json = JSON.parse(response.body)['events'] expect(response).to be_success @@ -24,7 +24,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 diff --git a/spec/controllers/api/v1/rooms_controller_spec.rb b/spec/controllers/api/v1/rooms_controller_spec.rb index bb29c44c..f8262800 100644 --- a/spec/controllers/api/v1/rooms_controller_spec.rb +++ b/spec/controllers/api/v1/rooms_controller_spec.rb @@ -12,7 +12,7 @@ describe Api::V1::RoomsController do context 'without conference scope' do it 'returns all rooms' do - get :index, format: :json + get :index, params: { format: :json } json = JSON.parse(response.body)['rooms'] expect(response).to be_success @@ -26,7 +26,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 diff --git a/spec/controllers/api/v1/speakers_controller_spec.rb b/spec/controllers/api/v1/speakers_controller_spec.rb index f3f857f0..fdaa08a0 100644 --- a/spec/controllers/api/v1/speakers_controller_spec.rb +++ b/spec/controllers/api/v1/speakers_controller_spec.rb @@ -19,7 +19,7 @@ describe Api::V1::SpeakersController do context 'without conference scope' do it 'returns all speakers' do - get :index, format: :json + get :index, params: { format: :json } json = JSON.parse(response.body)['speakers'] expect(response).to be_success expect(json.length).to eq(2) @@ -31,7 +31,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 diff --git a/spec/controllers/api/v1/tracks_controller_spec.rb b/spec/controllers/api/v1/tracks_controller_spec.rb index 74379414..65346b56 100644 --- a/spec/controllers/api/v1/tracks_controller_spec.rb +++ b/spec/controllers/api/v1/tracks_controller_spec.rb @@ -11,7 +11,7 @@ describe Api::V1::TracksController do context 'without conference scope' do it 'returns all tracks' do - get :index, format: :json + get :index, params: { format: :json } json = JSON.parse(response.body)['tracks'] expect(response).to be_success @@ -25,7 +25,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 diff --git a/spec/controllers/booths_controller_spec.rb b/spec/controllers/booths_controller_spec.rb index be1c4e41..8444be9c 100644 --- a/spec/controllers/booths_controller_spec.rb +++ b/spec/controllers/booths_controller_spec.rb @@ -15,7 +15,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]) @@ -27,7 +27,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) @@ -40,7 +40,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) @@ -60,11 +60,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 @@ -80,7 +80,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') @@ -93,7 +93,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 diff --git a/spec/controllers/conference_registration_controller_spec.rb b/spec/controllers/conference_registration_controller_spec.rb index c046d23e..f2849c27 100644 --- a/spec/controllers/conference_registration_controller_spec.rb +++ b/spec/controllers/conference_registration_controller_spec.rb @@ -13,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 @@ -29,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 @@ -231,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 @@ -250,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 @@ -260,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 @@ -273,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 @@ -296,8 +296,8 @@ describe ConferenceRegistrationsController, type: :controller do 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, 04, 29)), + conference_id: conference.short_title } end it 'redirects to registration show path' do @@ -317,8 +317,8 @@ describe ConferenceRegistrationsController, type: :controller do context 'update fails' do before do allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false) - patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)), - conference_id: conference.short_title + patch :update, params: { registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)), + conference_id: conference.short_title } end it 'renders edit template' do @@ -343,7 +343,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 @@ -356,7 +356,7 @@ describe ConferenceRegistrationsController, type: :controller do it 'deletes the registration' do expect do - delete :destroy, conference_id: conference.short_title + delete :destroy, params: { conference_id: conference.short_title } end.to change{ Registration.count }.from(2).to(1) end end @@ -364,7 +364,7 @@ describe ConferenceRegistrationsController, type: :controller do 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 diff --git a/spec/controllers/conferences_controller_spec.rb b/spec/controllers/conferences_controller_spec.rb index 91585d79..c9a17d14 100644 --- a/spec/controllers/conferences_controller_spec.rb +++ b/spec/controllers/conferences_controller_spec.rb @@ -17,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 @@ -44,7 +44,7 @@ describe ConferencesController do describe 'OPTIONS #index' do it 'Response code is 200' do - process :index, 'OPTIONS' + process :index expect(response.response_code).to eq(200) end end diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb index 68e1837a..60675d47 100644 --- a/spec/controllers/confirmations_controller_spec.rb +++ b/spec/controllers/confirmations_controller_spec.rb @@ -11,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 @@ -22,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 diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index e14e22fb..e719f823 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -37,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 diff --git a/spec/controllers/physical_ticket_controller_spec.rb b/spec/controllers/physical_ticket_controller_spec.rb index 5367fb96..7b2a02c4 100644 --- a/spec/controllers/physical_ticket_controller_spec.rb +++ b/spec/controllers/physical_ticket_controller_spec.rb @@ -11,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 diff --git a/spec/controllers/proposals_controller_spec.rb b/spec/controllers/proposals_controller_spec.rb index 2537569e..db52ffd1 100644 --- a/spec/controllers/proposals_controller_spec.rb +++ b/spec/controllers/proposals_controller_spec.rb @@ -13,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 @@ -31,9 +31,9 @@ describe ProposalsController do before { create(:cfp, program: conference.program) } it 'assigns url variables' do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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 @@ -41,9 +41,9 @@ describe ProposalsController do describe 'user related actions' do before do @new_user = attributes_for(:user) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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 @@ -58,9 +58,9 @@ describe ProposalsController do context 'creates proposal successfully' do before(:each, run: true) do @new_user = attributes_for(:user) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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 @@ -86,9 +86,9 @@ describe ProposalsController do it 'creates new event' do expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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.to change{ Event.count }.by 1 end end @@ -96,9 +96,9 @@ describe ProposalsController do context 'proposal save fails' do before(:each, run: true) do allow_any_instance_of(Event).to receive(:save).and_return(false) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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 @@ -112,9 +112,9 @@ describe ProposalsController do it 'does not create new proposal' do allow_any_instance_of(Event).to receive(:save).and_return(false) expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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 end @@ -125,25 +125,25 @@ describe ProposalsController do it 'does not create new user' do expect do - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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 @@ -164,7 +164,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 @@ -179,7 +179,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 @@ -195,7 +195,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 @@ -210,7 +210,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 @@ -228,15 +228,15 @@ 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 @@ -262,8 +262,8 @@ 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 + 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 @@ -271,8 +271,8 @@ describe ProposalsController do context 'proposal save fails' do before(:each, run: true) do allow_any_instance_of(Event).to receive(:save).and_return(false) - post :create, event: attributes_for(:event, event_type_id: event_type.id), - 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 @@ -286,8 +286,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 + 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 @@ -296,17 +296,17 @@ describe ProposalsController do describe 'PATCH #update' do it 'assigns url variable' do - patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), - 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 @@ -326,9 +326,9 @@ describe ProposalsController do context 'update fails' do before do allow_any_instance_of(Event).to receive(:save).and_return(false) - patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), - 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 @@ -349,13 +349,13 @@ describe ProposalsController do 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 @@ -376,7 +376,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 @@ -396,7 +396,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 @@ -423,7 +423,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 @@ -437,7 +437,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}" @@ -452,7 +452,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 @@ -466,7 +466,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 @@ -483,7 +483,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 @@ -503,7 +503,7 @@ describe ProposalsController do before do event.update_attributes(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 @@ -524,13 +524,13 @@ describe ProposalsController do before { event.update_attributes(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 @@ -550,7 +550,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 @@ -570,7 +570,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 diff --git a/spec/controllers/schedules_controller_spec.rb b/spec/controllers/schedules_controller_spec.rb index a448627a..8724c21b 100644 --- a/spec/controllers/schedules_controller_spec.rb +++ b/spec/controllers/schedules_controller_spec.rb @@ -13,7 +13,7 @@ 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 diff --git a/spec/controllers/subscriptions_controller_spec.rb b/spec/controllers/subscriptions_controller_spec.rb index c47d7ca5..dcc964a7 100644 --- a/spec/controllers/subscriptions_controller_spec.rb +++ b/spec/controllers/subscriptions_controller_spec.rb @@ -9,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 @@ -20,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 @@ -39,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 diff --git a/spec/controllers/surveys_controller_spec.rb b/spec/controllers/surveys_controller_spec.rb index fb62de8e..67b6cac0 100644 --- a/spec/controllers/surveys_controller_spec.rb +++ b/spec/controllers/surveys_controller_spec.rb @@ -14,7 +14,7 @@ describe SurveysController do describe 'GET #index' do context 'guest' do before :each do - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } end it '@sureveys variable is nil' do @@ -25,7 +25,7 @@ describe SurveysController do context 'signed in user' do before :each do sign_in user - get :index, conference_id: conference.short_title + get :index, params: { conference_id: conference.short_title } end it 'assigns @surveys with active surveys' do diff --git a/spec/controllers/tracks_controller_spec.rb b/spec/controllers/tracks_controller_spec.rb index 84ffcc5d..3216e8d0 100644 --- a/spec/controllers/tracks_controller_spec.rb +++ b/spec/controllers/tracks_controller_spec.rb @@ -15,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 @@ -31,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 @@ -45,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 @@ -62,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 @@ -88,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 @@ -113,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 @@ -128,9 +128,9 @@ describe TracksController do describe 'PATCH #update' do context 'updates successfully' do before :each do - patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'), - 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 @@ -154,9 +154,9 @@ describe TracksController do context 'update fails' do before :each do allow_any_instance_of(Track).to receive(:save).and_return(false) - patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'), - 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 @@ -182,7 +182,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 @@ -203,7 +203,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 @@ -224,7 +224,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 diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index eb325f88..c2010e89 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -8,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 @@ -35,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 @@ -44,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