diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d9db70a01..c41475865 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -19,11 +19,13 @@
+
+
@@ -34,6 +36,7 @@
+
@@ -53,6 +56,7 @@
+
@@ -60,6 +64,7 @@
+
@@ -68,10 +73,12 @@
-
+
+
+
@@ -80,6 +87,7 @@
+
@@ -87,6 +95,7 @@
+
@@ -100,7 +109,7 @@
-
+
@@ -127,7 +136,28 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -320,7 +768,8 @@
-
+
+
@@ -338,8 +787,8 @@
-
-
+
+
@@ -360,10 +809,10 @@
-
+
-
+
@@ -374,7 +823,7 @@
-
+
@@ -395,10 +844,10 @@
-
+
-
+
@@ -409,7 +858,7 @@
-
+
@@ -430,10 +879,10 @@
-
+
-
+
@@ -444,7 +893,7 @@
-
+
@@ -465,10 +914,10 @@
-
+
-
+
@@ -479,7 +928,7 @@
-
+
@@ -500,10 +949,10 @@
-
+
-
+
@@ -1025,19 +1474,19 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
@@ -1073,12 +1522,16 @@
-
+
+
+
+
+
-
+
@@ -1091,33 +1544,33 @@
-
+
+
-
+
+
+
+
-
-
-
-
@@ -1133,7 +1586,7 @@
-
+
@@ -1142,315 +1595,49 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -1460,7 +1647,7 @@
-
+
@@ -1471,34 +1658,319 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/controllers/commentaires_controller.rb b/app/controllers/commentaires_controller.rb
index c6688c1b4..9120d3671 100644
--- a/app/controllers/commentaires_controller.rb
+++ b/app/controllers/commentaires_controller.rb
@@ -1,6 +1,6 @@
class CommentairesController < ApplicationController
def create
- @commentaire = Commentaire.create
+ @commentaire = Commentaire.new
@commentaire.email = params['email_commentaire']
@commentaire.body = params['texte_commentaire']
@commentaire.dossier = Dossier.find(params['dossier_id'])
@@ -12,6 +12,5 @@ class CommentairesController < ApplicationController
else
redirect_to url_for({controller: 'admin/dossier', action: :show, :dossier_id => params['dossier_id']})
end
-
end
end
diff --git a/app/controllers/demandes_controller.rb b/app/controllers/demandes_controller.rb
index a6bd9be4c..b8fdfdf24 100644
--- a/app/controllers/demandes_controller.rb
+++ b/app/controllers/demandes_controller.rb
@@ -1,14 +1,13 @@
class DemandesController < ApplicationController
def show
@dossier = Dossier.find(params[:dossier_id])
- @evenement_vie = EvenementVie.where(use_admi_facile: true)
+ @evenement_vie = EvenementVie.for_admi_facile
end
def choice
@dossier = Dossier.find(params[:dossier_id])
- @dossier.ref_formulaire = params[:ref_formulaire]
- @dossier.save
+ @dossier.update_attributes(ref_formulaire: params[:ref_formulaire])
- redirect_to url_for({controller: :carte, action: :show, :dossier_id => params[:dossier_id]})
+ redirect_to url_for( { controller: :carte, action: :show, :dossier_id => params[:dossier_id] } )
end
end
diff --git a/app/controllers/dossiers_controller.rb b/app/controllers/dossiers_controller.rb
index 24e7862b7..2d351d72a 100644
--- a/app/controllers/dossiers_controller.rb
+++ b/app/controllers/dossiers_controller.rb
@@ -63,4 +63,18 @@ class DossiersController < ApplicationController
flash.now.alert = 'Les conditions sont obligatoires.'
render 'show'
end
+
+ private
+
+ def dossier_id_is_present?
+
+ end
+
+ def siret
+ params[:siret]
+ end
+
+ def siren
+ siret[0..8]
+ end
end
diff --git a/app/controllers/recapitulatif_controller.rb b/app/controllers/recapitulatif_controller.rb
index 94830f85a..4389ae781 100644
--- a/app/controllers/recapitulatif_controller.rb
+++ b/app/controllers/recapitulatif_controller.rb
@@ -3,6 +3,7 @@ class RecapitulatifController < ApplicationController
@dossier = Dossier.find(params[:dossier_id])
@dossier = @dossier.decorate
+ #mettre dans le modèle
@commentaires = @dossier.commentaires.order(created_at: :desc)
@commentaires = @commentaires.all.decorate
@commentaire_email = @dossier.mail_contact
diff --git a/app/controllers/start_controller.rb b/app/controllers/start_controller.rb
index 595657e24..fa611bec1 100644
--- a/app/controllers/start_controller.rb
+++ b/app/controllers/start_controller.rb
@@ -2,14 +2,17 @@ class StartController < ApplicationController
def index
end
+
def error_siret
flash.now.alert = 'Ce SIRET n\'est pas valide'
render 'index'
end
+
def error_login
flash.now.alert = 'Ce compte n\'existe pas'
render 'index'
end
+
def error_dossier
flash.now.alert = 'Ce dossier n\'existe pas'
render 'index'
diff --git a/app/decorators/commentaire_decorator.rb b/app/decorators/commentaire_decorator.rb
index 58146b3ce..283a7ff1a 100644
--- a/app/decorators/commentaire_decorator.rb
+++ b/app/decorators/commentaire_decorator.rb
@@ -6,5 +6,4 @@ class CommentaireDecorator < Draper::Decorator
rescue
'dd/mm/YYYY - HH:MM'
end
-
end
diff --git a/app/decorators/dossier_decorator.rb b/app/decorators/dossier_decorator.rb
index 4f7d53063..105dffb9c 100644
--- a/app/decorators/dossier_decorator.rb
+++ b/app/decorators/dossier_decorator.rb
@@ -6,8 +6,4 @@ class DossierDecorator < Draper::Decorator
rescue
'dd/mm/YYYY'
end
-
- def date_en
- date_previsionnelle.to_date.strftime("%Y-%m-%d")
- end
end
diff --git a/app/decorators/entreprise_decorator.rb b/app/decorators/entreprise_decorator.rb
index e308458f9..5d9e30fba 100644
--- a/app/decorators/entreprise_decorator.rb
+++ b/app/decorators/entreprise_decorator.rb
@@ -5,10 +5,6 @@ class EntrepriseDecorator < Draper::Decorator
raison_sociale.nil? ? nom + '' + prenom : raison_sociale
end
- def siege_social_true_false
- siege_social? ? 'Cet établissement est le siège social' : 'Cet établissement n\'est pas le siège social'
- end
-
def code_effectif_entreprise_libelle
case code_effectif_entreprise.to_s
diff --git a/app/models/evenement_vie.rb b/app/models/evenement_vie.rb
index cdee12da6..ff9c52041 100644
--- a/app/models/evenement_vie.rb
+++ b/app/models/evenement_vie.rb
@@ -1,2 +1,6 @@
class EvenementVie < ActiveRecord::Base
+ #TODO a tester
+ def self.for_admi_facile
+ where(use_admi_facile: true)
+ end
end
diff --git a/app/views/admin/dossier/show.html.haml b/app/views/admin/dossier/show.html.haml
index 06e432091..cf614ec31 100644
--- a/app/views/admin/dossier/show.html.haml
+++ b/app/views/admin/dossier/show.html.haml
@@ -13,8 +13,6 @@
.content{class: 'row'}
#map_qp{style: 'height:500px', class: 'col-lg-6 col-md-6'}
- %object{ data: "#{@dossier_pdf.ref_dossier_pdf.url}", type: "application/pdf", title:"Dossier PDF", class: 'col-lg-6 col-md-6', style: 'height:500px'}
-
= render partial: '/carte/carte_sources_CSS'
= render partial: '/carte/carte_sources_JS_backend'
%br
diff --git a/app/views/carte/_carte_sources_CSS.html.haml b/app/views/carte/_carte_sources_CSS.html.haml
index 173e9ca87..d994bb9dc 100644
--- a/app/views/carte/_carte_sources_CSS.html.haml
+++ b/app/views/carte/_carte_sources_CSS.html.haml
@@ -1,6 +1,6 @@
%div#sources_CSS_api_carto
- %link{:href => "http://leaflet.github.io/Leaflet.draw/leaflet.draw.css", :rel => "stylesheet", :type => "text/css"}/
- %link{:href => "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css", :rel => "stylesheet", :type => "text/css"}/
- %link{:href => "/assets/api_carto/lib/leaflet.photon.css", :rel => "stylesheet", :type => "text/css"}/
- %link{:href => "http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css", :rel => "stylesheet"}/
- %link{:href => "https://cdn.rawgit.com/CliffCloud/Leaflet.EasyButton/dd04bbf160aa33c44aa63e8a744b3632c162c340/src/easy-button.css", :rel => "stylesheet"}/
+ %link{:href => "http://leaflet.github.io/Leaflet.draw/leaflet.draw.css", :rel => "stylesheet", :type => "text/css"}
+ %link{:href => "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css", :rel => "stylesheet", :type => "text/css"}
+ %link{:href => "/assets/api_carto/lib/leaflet.photon.css", :rel => "stylesheet", :type => "text/css"}
+ %link{:href => "http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css", :rel => "stylesheet"}
+ %link{:href => "https://cdn.rawgit.com/CliffCloud/Leaflet.EasyButton/dd04bbf160aa33c44aa63e8a744b3632c162c340/src/easy-button.css", :rel => "stylesheet"}
diff --git a/app/views/recapitulatif/_commentaires_flux.html.haml b/app/views/recapitulatif/_commentaires_flux.html.haml
index 2a076641d..bf70e9714 100644
--- a/app/views/recapitulatif/_commentaires_flux.html.haml
+++ b/app/views/recapitulatif/_commentaires_flux.html.haml
@@ -16,7 +16,7 @@
%h4{style: 'margin-bottom:2%'} Nouveau
= form_tag(url_for({controller: '/commentaires', action: :create}), class: 'form-inline', method: 'POST') do
%input.form-control{:type => 'text', style: 'width: 30%; margin-bottom:2%', :id => 'email_commentaire', :name => 'email_commentaire', :value => @commentaire_email}
- %textarea.form-control{:id => 'texte_commentaire', :name => 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5'}
+ %textarea.form-control{:id => 'texte_commentaire', :name => 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255'}
%br
%input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'}
%br
diff --git a/spec/controllers/carte_controller_spec.rb b/spec/controllers/carte_controller_spec.rb
index f209a3037..30b207417 100644
--- a/spec/controllers/carte_controller_spec.rb
+++ b/spec/controllers/carte_controller_spec.rb
@@ -8,12 +8,12 @@ RSpec.describe CarteController, type: :controller do
describe "GET #show" do
it "returns http success" do
- get :show, :dossier_id => dossier_id
+ get :show, dossier_id: dossier_id
expect(response).to have_http_status(:success)
end
it 'redirection vers start si mauvais dossier ID' 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
@@ -29,28 +29,27 @@ RSpec.describe CarteController, type: :controller do
context 'En train de modifier la localisation' do
before do
post :save_ref_api_carto, :dossier_id => dossier_id, :ref_dossier => ref_dossier, :back_url => 'recapitulatif'
- @last_commentaire_id = ActiveRecord::Base.connection.execute("SELECT currval('commentaires_id_seq')").getvalue(0,0)
end
- context 'Enregistrement d\'un commentaire informant la modification' do
- subject{Commentaire.find(@last_commentaire_id)}
+ context 'Enregistrement d\'un commentaire informant la modification' do
+ subject { Commentaire.last }
- it 'champs email' do
- expect(subject.email).to eq('Modification localisation')
- end
-
- it 'champs body' do
- expect(subject.body).to eq('La localisation de la demande a été modifiée. Merci de le prendre en compte.')
- end
-
- it 'champs dossier' do
- expect(subject.dossier.id).to eq(dossier_id)
- end
+ it 'champs email' do
+ expect(subject.email).to eq('Modification localisation')
end
- it 'Redirection vers la page récapitulatif' do
- expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
+ it 'champs body' do
+ expect(subject.body).to eq('La localisation de la demande a été modifiée. Merci de le prendre en compte.')
end
+
+ it 'champs dossier' do
+ expect(subject.dossier.id).to eq(dossier_id)
+ end
+ end
+
+ it 'Redirection vers la page récapitulatif' do
+ expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
+ end
end
end
@@ -61,6 +60,8 @@ RSpec.describe CarteController, type: :controller do
get :get_position, :dossier_id => dossier_id
end
+ #TODO Test carto geocodeur ne revoit rien / nil
+
context 'retour d\'un fichier JSON avec 3 attributs' do
subject {JSON.parse(response.body)}
diff --git a/spec/controllers/commentaires_controller_spec.rb b/spec/controllers/commentaires_controller_spec.rb
index 71b75748e..14e1e1321 100644
--- a/spec/controllers/commentaires_controller_spec.rb
+++ b/spec/controllers/commentaires_controller_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe CommentairesController, type: :controller do
+describe CommentairesController, type: :controller do
let (:dossier_id){10000}
let (:email_commentaire){'test@test.com'}
let (:texte_commentaire){'Commentaire de test'}
diff --git a/spec/controllers/dossiers_controller_spec.rb b/spec/controllers/dossiers_controller_spec.rb
index 434078df3..41cc85946 100644
--- a/spec/controllers/dossiers_controller_spec.rb
+++ b/spec/controllers/dossiers_controller_spec.rb
@@ -24,13 +24,13 @@ RSpec.describe DossiersController, type: :controller do
describe 'POST #create' do
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{bad_siret}?token=#{SIADETOKEN}").
- to_return(:status => 404, :body => 'fake body', :headers => {})
+ 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'), :headers => {})
+ 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'), :headers => {})
+ to_return(:status => 200, :body => File.read('spec/support/files/entreprise.json'))
end
context 'Le SIRET est correct' do