Fix major DEPRECATION WARNING for spec/controllers/admin/*.rb
This commit is contained in:
parent
7c74cbc54b
commit
5750eb1aa5
12 changed files with 99 additions and 92 deletions
1
Gemfile
1
Gemfile
|
@ -108,6 +108,7 @@ group :test do
|
||||||
# gem 'guard-rspec', require: false
|
# gem 'guard-rspec', require: false
|
||||||
# gem 'guard-livereload', '~> 2.4', require: false
|
# gem 'guard-livereload', '~> 2.4', require: false
|
||||||
gem 'vcr'
|
gem 'vcr'
|
||||||
|
gem 'rails-controller-testing'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
|
|
@ -409,6 +409,10 @@ GEM
|
||||||
bundler (>= 1.3.0, < 2.0)
|
bundler (>= 1.3.0, < 2.0)
|
||||||
railties (= 5.0.0.1)
|
railties (= 5.0.0.1)
|
||||||
sprockets-rails (>= 2.0.0)
|
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)
|
rails-dom-testing (2.0.1)
|
||||||
activesupport (>= 4.2.0, < 6.0)
|
activesupport (>= 4.2.0, < 6.0)
|
||||||
nokogiri (~> 1.6.0)
|
nokogiri (~> 1.6.0)
|
||||||
|
@ -628,6 +632,7 @@ DEPENDENCIES
|
||||||
pry-byebug
|
pry-byebug
|
||||||
railroady
|
railroady
|
||||||
rails (= 5.0.0.1)
|
rails (= 5.0.0.1)
|
||||||
|
rails-controller-testing
|
||||||
rest-client
|
rest-client
|
||||||
rgeo-geojson
|
rgeo-geojson
|
||||||
rspec-rails (~> 3.0)
|
rspec-rails (~> 3.0)
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Admin::GestionnairesController < AdminController
|
||||||
assign_gestionnaire!
|
assign_gestionnaire!
|
||||||
end
|
end
|
||||||
|
|
||||||
if procedure_id
|
if procedure_id.present?
|
||||||
redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure_id)
|
redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure_id)
|
||||||
else
|
else
|
||||||
redirect_to admin_gestionnaires_path
|
redirect_to admin_gestionnaires_path
|
||||||
|
|
|
@ -7,9 +7,10 @@ class TypesDeChampService
|
||||||
.permit("#{attributes}" => [:libelle, :description, :order_place, :type_champ, :id, :mandatory, :type,
|
.permit("#{attributes}" => [:libelle, :description, :order_place, :type_champ, :id, :mandatory, :type,
|
||||||
drop_down_list_attributes: [:value, :id]])
|
drop_down_list_attributes: [:value, :id]])
|
||||||
|
|
||||||
parameters[attributes].each do |param|
|
|
||||||
if param.second[:libelle].empty?
|
parameters[attributes].each do |param_first, param_second|
|
||||||
parameters[attributes].delete(param.first.to_s)
|
if param_second[:libelle].empty?
|
||||||
|
parameters[attributes].delete(param_first.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@ describe Admin::AccompagnateursController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
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) }
|
it { expect(subject.status).to eq(200) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PUT #update' do
|
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) }
|
it { expect(subject).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure.id) }
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe Admin::GestionnairesController, type: :controller do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
let(:email) { 'test@plop.com' }
|
let(:email) { 'test@plop.com' }
|
||||||
let(:procedure_id) { nil }
|
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
|
context 'When email is valid' do
|
||||||
before do
|
before do
|
||||||
|
@ -175,7 +175,7 @@ describe Admin::GestionnairesController, type: :controller do
|
||||||
let!(:admin) { create :administrateur }
|
let!(:admin) { create :administrateur }
|
||||||
let!(:gestionnaire) { create :gestionnaire, email: email, administrateurs: [admin] }
|
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
|
context "when gestionaire_id is valid" do
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe Admin::MailsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET index' do
|
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 }
|
it { expect(subject.status).to eq 200 }
|
||||||
end
|
end
|
||||||
|
@ -19,12 +19,12 @@ describe Admin::MailsController, type: :controller do
|
||||||
|
|
||||||
context 'when is mail_received id' do
|
context 'when is mail_received id' do
|
||||||
subject { patch :update,
|
subject { patch :update,
|
||||||
procedure_id: procedure.id,
|
params: {procedure_id: procedure.id,
|
||||||
id: procedure.mail_received.id,
|
id: procedure.mail_received.id,
|
||||||
mail_received: {
|
mail_received: {
|
||||||
object: object,
|
object: object,
|
||||||
body: body
|
body: body
|
||||||
} }
|
}} }
|
||||||
|
|
||||||
it { expect(subject).to redirect_to admin_procedure_mails_path }
|
it { expect(subject).to redirect_to admin_procedure_mails_path }
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
let(:procedure_id) { procedure.id }
|
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
|
context 'when procedure is not found' do
|
||||||
let(:procedure_id) { 9_999_999 }
|
let(:procedure_id) { 9_999_999 }
|
||||||
|
@ -47,7 +47,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
|
||||||
}
|
}
|
||||||
end
|
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 }
|
subject { request }
|
||||||
|
|
||||||
it { is_expected.to render_template('show') }
|
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!(:pj) { create(:type_de_piece_justificative, procedure: procedure) }
|
||||||
let(:procedure_id) { procedure.id }
|
let(:procedure_id) { procedure.id }
|
||||||
let(:pj_id) { pj.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 }
|
subject { request }
|
||||||
context 'when procedure is not found' do
|
context 'when procedure is not found' do
|
||||||
let(:procedure_id) { 9_999_999 }
|
let(:procedure_id) { 9_999_999 }
|
||||||
|
@ -98,7 +98,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #move_up' do
|
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
|
context 'when procedure have no type de champ' do
|
||||||
let(:index) { 0 }
|
let(:index) { 0 }
|
||||||
|
@ -124,7 +124,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
|
||||||
it { expect(subject.status).to eq(200) }
|
it { expect(subject.status).to eq(200) }
|
||||||
it { expect(subject).to render_template('show') }
|
it { expect(subject).to render_template('show') }
|
||||||
it 'changes order places' do
|
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_0.reload
|
||||||
type_de_piece_justificative_1.reload
|
type_de_piece_justificative_1.reload
|
||||||
expect(type_de_piece_justificative_0.order_place).to eq(1)
|
expect(type_de_piece_justificative_0.order_place).to eq(1)
|
||||||
|
@ -135,7 +135,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #move_down' do
|
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 }
|
let(:index) { 0 }
|
||||||
|
|
||||||
subject { request }
|
subject { request }
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe Admin::PrevisualisationsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #show' do
|
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) }
|
it { expect(subject.status).to eq(200) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:procedure_published) { create :procedure, published: true, archived: false }
|
let(:procedure_published) { create :procedure, published: true, archived: false }
|
||||||
let(:procedure_archived) { create :procedure, published: false, archived: true }
|
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
|
context 'when procedure is draft' do
|
||||||
let!(:procedure) { procedure_draft }
|
let!(:procedure) { procedure_draft }
|
||||||
|
@ -98,7 +98,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
|
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
|
||||||
let(:procedure_id) { procedure.id }
|
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
|
context 'when user is not connected' do
|
||||||
before do
|
before do
|
||||||
|
@ -130,14 +130,14 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
context 'when all attributs are filled' do
|
context 'when all attributs are filled' do
|
||||||
describe 'new procedure in database' 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) }
|
it { expect { subject }.to change { Procedure.count }.by(1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure is correctly save' do
|
context 'when procedure is correctly save' do
|
||||||
before do
|
before do
|
||||||
post :create, procedure: procedure_params
|
post :create, params: {procedure: procedure_params}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure attributs in database' do
|
describe 'procedure attributs in database' do
|
||||||
|
@ -175,7 +175,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
let(:description) { '' }
|
let(:description) { '' }
|
||||||
|
|
||||||
describe 'no new procedure in database' do
|
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) }
|
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
|
describe 'flash message is present' do
|
||||||
before do
|
before do
|
||||||
post :create, procedure: procedure_params
|
post :create, params: {procedure: procedure_params}
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(flash[:alert]).to be_present }
|
it { expect(flash[:alert]).to be_present }
|
||||||
|
@ -202,14 +202,14 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
sign_out admin
|
sign_out admin
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { put :update, id: procedure.id }
|
subject { put :update, params: {id: procedure.id} }
|
||||||
|
|
||||||
it { expect(subject).to redirect_to new_administrateur_session_path }
|
it { expect(subject).to redirect_to new_administrateur_session_path }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when administrateur is connected' do
|
context 'when administrateur is connected' do
|
||||||
before do
|
before do
|
||||||
put :update, id: procedure.id, procedure: procedure_params
|
put :update, params: {id: procedure.id, procedure: procedure_params}
|
||||||
procedure.reload
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
context 'when admin is the owner of the procedure' do
|
context 'when admin is the owner of the procedure' do
|
||||||
before 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
|
procedure.reload
|
||||||
procedure2.reload
|
procedure2.reload
|
||||||
end
|
end
|
||||||
|
@ -338,7 +338,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
sign_out admin
|
sign_out admin
|
||||||
sign_in admin_2
|
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
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
context 'when admin is the owner of the procedure' do
|
context 'when admin is the owner of the procedure' do
|
||||||
before do
|
before do
|
||||||
put :archive, procedure_id: procedure.id
|
put :archive, params: {procedure_id: procedure.id}
|
||||||
procedure.reload
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
context 'when owner want to re-enable procedure' do
|
context 'when owner want to re-enable procedure' do
|
||||||
before 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
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
sign_out admin
|
sign_out admin
|
||||||
sign_in admin_2
|
sign_in admin_2
|
||||||
|
|
||||||
put :archive, procedure_id: procedure.id
|
put :archive, params: {procedure_id: procedure.id}
|
||||||
procedure.reload
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
describe 'PUT #clone' do
|
describe 'PUT #clone' do
|
||||||
let!(:procedure) { create(:procedure, administrateur: admin) }
|
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) }
|
it { expect { subject }.to change(Procedure, :count).by(1) }
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
subject
|
subject
|
||||||
end
|
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(response.status).to eq(200) }
|
||||||
it { expect(body.size).to eq(1) }
|
it { expect(body.size).to eq(1) }
|
||||||
|
@ -476,7 +476,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
describe 'POST transfer' do
|
describe 'POST transfer' do
|
||||||
let!(:procedure) { create :procedure, administrateur: admin }
|
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
|
context 'when admin is unknow' do
|
||||||
let(:email_admin) { 'plop' }
|
let(:email_admin) { 'plop' }
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
||||||
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
|
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
|
||||||
let(:procedure_id) { procedure.id }
|
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
|
context 'when procedure is not found' do
|
||||||
let(:procedure_id) { 9_999_999 }
|
let(:procedure_id) { 9_999_999 }
|
||||||
|
@ -65,7 +65,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
||||||
}
|
}
|
||||||
end
|
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
|
context 'when procedure is found' do
|
||||||
it { expect { request }.to change(TypeDeChamp, :count).by(1) }
|
it { expect { request }.to change(TypeDeChamp, :count).by(1) }
|
||||||
|
@ -123,7 +123,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'when procedure is not found' do
|
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
|
it 'creates type de champ' do
|
||||||
expect(subject.status).to eq(404)
|
expect(subject.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
@ -132,7 +132,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
||||||
|
|
||||||
describe '#destroy' do
|
describe '#destroy' do
|
||||||
before 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
|
end
|
||||||
|
|
||||||
context 'when type de champs does not exist' do
|
context 'when type de champs does not exist' do
|
||||||
|
@ -156,7 +156,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #move_up' do
|
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
|
context 'when procedure have no type de champ' do
|
||||||
let(:index) { 0 }
|
let(:index) { 0 }
|
||||||
|
@ -182,7 +182,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
||||||
it { expect(subject.status).to eq(200) }
|
it { expect(subject.status).to eq(200) }
|
||||||
it { expect(subject).to render_template('show') }
|
it { expect(subject).to render_template('show') }
|
||||||
it 'changes order places' do
|
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_0.reload
|
||||||
type_de_champ_1.reload
|
type_de_champ_1.reload
|
||||||
expect(type_de_champ_0.order_place).to eq(1)
|
expect(type_de_champ_0.order_place).to eq(1)
|
||||||
|
@ -193,7 +193,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #move_down' do
|
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 }
|
let(:index) { 0 }
|
||||||
|
|
||||||
subject { request }
|
subject { request }
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
|
||||||
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
|
let(:procedure) { create(:procedure, administrateur: admin, published: published) }
|
||||||
let(:procedure_id) { procedure.id }
|
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
|
context 'when procedure is not found' do
|
||||||
let(:procedure_id) { 9_999_999 }
|
let(:procedure_id) { 9_999_999 }
|
||||||
|
@ -66,7 +66,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
|
||||||
}
|
}
|
||||||
end
|
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
|
context 'when procedure is found' do
|
||||||
it { expect { request }.to change(TypeDeChamp, :count).by(1) }
|
it { expect { request }.to change(TypeDeChamp, :count).by(1) }
|
||||||
|
@ -106,7 +106,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'when procedure is not found' do
|
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
|
it 'creates type de champ' do
|
||||||
expect(subject.status).to eq(404)
|
expect(subject.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
@ -115,7 +115,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
|
||||||
|
|
||||||
describe '#destroy' do
|
describe '#destroy' do
|
||||||
before 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
|
end
|
||||||
|
|
||||||
context 'when type de champs does not exist' do
|
context 'when type de champs does not exist' do
|
||||||
|
@ -139,7 +139,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #move_up' do
|
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
|
context 'when procedure have no type de champ' do
|
||||||
let(:index) { 0 }
|
let(:index) { 0 }
|
||||||
|
@ -165,7 +165,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
|
||||||
it { expect(subject.status).to eq(200) }
|
it { expect(subject.status).to eq(200) }
|
||||||
it { expect(subject).to render_template('show') }
|
it { expect(subject).to render_template('show') }
|
||||||
it 'changes order places' do
|
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_0.reload
|
||||||
type_de_champ_1.reload
|
type_de_champ_1.reload
|
||||||
expect(type_de_champ_0.order_place).to eq(1)
|
expect(type_de_champ_0.order_place).to eq(1)
|
||||||
|
@ -176,7 +176,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #move_down' do
|
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 }
|
let(:index) { 0 }
|
||||||
|
|
||||||
subject { request }
|
subject { request }
|
||||||
|
|
Loading…
Reference in a new issue