mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 06:01:12 +00:00
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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue