Fix major DEPRECATION WARNING for spec/controllers/admin/*.rb

This commit is contained in:
Xavier J 2016-11-15 05:19:30 +01:00
parent 7c74cbc54b
commit 5750eb1aa5
12 changed files with 99 additions and 92 deletions

View file

@ -108,6 +108,7 @@ group :test do
# gem 'guard-rspec', require: false
# gem 'guard-livereload', '~> 2.4', require: false
gem 'vcr'
gem 'rails-controller-testing'
end
group :development do

View file

@ -409,6 +409,10 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.0.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
@ -628,6 +632,7 @@ DEPENDENCIES
pry-byebug
railroady
rails (= 5.0.0.1)
rails-controller-testing
rest-client
rgeo-geojson
rspec-rails (~> 3.0)

View file

@ -21,7 +21,7 @@ class Admin::GestionnairesController < AdminController
assign_gestionnaire!
end
if procedure_id
if procedure_id.present?
redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure_id)
else
redirect_to admin_gestionnaires_path

View file

@ -7,9 +7,10 @@ class TypesDeChampService
.permit("#{attributes}" => [:libelle, :description, :order_place, :type_champ, :id, :mandatory, :type,
drop_down_list_attributes: [:value, :id]])
parameters[attributes].each do |param|
if param.second[:libelle].empty?
parameters[attributes].delete(param.first.to_s)
parameters[attributes].each do |param_first, param_second|
if param_second[:libelle].empty?
parameters[attributes].delete(param_first.to_s)
end
end

View file

@ -10,12 +10,12 @@ describe Admin::AccompagnateursController, type: :controller do
end
describe 'GET #show' do
subject { get :show, procedure_id: procedure.id }
subject { get :show, params: {procedure_id: procedure.id} }
it { expect(subject.status).to eq(200) }
end
describe 'PUT #update' do
subject { put :update, accompagnateur_id: gestionnaire.id ,procedure_id: procedure.id, to: 'assign' }
subject { put :update, params: {accompagnateur_id: gestionnaire.id, procedure_id: procedure.id, to: 'assign'} }
it { expect(subject).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure.id) }

View file

@ -17,7 +17,7 @@ describe Admin::GestionnairesController, type: :controller do
describe 'POST #create' do
let(:email) { 'test@plop.com' }
let(:procedure_id) { nil }
subject { post :create, gestionnaire: {email: email}, procedure_id: procedure_id }
subject { post :create, params: {gestionnaire: {email: email}, procedure_id: procedure_id} }
context 'When email is valid' do
before do
@ -175,7 +175,7 @@ describe Admin::GestionnairesController, type: :controller do
let!(:admin) { create :administrateur }
let!(:gestionnaire) { create :gestionnaire, email: email, administrateurs: [admin] }
subject { delete :destroy, id: gestionnaire.id }
subject { delete :destroy, params: {id: gestionnaire.id} }
context "when gestionaire_id is valid" do
before do

View file

@ -8,7 +8,7 @@ describe Admin::MailsController, type: :controller do
end
describe 'GET index' do
subject { get :index, procedure_id: procedure.id }
subject { get :index, params: {procedure_id: procedure.id} }
it { expect(subject.status).to eq 200 }
end
@ -19,12 +19,12 @@ describe Admin::MailsController, type: :controller do
context 'when is mail_received id' do
subject { patch :update,
procedure_id: procedure.id,
params: {procedure_id: procedure.id,
id: procedure.mail_received.id,
mail_received: {
object: object,
body: body
} }
}} }
it { expect(subject).to redirect_to admin_procedure_mails_path }

View file

@ -11,7 +11,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
describe 'GET #show' do
let(:procedure_id) { procedure.id }
subject { get :show, procedure_id: procedure_id }
subject { get :show, params: {procedure_id: procedure_id} }
context 'when procedure is not found' do
let(:procedure_id) { 9_999_999 }
@ -47,7 +47,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
}
end
let(:request) { put :update, procedure_id: procedure_id, format: :js, procedure: update_params }
let(:request) { put :update, params: {procedure_id: procedure_id, format: :js, procedure: update_params} }
subject { request }
it { is_expected.to render_template('show') }
@ -75,7 +75,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
let!(:pj) { create(:type_de_piece_justificative, procedure: procedure) }
let(:procedure_id) { procedure.id }
let(:pj_id) { pj.id }
let(:request) { delete :destroy, procedure_id: procedure_id, id: pj_id }
let(:request) { delete :destroy, params: {procedure_id: procedure_id, id: pj_id} }
subject { request }
context 'when procedure is not found' do
let(:procedure_id) { 9_999_999 }
@ -98,7 +98,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
end
describe 'POST #move_up' do
subject { post :move_up, procedure_id: procedure.id, index: index, format: :js }
subject { post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} }
context 'when procedure have no type de champ' do
let(:index) { 0 }
@ -124,7 +124,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
it { expect(subject.status).to eq(200) }
it { expect(subject).to render_template('show') }
it 'changes order places' do
post :move_up, procedure_id: procedure.id, index: index, format: :js
post :move_up, params: {procedure_id: procedure.id, index: index, format: :js}
type_de_piece_justificative_0.reload
type_de_piece_justificative_1.reload
expect(type_de_piece_justificative_0.order_place).to eq(1)
@ -135,7 +135,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
end
describe 'POST #move_down' do
let(:request) { post :move_down, procedure_id: procedure.id, index: index, format: :js }
let(:request) { post :move_down, params: {procedure_id: procedure.id, index: index, format: :js} }
let(:index) { 0 }
subject { request }

View file

@ -9,7 +9,7 @@ describe Admin::PrevisualisationsController, type: :controller do
end
describe 'GET #show' do
subject { get :show, procedure_id: procedure.id }
subject { get :show, params: {procedure_id: procedure.id} }
it { expect(subject.status).to eq(200) }
end

View file

@ -58,7 +58,7 @@ describe Admin::ProceduresController, type: :controller do
let(:procedure_published) { create :procedure, published: true, archived: false }
let(:procedure_archived) { create :procedure, published: false, archived: true }
subject { delete :destroy, id: procedure.id }
subject { delete :destroy, params: {id: procedure.id} }
context 'when procedure is draft' do
let!(:procedure) { procedure_draft }
@ -98,7 +98,7 @@ describe Admin::ProceduresController, type: :controller do
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
let(:procedure_id) { procedure.id }
subject { get :edit, id: procedure_id }
subject { get :edit, params: {id: procedure_id} }
context 'when user is not connected' do
before do
@ -130,14 +130,14 @@ describe Admin::ProceduresController, type: :controller do
describe 'POST #create' do
context 'when all attributs are filled' do
describe 'new procedure in database' do
subject { post :create, procedure: procedure_params }
subject { post :create, params: {procedure: procedure_params} }
it { expect { subject }.to change { Procedure.count }.by(1) }
end
context 'when procedure is correctly save' do
before do
post :create, procedure: procedure_params
post :create, params: {procedure: procedure_params}
end
describe 'procedure attributs in database' do
@ -175,7 +175,7 @@ describe Admin::ProceduresController, type: :controller do
let(:description) { '' }
describe 'no new procedure in database' do
subject { post :create, procedure: procedure_params }
subject { post :create, params: {procedure: procedure_params} }
it { expect { subject }.to change { Procedure.count }.by(0) }
@ -186,7 +186,7 @@ describe Admin::ProceduresController, type: :controller do
describe 'flash message is present' do
before do
post :create, procedure: procedure_params
post :create, params: {procedure: procedure_params}
end
it { expect(flash[:alert]).to be_present }
@ -202,14 +202,14 @@ describe Admin::ProceduresController, type: :controller do
sign_out admin
end
subject { put :update, id: procedure.id }
subject { put :update, params: {id: procedure.id} }
it { expect(subject).to redirect_to new_administrateur_session_path }
end
context 'when administrateur is connected' do
before do
put :update, id: procedure.id, procedure: procedure_params
put :update, params: {id: procedure.id, procedure: procedure_params}
procedure.reload
end
@ -270,7 +270,7 @@ describe Admin::ProceduresController, type: :controller do
context 'when admin is the owner of the procedure' do
before do
put :publish, procedure_id: procedure.id, procedure_path: procedure_path
put :publish, params: {procedure_id: procedure.id, procedure_path: procedure_path}
procedure.reload
procedure2.reload
end
@ -338,7 +338,7 @@ describe Admin::ProceduresController, type: :controller do
sign_out admin
sign_in admin_2
put :publish, procedure_id: procedure.id, procedure_path: 'fake_path'
put :publish, params: {procedure_id: procedure.id, procedure_path: 'fake_path'}
procedure.reload
end
@ -354,7 +354,7 @@ describe Admin::ProceduresController, type: :controller do
context 'when admin is the owner of the procedure' do
before do
put :archive, procedure_id: procedure.id
put :archive, params: {procedure_id: procedure.id}
procedure.reload
end
@ -366,7 +366,7 @@ describe Admin::ProceduresController, type: :controller do
context 'when owner want to re-enable procedure' do
before do
put :publish, procedure_id: procedure.id, procedure_path: 'fake_path'
put :publish, params: {procedure_id: procedure.id, procedure_path: 'fake_path'}
procedure.reload
end
@ -383,7 +383,7 @@ describe Admin::ProceduresController, type: :controller do
sign_out admin
sign_in admin_2
put :archive, procedure_id: procedure.id
put :archive, params: {procedure_id: procedure.id}
procedure.reload
end
@ -394,7 +394,7 @@ describe Admin::ProceduresController, type: :controller do
describe 'PUT #clone' do
let!(:procedure) { create(:procedure, administrateur: admin) }
subject { put :clone, procedure_id: procedure.id }
subject { put :clone, params: {procedure_id: procedure.id} }
it { expect { subject }.to change(Procedure, :count).by(1) }
@ -452,7 +452,7 @@ describe Admin::ProceduresController, type: :controller do
subject
end
subject { get :path_list, request: procedure2.path }
subject { get :path_list, params: {request: procedure2.path} }
it { expect(response.status).to eq(200) }
it { expect(body.size).to eq(1) }
@ -476,7 +476,7 @@ describe Admin::ProceduresController, type: :controller do
describe 'POST transfer' do
let!(:procedure) { create :procedure, administrateur: admin }
subject { post :transfer, email_admin: email_admin, procedure_id: procedure.id }
subject { post :transfer, params: {email_admin: email_admin, procedure_id: procedure.id} }
context 'when admin is unknow' do
let(:email_admin) { 'plop' }

View file

@ -13,7 +13,7 @@ describe Admin::TypesDeChampController, type: :controller do
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
let(:procedure_id) { procedure.id }
subject { get :show, procedure_id: procedure_id }
subject { get :show, params: {procedure_id: procedure_id} }
context 'when procedure is not found' do
let(:procedure_id) { 9_999_999 }
@ -65,7 +65,7 @@ describe Admin::TypesDeChampController, type: :controller do
}
end
let(:request) { put :update, format: :js, procedure_id: procedure.id, procedure: procedure_params }
let(:request) { put :update, params: {procedure_id: procedure.id, procedure: procedure_params}, format: :js }
context 'when procedure is found' do
it { expect { request }.to change(TypeDeChamp, :count).by(1) }
@ -123,7 +123,7 @@ describe Admin::TypesDeChampController, type: :controller do
end
end
context 'when procedure is not found' do
subject { put :update, format: :js, procedure_id: 9_999_999, procedure: procedure_params }
subject { put :update, format: :js, params: {procedure_id: 9_999_999, procedure: procedure_params} }
it 'creates type de champ' do
expect(subject.status).to eq(404)
end
@ -132,7 +132,7 @@ describe Admin::TypesDeChampController, type: :controller do
describe '#destroy' do
before do
delete :destroy, procedure_id: procedure.id, id: type_de_champ_id, format: :js
delete :destroy, params: {procedure_id: procedure.id, id: type_de_champ_id, format: :js}
end
context 'when type de champs does not exist' do
@ -156,7 +156,7 @@ describe Admin::TypesDeChampController, type: :controller do
end
describe 'POST #move_up' do
subject { post :move_up, procedure_id: procedure.id, index: index, format: :js }
subject { post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} }
context 'when procedure have no type de champ' do
let(:index) { 0 }
@ -182,7 +182,7 @@ describe Admin::TypesDeChampController, type: :controller do
it { expect(subject.status).to eq(200) }
it { expect(subject).to render_template('show') }
it 'changes order places' do
post :move_up, procedure_id: procedure.id, index: index, format: :js
post :move_up, params: {procedure_id: procedure.id, index: index, format: :js}
type_de_champ_0.reload
type_de_champ_1.reload
expect(type_de_champ_0.order_place).to eq(1)
@ -193,7 +193,7 @@ describe Admin::TypesDeChampController, type: :controller do
end
describe 'POST #move_down' do
let(:request) { post :move_down, procedure_id: procedure.id, index: index, format: :js }
let(:request) { post :move_down, params: {procedure_id: procedure.id, index: index, format: :js} }
let(:index) { 0 }
subject { request }

View file

@ -13,7 +13,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
let(:procedure_id) { procedure.id }
subject { get :show, procedure_id: procedure_id }
subject { get :show, params: {procedure_id: procedure_id} }
context 'when procedure is not found' do
let(:procedure_id) { 9_999_999 }
@ -66,7 +66,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
}
end
let(:request) { put :update, format: :js, procedure_id: procedure.id, procedure: procedure_params }
let(:request) { put :update, params: {format: :js, procedure_id: procedure.id, procedure: procedure_params} }
context 'when procedure is found' do
it { expect { request }.to change(TypeDeChamp, :count).by(1) }
@ -106,7 +106,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
end
end
context 'when procedure is not found' do
subject { put :update, format: :js, procedure_id: 9_999_999, procedure: procedure_params }
subject { put :update, params: {format: :js, procedure_id: 9_999_999, procedure: procedure_params} }
it 'creates type de champ' do
expect(subject.status).to eq(404)
end
@ -115,7 +115,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
describe '#destroy' do
before do
delete :destroy, procedure_id: procedure.id, id: type_de_champ_id, format: :js
delete :destroy, params: {procedure_id: procedure.id, id: type_de_champ_id, format: :js}
end
context 'when type de champs does not exist' do
@ -139,7 +139,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
end
describe 'POST #move_up' do
subject { post :move_up, procedure_id: procedure.id, index: index, format: :js }
subject { post :move_up, params: {procedure_id: procedure.id, index: index, format: :js} }
context 'when procedure have no type de champ' do
let(:index) { 0 }
@ -165,7 +165,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
it { expect(subject.status).to eq(200) }
it { expect(subject).to render_template('show') }
it 'changes order places' do
post :move_up, procedure_id: procedure.id, index: index, format: :js
post :move_up, params: {procedure_id: procedure.id, index: index, format: :js}
type_de_champ_0.reload
type_de_champ_1.reload
expect(type_de_champ_0.order_place).to eq(1)
@ -176,7 +176,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
end
describe 'POST #move_down' do
let(:request) { post :move_down, procedure_id: procedure.id, index: index, format: :js }
let(:request) { post :move_down, params: {procedure_id: procedure.id, index: index, format: :js} }
let(:index) { 0 }
subject { request }