Merge branch 'dev'
This commit is contained in:
commit
68ce658836
20 changed files with 234 additions and 106 deletions
2
Gemfile
2
Gemfile
|
@ -175,7 +175,7 @@ group :development, :test do
|
||||||
gem 'rspec-rails'
|
gem 'rspec-rails'
|
||||||
|
|
||||||
# Deploy
|
# Deploy
|
||||||
gem 'mina', git: 'https://github.com/mina-deploy/mina.git'
|
gem 'mina', git: 'https://github.com/mina-deploy/mina.git', require: false
|
||||||
|
|
||||||
gem 'rspec_junit_formatter'
|
gem 'rspec_junit_formatter'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
class Champs::CarteController < ApplicationController
|
class Champs::CarteController < ApplicationController
|
||||||
before_action :authenticate_logged_user!
|
before_action :authenticate_logged_user!
|
||||||
|
|
||||||
|
EMPTY_GEO_JSON = '[]'
|
||||||
|
ERROR_GEO_JSON = ''
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@selector = ".carte-#{params[:position]}"
|
@selector = ".carte-#{params[:position]}"
|
||||||
|
|
||||||
|
@ -26,13 +29,17 @@ class Champs::CarteController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
geo_areas = []
|
geo_areas = []
|
||||||
geo_json = geo_json.blank? ? [] : JSON.parse(geo_json)
|
|
||||||
|
|
||||||
if geo_json.first == ["error", "TooManyPolygons"]
|
if geo_json == EMPTY_GEO_JSON
|
||||||
|
@champ.value = nil
|
||||||
|
@champ.geo_areas = []
|
||||||
|
elsif geo_json == ERROR_GEO_JSON
|
||||||
@error = true
|
@error = true
|
||||||
@champ.value = nil
|
@champ.value = nil
|
||||||
@champ.geo_areas = []
|
@champ.geo_areas = []
|
||||||
elsif geo_json.present?
|
else
|
||||||
|
geo_json = JSON.parse(geo_json)
|
||||||
|
|
||||||
if @champ.cadastres?
|
if @champ.cadastres?
|
||||||
cadastres = ModuleApiCartoService.generate_cadastre(geo_json)
|
cadastres = ModuleApiCartoService.generate_cadastre(geo_json)
|
||||||
geo_areas += cadastres.map do |cadastre|
|
geo_areas += cadastres.map do |cadastre|
|
||||||
|
|
|
@ -74,44 +74,32 @@ module NewGestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
def passer_en_instruction
|
def passer_en_instruction
|
||||||
dossier.en_instruction!
|
dossier.passer_en_instruction!(current_gestionnaire)
|
||||||
current_gestionnaire.follow(dossier)
|
|
||||||
flash.notice = 'Dossier passé en instruction.'
|
flash.notice = 'Dossier passé en instruction.'
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||||
end
|
end
|
||||||
|
|
||||||
def repasser_en_construction
|
def repasser_en_construction
|
||||||
dossier.en_construction!
|
dossier.repasser_en_construction!(current_gestionnaire)
|
||||||
flash.notice = 'Dossier repassé en construction.'
|
flash.notice = 'Dossier repassé en construction.'
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||||
end
|
end
|
||||||
|
|
||||||
def terminer
|
def terminer
|
||||||
if params[:dossier] && params[:dossier][:motivation].present?
|
motivation = params[:dossier] && params[:dossier][:motivation]
|
||||||
dossier.motivation = params[:dossier][:motivation]
|
|
||||||
end
|
|
||||||
|
|
||||||
case params[:process_action]
|
case params[:process_action]
|
||||||
when "refuser"
|
when "refuser"
|
||||||
dossier.refuse!
|
dossier.refuser!(current_gestionnaire, motivation)
|
||||||
dossier.save
|
|
||||||
flash.notice = "Dossier considéré comme refusé."
|
flash.notice = "Dossier considéré comme refusé."
|
||||||
NotificationMailer.send_refused_notification(dossier).deliver_later
|
|
||||||
when "classer_sans_suite"
|
when "classer_sans_suite"
|
||||||
dossier.sans_suite!
|
dossier.classer_sans_suite!(current_gestionnaire, motivation)
|
||||||
dossier.save
|
|
||||||
flash.notice = "Dossier considéré comme sans suite."
|
flash.notice = "Dossier considéré comme sans suite."
|
||||||
NotificationMailer.send_without_continuation_notification(dossier).deliver_later
|
|
||||||
when "accepter"
|
when "accepter"
|
||||||
dossier.accepte!
|
dossier.accepter!(current_gestionnaire, motivation)
|
||||||
if dossier.attestation.nil?
|
|
||||||
dossier.attestation = dossier.build_attestation
|
|
||||||
dossier.save
|
|
||||||
end
|
|
||||||
flash.notice = "Dossier traité avec succès."
|
flash.notice = "Dossier traité avec succès."
|
||||||
NotificationMailer.send_closed_notification(dossier).deliver_later
|
|
||||||
end
|
end
|
||||||
|
|
||||||
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
render partial: 'state_button_refresh', locals: { dossier: dossier }
|
||||||
|
|
|
@ -107,15 +107,18 @@ export function getCurrentMap(input) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const EMPTY_GEO_JSON = '[]';
|
||||||
|
const ERROR_GEO_JSON = '';
|
||||||
|
|
||||||
export function addFreeDrawEvents(map, selector) {
|
export function addFreeDrawEvents(map, selector) {
|
||||||
const input = findInput(selector);
|
const input = findInput(selector);
|
||||||
map.freeDraw.on('markers', ({ latLngs }) => {
|
map.freeDraw.on('markers', ({ latLngs }) => {
|
||||||
if (latLngs.length === 0) {
|
if (latLngs.length === 0) {
|
||||||
input.value = '';
|
input.value = EMPTY_GEO_JSON;
|
||||||
} else if (polygonArea(latLngs) < 300000) {
|
} else if (polygonArea(latLngs) < 300000) {
|
||||||
input.value = JSON.stringify(latLngs);
|
input.value = JSON.stringify(latLngs);
|
||||||
} else {
|
} else {
|
||||||
input.value = '{ "error": "TooManyPolygons" }';
|
input.value = ERROR_GEO_JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
fire(input, 'change');
|
fire(input, 'change');
|
||||||
|
|
|
@ -3,7 +3,11 @@ class AutoArchiveProcedureJob < ApplicationJob
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure|
|
Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure|
|
||||||
procedure.dossiers.state_en_construction.each(&:en_instruction!)
|
gestionnaire = procedure.gestionnaire_for_cron_job
|
||||||
|
|
||||||
|
procedure.dossiers.state_en_construction.find_each do |dossier|
|
||||||
|
dossier.passer_en_instruction!(gestionnaire)
|
||||||
|
end
|
||||||
|
|
||||||
procedure.archive!
|
procedure.archive!
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
||||||
queue_as :cron
|
queue_as :cron
|
||||||
|
|
||||||
def perform(procedure_id, state)
|
def perform(procedure_id, state, gestionnaire_id = nil)
|
||||||
procedure = Procedure.find(procedure_id)
|
procedure = Procedure.find(procedure_id)
|
||||||
|
gestionnaire = procedure.gestionnaire_for_cron_job
|
||||||
|
|
||||||
case state
|
case state
|
||||||
when Dossier.states.fetch(:en_instruction)
|
when Dossier.states.fetch(:en_instruction)
|
||||||
procedure.dossiers.state_en_construction.update_all(
|
procedure.dossiers.state_en_construction.find_each do |dossier|
|
||||||
state: Dossier.states.fetch(:en_instruction),
|
dossier.passer_en_instruction!(gestionnaire)
|
||||||
en_instruction_at: Time.zone.now
|
end
|
||||||
)
|
|
||||||
when Dossier.states.fetch(:accepte)
|
when Dossier.states.fetch(:accepte)
|
||||||
procedure.dossiers.state_en_construction.find_each do |dossier|
|
procedure.dossiers.state_en_construction.find_each do |dossier|
|
||||||
dossier.update(
|
dossier.accepter!(gestionnaire, '')
|
||||||
state: Dossier.states.fetch(:accepte),
|
|
||||||
en_instruction_at: Time.zone.now,
|
|
||||||
processed_at: Time.zone.now
|
|
||||||
)
|
|
||||||
dossier.attestation = dossier.build_attestation
|
|
||||||
dossier.save
|
|
||||||
NotificationMailer.send_closed_notification(dossier).deliver_later
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise "Receiving Procedure##{procedure_id} in invalid state \"#{state}\""
|
raise "Receiving Procedure##{procedure_id} in invalid state \"#{state}\""
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Preview all emails at http://localhost:3000/rails/mailers/avis_mailer
|
# Preview all emails at http://localhost:3000/rails/mailers/avis_mailer
|
||||||
class AvisMailer < ApplicationMailer
|
class AvisMailer < ApplicationMailer
|
||||||
|
layout 'mailers/layout'
|
||||||
|
|
||||||
def avis_invitation(avis)
|
def avis_invitation(avis)
|
||||||
@avis = avis
|
@avis = avis
|
||||||
email = @avis.gestionnaire&.email || @avis.email
|
email = @avis.gestionnaire&.email || @avis.email
|
||||||
|
|
|
@ -28,6 +28,8 @@ class Dossier < ApplicationRecord
|
||||||
has_many :followers_gestionnaires, through: :follows, source: :gestionnaire
|
has_many :followers_gestionnaires, through: :follows, source: :gestionnaire
|
||||||
has_many :avis, dependent: :destroy
|
has_many :avis, dependent: :destroy
|
||||||
|
|
||||||
|
has_many :dossier_operation_logs
|
||||||
|
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
@ -306,8 +308,63 @@ class Dossier < ApplicationRecord
|
||||||
DossierMailer.notify_deletion_to_user(deleted_dossier, user.email).deliver_later
|
DossierMailer.notify_deletion_to_user(deleted_dossier, user.email).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def passer_en_instruction!(gestionnaire)
|
||||||
|
en_instruction!
|
||||||
|
gestionnaire.follow(self)
|
||||||
|
|
||||||
|
log_dossier_operation(gestionnaire, :passer_en_instruction)
|
||||||
|
end
|
||||||
|
|
||||||
|
def repasser_en_construction!(gestionnaire)
|
||||||
|
self.en_instruction_at = nil
|
||||||
|
en_construction!
|
||||||
|
|
||||||
|
log_dossier_operation(gestionnaire, :repasser_en_construction)
|
||||||
|
end
|
||||||
|
|
||||||
|
def accepter!(gestionnaire, motivation)
|
||||||
|
self.motivation = motivation
|
||||||
|
self.en_instruction_at ||= Time.zone.now
|
||||||
|
|
||||||
|
accepte!
|
||||||
|
|
||||||
|
if attestation.nil?
|
||||||
|
update(attestation: build_attestation)
|
||||||
|
end
|
||||||
|
|
||||||
|
NotificationMailer.send_closed_notification(self).deliver_later
|
||||||
|
log_dossier_operation(gestionnaire, :accepter)
|
||||||
|
end
|
||||||
|
|
||||||
|
def refuser!(gestionnaire, motivation)
|
||||||
|
self.motivation = motivation
|
||||||
|
self.en_instruction_at ||= Time.zone.now
|
||||||
|
|
||||||
|
refuse!
|
||||||
|
|
||||||
|
NotificationMailer.send_refused_notification(self).deliver_later
|
||||||
|
log_dossier_operation(gestionnaire, :refuser)
|
||||||
|
end
|
||||||
|
|
||||||
|
def classer_sans_suite!(gestionnaire, motivation)
|
||||||
|
self.motivation = motivation
|
||||||
|
self.en_instruction_at ||= Time.zone.now
|
||||||
|
|
||||||
|
sans_suite!
|
||||||
|
|
||||||
|
NotificationMailer.send_without_continuation_notification(self).deliver_later
|
||||||
|
log_dossier_operation(gestionnaire, :classer_sans_suite)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def log_dossier_operation(gestionnaire, operation)
|
||||||
|
dossier_operation_logs.create(
|
||||||
|
gestionnaire: gestionnaire,
|
||||||
|
operation: DossierOperationLog.operations.fetch(operation)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def update_state_dates
|
def update_state_dates
|
||||||
if en_construction? && !self.en_construction_at
|
if en_construction? && !self.en_construction_at
|
||||||
self.en_construction_at = Time.zone.now
|
self.en_construction_at = Time.zone.now
|
||||||
|
|
12
app/models/dossier_operation_log.rb
Normal file
12
app/models/dossier_operation_log.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class DossierOperationLog < ApplicationRecord
|
||||||
|
enum operation: {
|
||||||
|
passer_en_instruction: 'passer_en_instruction',
|
||||||
|
repasser_en_construction: 'repasser_en_construction',
|
||||||
|
accepter: 'accepter',
|
||||||
|
refuser: 'refuser',
|
||||||
|
classer_sans_suite: 'classer_sans_suite'
|
||||||
|
}
|
||||||
|
|
||||||
|
belongs_to :dossier
|
||||||
|
belongs_to :gestionnaire
|
||||||
|
end
|
|
@ -358,6 +358,12 @@ class Procedure < ApplicationRecord
|
||||||
where.not(aasm_state: :archivee).where("path LIKE ?", "%#{path}%")
|
where.not(aasm_state: :archivee).where("path LIKE ?", "%#{path}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def gestionnaire_for_cron_job
|
||||||
|
administrateur_email = administrateur.email
|
||||||
|
gestionnaire = Gestionnaire.find_by(email: administrateur_email)
|
||||||
|
gestionnaire || gestionnaires.first
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def claim_path_ownership!(path)
|
def claim_path_ownership!(path)
|
||||||
|
|
|
@ -25,6 +25,7 @@ class ProcedureLogoUploader < BaseUploader
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename
|
def filename
|
||||||
|
if file.present?
|
||||||
if original_filename.present? || model.logo_secure_token
|
if original_filename.present? || model.logo_secure_token
|
||||||
if Flipflop.remote_storage?
|
if Flipflop.remote_storage?
|
||||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||||
|
@ -34,6 +35,7 @@ class ProcedureLogoUploader < BaseUploader
|
||||||
end
|
end
|
||||||
filename
|
filename
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
|
- content_for(:title, 'Vous avez été invité à donner votre avis')
|
||||||
|
|
||||||
- avis_link = @avis.gestionnaire.present? ? gestionnaire_avis_url(@avis) : sign_up_gestionnaire_avis_url(@avis.id, @avis.email)
|
- avis_link = @avis.gestionnaire.present? ? gestionnaire_avis_url(@avis) : sign_up_gestionnaire_avis_url(@avis.id, @avis.email)
|
||||||
|
|
||||||
%p
|
%p
|
||||||
Bonjour,
|
Bonjour,
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= "Vous avez été invité par #{@avis.claimant.email} à donner votre avis sur le dossier nº #{@avis.dossier.id} de la démarche \"#{@avis.dossier.procedure.libelle}\"."
|
Vous avez été invité par
|
||||||
|
%strong= @avis.claimant.email
|
||||||
|
= "à donner votre avis sur le dossier nº #{@avis.dossier.id} de la démarche :"
|
||||||
|
%strong= @avis.dossier.procedure.libelle
|
||||||
|
|
||||||
%p
|
%p
|
||||||
Message de votre interlocuteur :
|
= "#{@avis.claimant.email} vous a écrit :"
|
||||||
%br
|
%br
|
||||||
%span{ style: 'font-style: italic;' }
|
%p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 16px;" }
|
||||||
= @avis.introduction
|
= @avis.introduction
|
||||||
|
|
||||||
- if @avis.gestionnaire.present?
|
- if @avis.gestionnaire.present?
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# API URLs
|
# API URLs
|
||||||
API_ADRESSE_URL = "https://api-adresse.data.gouv.fr"
|
API_ADRESSE_URL = ENV.fetch("API_ADRESSE_URL", "https://api-adresse.data.gouv.fr")
|
||||||
API_CARTO_URL = "https://apicarto.sgmap.fr"
|
API_CARTO_URL = ENV.fetch("API_CARTO_URL", "https://apicarto.sgmap.fr")
|
||||||
API_ENTREPRISE_URL = "https://entreprise.api.gouv.fr/v2"
|
API_ENTREPRISE_URL = ENV.fetch("API_ENTREPRISE_URL", "https://entreprise.api.gouv.fr/v2")
|
||||||
API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr")
|
API_GEO_URL = ENV.fetch("API_GEO_URL", "https://geo.api.gouv.fr")
|
||||||
API_GEO_SANDBOX_URL = "https://sandbox.geo.api.gouv.fr"
|
API_GEO_SANDBOX_URL = ENV.fetch("API_GEO_SANDBOX_URL", "https://sandbox.geo.api.gouv.fr")
|
||||||
HELPSCOUT_API_URL = "https://api.helpscout.net/v2"
|
HELPSCOUT_API_URL = ENV.fetch("HELPSCOUT_API_URL", "https://api.helpscout.net/v2")
|
||||||
PIPEDRIVE_API_URL = "https://api.pipedrive.com/v1"
|
PIPEDRIVE_API_URL = ENV.fetch("PIPEDRIVE_API_URL", "https://api.pipedrive.com/v1")
|
||||||
|
|
||||||
# Internal URLs
|
# Internal URLs
|
||||||
FOG_BASE_URL = "https://static.demarches-simplifiees.fr"
|
FOG_BASE_URL = "https://static.demarches-simplifiees.fr"
|
||||||
|
|
11
db/migrate/20181123195208_create_dossier_operation_logs.rb
Normal file
11
db/migrate/20181123195208_create_dossier_operation_logs.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateDossierOperationLogs < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :dossier_operation_logs do |t|
|
||||||
|
t.string :operation, null: false
|
||||||
|
t.references :dossier, foreign_key: true, index: true
|
||||||
|
t.references :gestionnaire, foreign_key: true, index: true
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
14
db/schema.rb
14
db/schema.rb
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_11_21_234008) do
|
ActiveRecord::Schema.define(version: 2018_11_23_195208) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -218,6 +218,16 @@ ActiveRecord::Schema.define(version: 2018_11_21_234008) do
|
||||||
t.index ["procedure_id"], name: "index_deleted_dossiers_on_procedure_id"
|
t.index ["procedure_id"], name: "index_deleted_dossiers_on_procedure_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "dossier_operation_logs", force: :cascade do |t|
|
||||||
|
t.string "operation", null: false
|
||||||
|
t.bigint "dossier_id"
|
||||||
|
t.bigint "gestionnaire_id"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["dossier_id"], name: "index_dossier_operation_logs_on_dossier_id"
|
||||||
|
t.index ["gestionnaire_id"], name: "index_dossier_operation_logs_on_gestionnaire_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "dossiers", id: :serial, force: :cascade do |t|
|
create_table "dossiers", id: :serial, force: :cascade do |t|
|
||||||
t.boolean "autorisation_donnees"
|
t.boolean "autorisation_donnees"
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
|
@ -608,6 +618,8 @@ ActiveRecord::Schema.define(version: 2018_11_21_234008) do
|
||||||
add_foreign_key "avis", "gestionnaires", column: "claimant_id"
|
add_foreign_key "avis", "gestionnaires", column: "claimant_id"
|
||||||
add_foreign_key "closed_mails", "procedures"
|
add_foreign_key "closed_mails", "procedures"
|
||||||
add_foreign_key "commentaires", "dossiers"
|
add_foreign_key "commentaires", "dossiers"
|
||||||
|
add_foreign_key "dossier_operation_logs", "dossiers"
|
||||||
|
add_foreign_key "dossier_operation_logs", "gestionnaires"
|
||||||
add_foreign_key "dossiers", "users"
|
add_foreign_key "dossiers", "users"
|
||||||
add_foreign_key "feedbacks", "users"
|
add_foreign_key "feedbacks", "users"
|
||||||
add_foreign_key "geo_areas", "champs"
|
add_foreign_key "geo_areas", "champs"
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe Champs::CarteController, type: :controller do
|
||||||
{
|
{
|
||||||
dossier: {
|
dossier: {
|
||||||
champs_attributes: {
|
champs_attributes: {
|
||||||
'1' => { value: selection.to_json }
|
'1' => { value: value }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
position: '1',
|
position: '1',
|
||||||
|
@ -35,13 +35,18 @@ describe Champs::CarteController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when coordinates are empty' do
|
context 'when coordinates are empty' do
|
||||||
let(:selection) { [] }
|
let(:value) { '[]' }
|
||||||
|
|
||||||
it { expect(response.body).to include("DS.drawMapData(\".carte-1\", {\"position\":{\"lon\":\"2.428462\",\"lat\":\"46.538192\",\"zoom\":\"13\"},\"selection\":[],\"quartiersPrioritaires\":[],\"cadastres\":[],\"parcellesAgricoles\":[]});") }
|
it {
|
||||||
|
expect(assigns(:error)).to eq(nil)
|
||||||
|
expect(champ.reload.value).to eq(nil)
|
||||||
|
expect(champ.reload.geo_areas).to eq([])
|
||||||
|
expect(response.body).to include("DS.drawMapData(\".carte-1\", {\"position\":{\"lon\":\"2.428462\",\"lat\":\"46.538192\",\"zoom\":\"13\"},\"selection\":[],\"quartiersPrioritaires\":[],\"cadastres\":[],\"parcellesAgricoles\":[]});")
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when coordinates are informed' do
|
context 'when coordinates are informed' do
|
||||||
let(:selection) { [[{ "lat": 48.87442541960633, "lng": 2.3859214782714844 }, { "lat": 48.87273183590832, "lng": 2.3850631713867183 }, { "lat": 48.87081237174292, "lng": 2.3809432983398438 }, { "lat": 48.8712640169951, "lng": 2.377510070800781 }, { "lat": 48.87510283703279, "lng": 2.3778533935546875 }, { "lat": 48.87544154230615, "lng": 2.382831573486328 }, { "lat": 48.87442541960633, "lng": 2.3859214782714844 }]] }
|
let(:value) { [[{ "lat": 48.87442541960633, "lng": 2.3859214782714844 }, { "lat": 48.87273183590832, "lng": 2.3850631713867183 }, { "lat": 48.87081237174292, "lng": 2.3809432983398438 }, { "lat": 48.8712640169951, "lng": 2.377510070800781 }, { "lat": 48.87510283703279, "lng": 2.3778533935546875 }, { "lat": 48.87544154230615, "lng": 2.382831573486328 }, { "lat": 48.87442541960633, "lng": 2.3859214782714844 }]].to_json }
|
||||||
|
|
||||||
it { expect(response.body).not_to be_nil }
|
it { expect(response.body).not_to be_nil }
|
||||||
it { expect(response.body).to include('MultiPolygon') }
|
it { expect(response.body).to include('MultiPolygon') }
|
||||||
|
@ -50,9 +55,10 @@ describe Champs::CarteController, type: :controller do
|
||||||
|
|
||||||
context 'when error' do
|
context 'when error' do
|
||||||
let(:geojson) { [[{ "lat": 48.87442541960633, "lng": 2.3859214782714844 }, { "lat": 48.87273183590832, "lng": 2.3850631713867183 }, { "lat": 48.87081237174292, "lng": 2.3809432983398438 }, { "lat": 48.8712640169951, "lng": 2.377510070800781 }, { "lat": 48.87510283703279, "lng": 2.3778533935546875 }, { "lat": 48.87544154230615, "lng": 2.382831573486328 }, { "lat": 48.87442541960633, "lng": 2.3859214782714844 }]] }
|
let(:geojson) { [[{ "lat": 48.87442541960633, "lng": 2.3859214782714844 }, { "lat": 48.87273183590832, "lng": 2.3850631713867183 }, { "lat": 48.87081237174292, "lng": 2.3809432983398438 }, { "lat": 48.8712640169951, "lng": 2.377510070800781 }, { "lat": 48.87510283703279, "lng": 2.3778533935546875 }, { "lat": 48.87544154230615, "lng": 2.382831573486328 }, { "lat": 48.87442541960633, "lng": 2.3859214782714844 }]] }
|
||||||
let(:selection) { { error: "TooManyPolygons" } }
|
let(:value) { '' }
|
||||||
|
|
||||||
it {
|
it {
|
||||||
|
expect(assigns(:error)).to eq(true)
|
||||||
expect(champ.reload.value).to eq(nil)
|
expect(champ.reload.value).to eq(nil)
|
||||||
expect(champ.reload.geo_areas).to eq([])
|
expect(champ.reload.geo_areas).to eq([])
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,12 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :with_gestionnaire do
|
||||||
|
after(:build) do |procedure, _evaluator|
|
||||||
|
procedure.gestionnaires << create(:gestionnaire)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
trait :with_api_carto do
|
trait :with_api_carto do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
procedure.module_api_carto.use_api_carto = true
|
procedure.module_api_carto.use_api_carto = true
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe AutoArchiveProcedureJob, type: :job do
|
RSpec.describe AutoArchiveProcedureJob, type: :job do
|
||||||
let!(:procedure) { create(:procedure, :published, auto_archive_on: nil) }
|
let!(:procedure) { create(:procedure, :published, :with_gestionnaire, auto_archive_on: nil) }
|
||||||
let!(:procedure_hier) { create(:procedure, :published, auto_archive_on: 1.day.ago) }
|
let!(:procedure_hier) { create(:procedure, :published, :with_gestionnaire, auto_archive_on: 1.day.ago) }
|
||||||
let!(:procedure_aujourdhui) { create(:procedure, :published, auto_archive_on: Date.today) }
|
let!(:procedure_aujourdhui) { create(:procedure, :published, :with_gestionnaire, auto_archive_on: Date.today) }
|
||||||
let!(:procedure_demain) { create(:procedure, :published, auto_archive_on: 1.day.from_now) }
|
let!(:procedure_demain) { create(:procedure, :published, :with_gestionnaire, auto_archive_on: 1.day.from_now) }
|
||||||
|
|
||||||
subject { AutoArchiveProcedureJob.new.perform }
|
subject { AutoArchiveProcedureJob.new.perform }
|
||||||
|
|
||||||
|
@ -37,18 +37,22 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
|
||||||
procedure_aujourdhui.reload
|
procedure_aujourdhui.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(dossier1.state).to eq Dossier.states.fetch(:brouillon) }
|
it {
|
||||||
it { expect(dossier2.state).to eq Dossier.states.fetch(:en_instruction) }
|
expect(dossier1.state).to eq Dossier.states.fetch(:brouillon)
|
||||||
it { expect(dossier3.state).to eq Dossier.states.fetch(:en_instruction) }
|
expect(dossier2.state).to eq Dossier.states.fetch(:en_instruction)
|
||||||
it { expect(dossier4.state).to eq Dossier.states.fetch(:en_instruction) }
|
expect(dossier3.state).to eq Dossier.states.fetch(:en_instruction)
|
||||||
it { expect(dossier5.state).to eq Dossier.states.fetch(:en_instruction) }
|
expect(dossier4.state).to eq Dossier.states.fetch(:en_instruction)
|
||||||
it { expect(dossier6.state).to eq Dossier.states.fetch(:accepte) }
|
expect(dossier5.state).to eq Dossier.states.fetch(:en_instruction)
|
||||||
it { expect(dossier7.state).to eq Dossier.states.fetch(:refuse) }
|
expect(dossier6.state).to eq Dossier.states.fetch(:accepte)
|
||||||
it { expect(dossier8.state).to eq Dossier.states.fetch(:sans_suite) }
|
expect(dossier7.state).to eq Dossier.states.fetch(:refuse)
|
||||||
it { expect(dossier9.state).to eq Dossier.states.fetch(:en_instruction) }
|
expect(dossier8.state).to eq Dossier.states.fetch(:sans_suite)
|
||||||
|
expect(dossier9.state).to eq Dossier.states.fetch(:en_instruction)
|
||||||
|
}
|
||||||
|
|
||||||
it { expect(procedure_hier.archivee?).to eq true }
|
it {
|
||||||
it { expect(procedure_aujourdhui.archivee?).to eq true }
|
expect(procedure_hier.archivee?).to eq true
|
||||||
|
expect(procedure_aujourdhui.archivee?).to eq true
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when procedures have auto_archive_on set on future" do
|
context "when procedures have auto_archive_on set on future" do
|
||||||
|
|
|
@ -5,57 +5,66 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do
|
||||||
let(:date) { Time.utc(2017, 9, 1, 10, 5, 0) }
|
let(:date) { Time.utc(2017, 9, 1, 10, 5, 0) }
|
||||||
let(:instruction_date) { date + 120 }
|
let(:instruction_date) { date + 120 }
|
||||||
|
|
||||||
|
let(:procedure) { create(:procedure, :with_gestionnaire) }
|
||||||
|
let(:nouveau_dossier1) { create(:dossier, :en_construction, procedure: procedure) }
|
||||||
|
let(:nouveau_dossier2) { create(:dossier, :en_construction, procedure: procedure) }
|
||||||
|
let(:dossier_recu) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||||
|
let(:dossier_brouillon) { create(:dossier, procedure: procedure) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(date)
|
Timecop.freeze(date)
|
||||||
create(:attestation_template, procedure: nouveau_dossier1.procedure)
|
nouveau_dossier1
|
||||||
AutoReceiveDossiersForProcedureJob.new.perform(procedure_id, state)
|
nouveau_dossier2
|
||||||
|
dossier_recu
|
||||||
|
dossier_brouillon
|
||||||
|
|
||||||
|
create(:attestation_template, procedure: procedure)
|
||||||
|
AutoReceiveDossiersForProcedureJob.new.perform(procedure.id, state)
|
||||||
end
|
end
|
||||||
|
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
|
||||||
context "with some dossiers" do
|
context "with some dossiers" do
|
||||||
let(:nouveau_dossier1) { create(:dossier, :en_construction) }
|
|
||||||
let(:nouveau_dossier2) { create(:dossier, :en_construction, procedure: nouveau_dossier1.procedure) }
|
|
||||||
let(:dossier_recu) { create(:dossier, :en_instruction, procedure: nouveau_dossier2.procedure) }
|
|
||||||
let(:dossier_brouillon) { create(:dossier, procedure: dossier_recu.procedure) }
|
|
||||||
let(:procedure_id) { dossier_brouillon.procedure_id }
|
|
||||||
|
|
||||||
context "en_construction" do
|
context "en_construction" do
|
||||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||||
|
|
||||||
it { expect(nouveau_dossier1.reload.en_instruction?).to be true }
|
it {
|
||||||
it { expect(nouveau_dossier1.reload.en_instruction_at).to eq(date) }
|
expect(nouveau_dossier1.reload.en_instruction?).to be true
|
||||||
|
expect(nouveau_dossier1.reload.en_instruction_at).to eq(date)
|
||||||
|
|
||||||
it { expect(nouveau_dossier2.reload.en_instruction?).to be true }
|
expect(nouveau_dossier2.reload.en_instruction?).to be true
|
||||||
it { expect(nouveau_dossier2.reload.en_instruction_at).to eq(date) }
|
expect(nouveau_dossier2.reload.en_instruction_at).to eq(date)
|
||||||
|
|
||||||
it { expect(dossier_recu.reload.en_instruction?).to be true }
|
expect(dossier_recu.reload.en_instruction?).to be true
|
||||||
it { expect(dossier_recu.reload.en_instruction_at).to eq(instruction_date) }
|
expect(dossier_recu.reload.en_instruction_at).to eq(instruction_date)
|
||||||
|
|
||||||
it { expect(dossier_brouillon.reload.brouillon?).to be true }
|
expect(dossier_brouillon.reload.brouillon?).to be true
|
||||||
it { expect(dossier_brouillon.reload.en_instruction_at).to eq(nil) }
|
expect(dossier_brouillon.reload.en_instruction_at).to eq(nil)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
context "accepte" do
|
context "accepte" do
|
||||||
let(:state) { Dossier.states.fetch(:accepte) }
|
let(:state) { Dossier.states.fetch(:accepte) }
|
||||||
|
|
||||||
it { expect(nouveau_dossier1.reload.accepte?).to be true }
|
it {
|
||||||
it { expect(nouveau_dossier1.reload.en_instruction_at).to eq(date) }
|
expect(nouveau_dossier1.reload.accepte?).to be true
|
||||||
it { expect(nouveau_dossier1.reload.processed_at).to eq(date) }
|
expect(nouveau_dossier1.reload.en_instruction_at).to eq(date)
|
||||||
it { expect(nouveau_dossier1.reload.attestation).to be_present }
|
expect(nouveau_dossier1.reload.processed_at).to eq(date)
|
||||||
|
expect(nouveau_dossier1.reload.attestation).to be_present
|
||||||
|
|
||||||
it { expect(nouveau_dossier2.reload.accepte?).to be true }
|
expect(nouveau_dossier2.reload.accepte?).to be true
|
||||||
it { expect(nouveau_dossier2.reload.en_instruction_at).to eq(date) }
|
expect(nouveau_dossier2.reload.en_instruction_at).to eq(date)
|
||||||
it { expect(nouveau_dossier2.reload.processed_at).to eq(date) }
|
expect(nouveau_dossier2.reload.processed_at).to eq(date)
|
||||||
it { expect(nouveau_dossier2.reload.attestation).to be_present }
|
expect(nouveau_dossier2.reload.attestation).to be_present
|
||||||
|
|
||||||
it { expect(dossier_recu.reload.en_instruction?).to be true }
|
expect(dossier_recu.reload.en_instruction?).to be true
|
||||||
it { expect(dossier_recu.reload.en_instruction_at).to eq(instruction_date) }
|
expect(dossier_recu.reload.en_instruction_at).to eq(instruction_date)
|
||||||
it { expect(dossier_recu.reload.processed_at).to eq(nil) }
|
expect(dossier_recu.reload.processed_at).to eq(nil)
|
||||||
|
|
||||||
it { expect(dossier_brouillon.reload.brouillon?).to be true }
|
expect(dossier_brouillon.reload.brouillon?).to be true
|
||||||
it { expect(dossier_brouillon.reload.en_instruction_at).to eq(nil) }
|
expect(dossier_brouillon.reload.en_instruction_at).to eq(nil)
|
||||||
it { expect(dossier_brouillon.reload.processed_at).to eq(nil) }
|
expect(dossier_brouillon.reload.processed_at).to eq(nil)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe AvisMailer, type: :mailer do
|
||||||
subject { described_class.avis_invitation(avis) }
|
subject { described_class.avis_invitation(avis) }
|
||||||
|
|
||||||
it { expect(subject.subject).to eq("Donnez votre avis sur le dossier nº #{avis.dossier.id} (#{avis.dossier.procedure.libelle})") }
|
it { expect(subject.subject).to eq("Donnez votre avis sur le dossier nº #{avis.dossier.id} (#{avis.dossier.procedure.libelle})") }
|
||||||
it { expect(subject.body).to include("Vous avez été invité par #{avis.claimant.email} à donner votre avis sur le dossier nº #{avis.dossier.id} de la démarche "#{avis.dossier.procedure.libelle}".") }
|
it { expect(subject.body).to have_text("Vous avez été invité par #{avis.claimant.email} à donner votre avis sur le dossier nº #{avis.dossier.id} de la démarche : #{avis.dossier.procedure.libelle}") }
|
||||||
it { expect(subject.body).to include(avis.introduction) }
|
it { expect(subject.body).to include(avis.introduction) }
|
||||||
it { expect(subject.body).to include(gestionnaire_avis_url(avis)) }
|
it { expect(subject.body).to include(gestionnaire_avis_url(avis)) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue