style check
This commit is contained in:
parent
32da0fa891
commit
3a68a0d0ad
8 changed files with 114 additions and 119 deletions
|
@ -5,39 +5,39 @@ RSpec.describe Admin::DossierController, type: :controller do
|
|||
let(:dossier_id) { dossier.id }
|
||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||
|
||||
describe "GET #show" do
|
||||
describe 'GET #show' do
|
||||
context 'l\'utilisateur est connecté' do
|
||||
before do
|
||||
sign_in
|
||||
end
|
||||
|
||||
it "returns http success" do
|
||||
get :show, :dossier_id => dossier_id
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'le numéro de dossier n\'existe pas' do
|
||||
get :show, :dossier_id => bad_dossier_id
|
||||
get :show, dossier_id: bad_dossier_id
|
||||
expect(response).to redirect_to('/start/error_dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'L\'utilisateur n\'est pas connecté avec un dossier_id correct' do
|
||||
it {
|
||||
get :show, :dossier_id => dossier_id
|
||||
it do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to redirect_to('/')
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #index" do
|
||||
describe 'GET #index' do
|
||||
let(:user) { create(:user) }
|
||||
before do
|
||||
sign_in
|
||||
end
|
||||
|
||||
it 'le numéro de dossier est correct' do
|
||||
get :index, :dossier_id => dossier_id
|
||||
get :index, dossier_id: dossier_id
|
||||
expect(response).to redirect_to("/admin/dossiers/#{dossier_id}")
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ RSpec.describe Admin::DossierController, type: :controller do
|
|||
end
|
||||
|
||||
it 'le numéro de dossier n\'existe pas' do
|
||||
get :index, :dossier_id => bad_dossier_id
|
||||
get :index, dossier_id: bad_dossier_id
|
||||
expect(response).to redirect_to('/start/error_dossier')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe CarteController, type: :controller do
|
||||
|
||||
let(:bad_adresse){'babouba'}
|
||||
|
||||
let(:bad_adresse) { 'babouba' }
|
||||
|
||||
let(:dossier) { create(:dossier) }
|
||||
let!(:entreprise) { create(:entreprise, dossier: dossier) }
|
||||
|
@ -13,9 +11,8 @@ RSpec.describe CarteController, type: :controller do
|
|||
let(:ref_dossier) { 'IATRQPQY' }
|
||||
let(:adresse) { etablissement.adresse }
|
||||
|
||||
|
||||
describe "GET #show" do
|
||||
it "returns http success" do
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
@ -28,16 +25,16 @@ RSpec.describe CarteController, type: :controller do
|
|||
|
||||
describe 'POST #save_ref_api_carto' do
|
||||
context 'Aucune localisation n\'a jamais été enregistrée' do
|
||||
it {
|
||||
post :save_ref_api_carto, :dossier_id => dossier_id, :ref_dossier => ref_dossier, :back_url => ''
|
||||
it do
|
||||
post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier: ref_dossier, back_url: ''
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context 'En train de modifier la localisation' do
|
||||
let(:dossier) { create(:dossier, ref_dossier: ref_dossier)}
|
||||
let(:dossier) { create(:dossier, ref_dossier: ref_dossier) }
|
||||
before do
|
||||
post :save_ref_api_carto, :dossier_id => dossier_id, :ref_dossier => ref_dossier
|
||||
post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier: ref_dossier
|
||||
end
|
||||
|
||||
context 'Enregistrement d\'un commentaire informant la modification' do
|
||||
|
@ -64,12 +61,12 @@ RSpec.describe CarteController, type: :controller do
|
|||
|
||||
describe '#get_position' do
|
||||
context 'Geocodeur renvoie des positions nil' do
|
||||
let(:etablissement) { create(:etablissement, adresse: bad_adresse)}
|
||||
let(:dossier) {create(:dossier, etablissement: etablissement)}
|
||||
let(:etablissement) { create(:etablissement, adresse: bad_adresse) }
|
||||
let(:dossier) { create(:dossier, etablissement: etablissement) }
|
||||
before do
|
||||
stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{bad_adresse}").
|
||||
to_return(:status => 200, :body => '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', :headers => {})
|
||||
get :get_position, :dossier_id => dossier.id
|
||||
stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{bad_adresse}")
|
||||
.to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})
|
||||
get :get_position, dossier_id: dossier.id
|
||||
end
|
||||
|
||||
subject { dossier.reload }
|
||||
|
@ -82,12 +79,12 @@ RSpec.describe CarteController, type: :controller do
|
|||
|
||||
context 'retour d\'un fichier JSON avec 3 attributs' do
|
||||
before do
|
||||
stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{adresse}").
|
||||
to_return(:status => 200, :body => '{"query": "50 avenue des champs \u00e9lys\u00e9es Paris 75008", "version": "draft", "licence": "ODbL 1.0", "features": [{"geometry": {"coordinates": [2.306888, 48.870374], "type": "Point"}, "type": "Feature", "properties": {"city": "Paris", "label": "50 Avenue des Champs \u00c9lys\u00e9es 75008 Paris", "housenumber": "50", "id": "ADRNIVX_0000000270748251", "postcode": "75008", "name": "50 Avenue des Champs \u00c9lys\u00e9es", "citycode": "75108", "context": "75, \u00cele-de-France", "score": 0.9054545454545454, "type": "housenumber"}}], "type": "FeatureCollection", "attribution": "BAN"}', :headers => {})
|
||||
stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{adresse}")
|
||||
.to_return(status: 200, body: '{"query": "50 avenue des champs \u00e9lys\u00e9es Paris 75008", "version": "draft", "licence": "ODbL 1.0", "features": [{"geometry": {"coordinates": [2.306888, 48.870374], "type": "Point"}, "type": "Feature", "properties": {"city": "Paris", "label": "50 Avenue des Champs \u00c9lys\u00e9es 75008 Paris", "housenumber": "50", "id": "ADRNIVX_0000000270748251", "postcode": "75008", "name": "50 Avenue des Champs \u00c9lys\u00e9es", "citycode": "75108", "context": "75, \u00cele-de-France", "score": 0.9054545454545454, "type": "housenumber"}}], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})
|
||||
|
||||
get :get_position, :dossier_id => dossier_id
|
||||
get :get_position, dossier_id: dossier_id
|
||||
end
|
||||
subject {JSON.parse(response.body)}
|
||||
subject { JSON.parse(response.body) }
|
||||
|
||||
it 'format JSON valide' do
|
||||
expect(response.content_type).to eq('application/json')
|
||||
|
|
|
@ -9,14 +9,14 @@ describe CommentairesController, type: :controller do
|
|||
describe '#POST create' do
|
||||
context 'création correct d\'un commentaire' do
|
||||
it 'depuis la page récapitulatif' do
|
||||
request.env["HTTP_REFERER"] = "/recapitulatif"
|
||||
post :create, :dossier_id => dossier_id, :email_commentaire => email_commentaire, :texte_commentaire => texte_commentaire
|
||||
request.env['HTTP_REFERER'] = '/recapitulatif'
|
||||
post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
|
||||
it 'depuis la page admin' do
|
||||
request.env["HTTP_REFERER"] = "/admin/dossiers"
|
||||
post :create, :dossier_id => dossier_id, :email_commentaire => email_commentaire, :texte_commentaire => texte_commentaire
|
||||
request.env['HTTP_REFERER'] = '/admin/dossiers'
|
||||
post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire
|
||||
expect(response).to redirect_to("/admin/dossiers/#{dossier_id}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,9 +4,9 @@ RSpec.describe DemandesController, type: :controller do
|
|||
let(:dossier) { create(:dossier, formulaire_id: '') }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
describe "GET #show" do
|
||||
it "returns http success" do
|
||||
get :show, :dossier_id => dossier_id
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
@ -14,15 +14,15 @@ RSpec.describe DemandesController, type: :controller do
|
|||
describe 'POST #upated' do
|
||||
context 'when dossier is not linked to formulaire' do
|
||||
it 'redirect to carte controller' do
|
||||
post :update, :dossier_id => dossier_id, :formulaire => '1'
|
||||
post :update, dossier_id: dossier_id, formulaire: '1'
|
||||
expect(response).to redirect_to(controller: :carte, action: :show, dossier_id: dossier_id)
|
||||
end
|
||||
end
|
||||
context 'when dossier is already linked to formaulaire' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
subject { post :update, :dossier_id => dossier_id, :formulaire => '1' }
|
||||
subject { post :update, dossier_id: dossier_id, formulaire: '1' }
|
||||
it 'raise error' do
|
||||
expect{subject}.to raise_error("La modification du formulaire n'est pas possible")
|
||||
expect { subject }.to raise_error("La modification du formulaire n'est pas possible")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,8 +5,8 @@ describe DescriptionController, type: :controller do
|
|||
let(:dossier_id) { dossier.id }
|
||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||
|
||||
describe "GET #show" do
|
||||
it "returns http success" do
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
@ -17,39 +17,38 @@ describe DescriptionController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
let(:timestamp){Time.now}
|
||||
let(:nom_projet){'Projet de test'}
|
||||
let(:description){'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.'}
|
||||
let(:montant_projet){12000}
|
||||
let(:montant_aide_demande){3000}
|
||||
let(:date_previsionnelle){'20/01/2016'}
|
||||
let(:mail_contact){'test@test.com'}
|
||||
describe 'POST #create' do
|
||||
let(:timestamp) { Time.now }
|
||||
let(:nom_projet) { 'Projet de test' }
|
||||
let(:description) { 'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.' }
|
||||
let(:montant_projet) { 12_000 }
|
||||
let(:montant_aide_demande) { 3000 }
|
||||
let(:date_previsionnelle) { '20/01/2016' }
|
||||
let(:mail_contact) { 'test@test.com' }
|
||||
|
||||
let(:name_piece_jointe){'dossierPDF.pdf'}
|
||||
let(:name_piece_jointe_103){'piece_jointe_103.pdf'}
|
||||
let(:name_piece_jointe_692){'piece_jointe_692.pdf'}
|
||||
|
||||
let(:cerfa_pdf) {Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_jointe}", 'application/pdf')}
|
||||
let(:piece_jointe_103) {Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_jointe_103}", 'application/pdf')}
|
||||
let(:piece_jointe_692) {Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_jointe_692}", 'application/pdf')}
|
||||
let(:name_piece_jointe) { 'dossierPDF.pdf' }
|
||||
let(:name_piece_jointe_103) { 'piece_jointe_103.pdf' }
|
||||
let(:name_piece_jointe_692) { 'piece_jointe_692.pdf' }
|
||||
|
||||
let(:cerfa_pdf) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_jointe}", 'application/pdf') }
|
||||
let(:piece_jointe_103) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_jointe_103}", 'application/pdf') }
|
||||
let(:piece_jointe_692) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_jointe_692}", 'application/pdf') }
|
||||
|
||||
context 'Tous les attributs sont bons' do
|
||||
#TODO separer en deux tests : check donnees et check redirect
|
||||
# TODO separer en deux tests : check donnees et check redirect
|
||||
it 'Premier enregistrement des données' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => mail_contact
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
|
||||
#TODO changer les valeurs des champs et check in bdd
|
||||
# TODO changer les valeurs des champs et check in bdd
|
||||
context 'En train de modifier les données de description du projet' do
|
||||
before do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => mail_contact, :back_url => 'recapitulatif'
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact, back_url: 'recapitulatif'
|
||||
end
|
||||
|
||||
context 'Enregistrement d\'un commentaire informant la modification' do
|
||||
subject{Commentaire.last}
|
||||
subject { Commentaire.last }
|
||||
|
||||
it 'champs email' do
|
||||
expect(subject.email).to eq('Modification détails')
|
||||
|
@ -72,39 +71,39 @@ describe DescriptionController, type: :controller do
|
|||
|
||||
context 'Attribut(s) manquant(s)' do
|
||||
it 'nom_projet manquant' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => '', :description => description, :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => mail_contact
|
||||
post :create, dossier_id: dossier_id, nom_projet: '', description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
end
|
||||
|
||||
it 'description manquante' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => '', :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => mail_contact
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: '', montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
end
|
||||
|
||||
it 'montant_projet manquant' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => '', :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => mail_contact
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: '', montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
end
|
||||
|
||||
it 'montant_aide_demande manquant' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => montant_projet, :montant_aide_demande => '', :date_previsionnelle => date_previsionnelle, :mail_contact => mail_contact
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: '', date_previsionnelle: date_previsionnelle, mail_contact: mail_contact
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
end
|
||||
|
||||
it 'date_previsionnelle manquante' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => '', :mail_contact => mail_contact
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: '', mail_contact: mail_contact
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
end
|
||||
|
||||
it 'mail_contact manquant' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => ''
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: ''
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Mauvais format(s)' do
|
||||
it 'mail_contact n\'est un format d\'email' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => 'test.com'
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: 'test.com'
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
end
|
||||
end
|
||||
|
@ -112,19 +111,19 @@ describe DescriptionController, type: :controller do
|
|||
context 'Sauvegarde du CERFA PDF' do
|
||||
before do
|
||||
dossier.build_default_pieces_jointes
|
||||
post :create, :dossier_id => dossier_id,
|
||||
:nom_projet => nom_projet,
|
||||
:description => description,
|
||||
:montant_projet => montant_projet,
|
||||
:montant_aide_demande => montant_aide_demande,
|
||||
:date_previsionnelle => date_previsionnelle,
|
||||
:mail_contact => mail_contact,
|
||||
:cerfa_pdf => cerfa_pdf
|
||||
post :create, dossier_id: dossier_id,
|
||||
nom_projet: nom_projet,
|
||||
description: description,
|
||||
montant_projet: montant_projet,
|
||||
montant_aide_demande: montant_aide_demande,
|
||||
date_previsionnelle: date_previsionnelle,
|
||||
mail_contact: mail_contact,
|
||||
cerfa_pdf: cerfa_pdf
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
context 'un CERFA PDF est envoyé' do
|
||||
subject{ dossier.cerfa }
|
||||
subject { dossier.cerfa }
|
||||
it 'content' do
|
||||
expect(subject['content']).to eq(name_piece_jointe)
|
||||
end
|
||||
|
@ -136,29 +135,29 @@ describe DescriptionController, type: :controller do
|
|||
|
||||
context 'les anciens CERFA PDF sont écrasées à chaque fois' do
|
||||
it 'il n\'y a qu\'un CERFA PDF par dossier' do
|
||||
post :create, :dossier_id => dossier_id, :nom_projet => nom_projet, :description => description, :montant_projet => montant_projet, :montant_aide_demande => montant_aide_demande, :date_previsionnelle => date_previsionnelle, :mail_contact => mail_contact, :cerfa_pdf => cerfa_pdf
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: mail_contact, cerfa_pdf: cerfa_pdf
|
||||
cerfa = PieceJointe.where(type_piece_jointe_id: '0', dossier_id: dossier_id)
|
||||
expect(cerfa.many?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'pas de CERFA PDF' do
|
||||
#TODO à écrire
|
||||
# TODO à écrire
|
||||
end
|
||||
end
|
||||
|
||||
context 'Sauvegarde des pièces jointes' do
|
||||
before do
|
||||
dossier.build_default_pieces_jointes
|
||||
post :create, :dossier_id => dossier_id,
|
||||
:nom_projet => nom_projet,
|
||||
:description => description,
|
||||
:montant_projet => montant_projet,
|
||||
:montant_aide_demande => montant_aide_demande,
|
||||
:date_previsionnelle => date_previsionnelle,
|
||||
:mail_contact => mail_contact,
|
||||
:piece_jointe_692 => piece_jointe_692,
|
||||
:piece_jointe_103 => piece_jointe_103
|
||||
post :create, dossier_id: dossier_id,
|
||||
nom_projet: nom_projet,
|
||||
description: description,
|
||||
montant_projet: montant_projet,
|
||||
montant_aide_demande: montant_aide_demande,
|
||||
date_previsionnelle: date_previsionnelle,
|
||||
mail_contact: mail_contact,
|
||||
piece_jointe_692: piece_jointe_692,
|
||||
piece_jointe_103: piece_jointe_103
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
|
|
|
@ -3,34 +3,34 @@ require 'spec_helper'
|
|||
RSpec.describe DossiersController, type: :controller do
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:siret_not_found) { 999999999999 }
|
||||
let(:siret_not_found) { 999_999_999_999 }
|
||||
|
||||
let(:siren) { dossier.siren }
|
||||
let(:siret) { dossier.siret }
|
||||
let(:bad_siret){1}
|
||||
let(:bad_siret) { 1 }
|
||||
|
||||
describe 'GET #show' do
|
||||
it "returns http success with dossier_id valid" do
|
||||
get :show, :id => dossier_id
|
||||
it 'returns http success with dossier_id valid' do
|
||||
get :show, id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'redirection vers start si mauvais dossier ID' do
|
||||
get :show, :id => siret_not_found
|
||||
get :show, id: siret_not_found
|
||||
expect(response).to redirect_to('/start/error_dossier')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}").
|
||||
to_return(:status => 404, :body => 'fake body')
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 404, body: 'fake body')
|
||||
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}").
|
||||
to_return(:status => 200, :body => File.read('spec/support/files/etablissement.json'))
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}").
|
||||
to_return(:status => 200, :body => File.read('spec/support/files/entreprise.json'))
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
end
|
||||
|
||||
describe 'professionnel fills form' do
|
||||
|
@ -41,11 +41,11 @@ RSpec.describe DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
it 'create a dossier' do
|
||||
expect{ post :create, siret: siret, pro_dossier_id: '' }.to change{ Dossier.count }.by(1)
|
||||
expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Dossier.count }.by(1)
|
||||
end
|
||||
|
||||
it 'creates entreprise' do
|
||||
expect{ post :create, siret: siret, pro_dossier_id: '' }.to change{ Entreprise.count }.by(1)
|
||||
expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Entreprise.count }.by(1)
|
||||
end
|
||||
|
||||
it 'links entreprise to dossier' do
|
||||
|
@ -53,7 +53,7 @@ RSpec.describe DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
it 'creates etablissement for dossier' do
|
||||
expect{ post :create, siret: siret, pro_dossier_id: '' }.to change{ Etablissement.count }.by(1)
|
||||
expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Etablissement.count }.by(1)
|
||||
end
|
||||
|
||||
it 'links etablissement to dossier' do
|
||||
|
@ -69,7 +69,7 @@ RSpec.describe DossiersController, type: :controller do
|
|||
let(:siret_not_found) { '11111111111111' }
|
||||
subject { post :create, siret: siret_not_found, pro_dossier_id: '' }
|
||||
it 'does not create new dossier' do
|
||||
expect{ subject }.not_to change{ Dossier.count }
|
||||
expect { subject }.not_to change { Dossier.count }
|
||||
end
|
||||
|
||||
it 'redirects to show' do
|
||||
|
@ -79,7 +79,7 @@ RSpec.describe DossiersController, type: :controller do
|
|||
end
|
||||
context 'when pro_dossier_id is not empty' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise) }
|
||||
subject { post :create, siret: dossier.siret ,pro_dossier_id: 99999999999}
|
||||
subject { post :create, siret: dossier.siret, pro_dossier_id: 99_999_999_999 }
|
||||
|
||||
context 'when dossier not found' do
|
||||
it 'redirects to start with error_dossier' do
|
||||
|
@ -88,14 +88,13 @@ RSpec.describe DossiersController, type: :controller do
|
|||
end
|
||||
context 'when dossier found' do
|
||||
context 'when siret match' do
|
||||
subject { post :create, siret: dossier.siret ,pro_dossier_id: dossier.id}
|
||||
subject { post :create, siret: dossier.siret, pro_dossier_id: dossier.id }
|
||||
it 'redirects to controller recapitulatif' do
|
||||
expect(subject).to redirect_to(controller: :recapitulatif, action: :show, dossier_id: dossier.id)
|
||||
end
|
||||
|
||||
end
|
||||
context 'when siret does not match' do
|
||||
subject { post :create, siret: '11111111111111' ,pro_dossier_id: dossier.id}
|
||||
subject { post :create, siret: '11111111111111', pro_dossier_id: dossier.id }
|
||||
it 'redirects to start with action error_dossier' do
|
||||
expect(subject).to redirect_to(controller: :start, action: :error_dossier)
|
||||
end
|
||||
|
@ -107,7 +106,7 @@ RSpec.describe DossiersController, type: :controller do
|
|||
|
||||
describe 'PUT #update' do
|
||||
before do
|
||||
put :update, :id => dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||
put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||
end
|
||||
context 'when Checkbox is checked' do
|
||||
let(:autorisation_donnees) { '1' }
|
||||
|
|
|
@ -5,8 +5,8 @@ RSpec.describe RecapitulatifController, type: :controller do
|
|||
|
||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||
|
||||
describe "GET #show" do
|
||||
it "returns http success" do
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier.id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe StartController, type: :controller do
|
||||
describe "GET #index" do
|
||||
it "returns http success" do
|
||||
describe 'GET #index' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #index with bad SIRET" do
|
||||
describe 'GET #index with bad SIRET' do
|
||||
before do
|
||||
get :error_siret
|
||||
end
|
||||
|
||||
it "returns http success and flash alert is present" do
|
||||
it 'returns http success and flash alert is present' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
it 'la flash alert est présente' do
|
||||
|
@ -24,12 +24,12 @@ RSpec.describe StartController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET #index with bad LOGIN" do
|
||||
describe 'GET #index with bad LOGIN' do
|
||||
before do
|
||||
get :error_login
|
||||
end
|
||||
|
||||
it "returns http success and flash alert is present" do
|
||||
it 'returns http success and flash alert is present' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
it 'la flash alert est présente' do
|
||||
|
@ -40,12 +40,12 @@ RSpec.describe StartController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET #index with bad DOSSIER" do
|
||||
describe 'GET #index with bad DOSSIER' do
|
||||
before do
|
||||
get :error_dossier
|
||||
end
|
||||
|
||||
it "returns http success and flash alert is present" do
|
||||
it 'returns http success and flash alert is present' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
it 'la flash alert est présente' do
|
||||
|
|
Loading…
Reference in a new issue