Use keyword arguments in tests
Raisl 5.1 removes support for non-keyword arguments in `#process`, `#get`, `#post`, `#patch`, `#put`, `#delete`, and `#head` for the `ActionDispatch::IntegrationTest` and `ActionController::TestCase` classes. This means we have to add `params` everywhere in the controller tests.
This commit is contained in:
parent
b8013661a2
commit
d1180e2767
35 changed files with 975 additions and 364 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue