commit
43b2393059
193 changed files with 396 additions and 673 deletions
2
.rspec
2
.rspec
|
@ -1,2 +1,2 @@
|
||||||
--color
|
--color
|
||||||
--require spec_helper
|
--require rails_helper
|
||||||
|
|
17
README.md
17
README.md
|
@ -65,22 +65,9 @@ L'application tourne à l'adresse `http://localhost:3000`.
|
||||||
|
|
||||||
En local, un utilisateur de test est créé automatiquement, avec les identifiants `test@exemple.fr`/`this is a very complicated password !`. (voir [db/seeds.rb](https://github.com/betagouv/demarches-simplifiees.fr/blob/dev/db/seeds.rb))
|
En local, un utilisateur de test est créé automatiquement, avec les identifiants `test@exemple.fr`/`this is a very complicated password !`. (voir [db/seeds.rb](https://github.com/betagouv/demarches-simplifiees.fr/blob/dev/db/seeds.rb))
|
||||||
|
|
||||||
### Programmation des jobs
|
### Programmation des tâches récurrentes
|
||||||
|
|
||||||
AutoArchiveProcedureJob.set(cron: "* * * * *").perform_later
|
rails jobs:schedule
|
||||||
WeeklyOverviewJob.set(cron: "0 7 * * MON").perform_later
|
|
||||||
DeclarativeProceduresJob.set(cron: "* * * * *").perform_later
|
|
||||||
UpdateAdministrateurUsageStatisticsJob.set(cron: "0 10 * * *").perform_later
|
|
||||||
FindDubiousProceduresJob.set(cron: "0 0 * * *").perform_later
|
|
||||||
Administrateurs::ActivateBeforeExpirationJob.set(cron: "0 8 * * *").perform_later
|
|
||||||
WarnExpiringDossiersJob.set(cron: "0 0 1 * *").perform_later
|
|
||||||
InstructeurEmailNotificationJob.set(cron: "0 10 * * MON-FRI").perform_later
|
|
||||||
PurgeUnattachedBlobsJob.set(cron: "0 0 * * *").perform_later
|
|
||||||
OperationsSignatureJob.set(cron: "0 6 * * *").perform_later
|
|
||||||
ExpiredDossiersDeletionJob.set(cron: "0 7 * * *").perform_later
|
|
||||||
PurgeStaleExportsJob.set(cron: "*/5 * * * *").perform_later
|
|
||||||
NotifyDraftNotSubmittedJob.set(cron: "0 7 * * *").perform_later
|
|
||||||
DiscardedDossiersDeletionJob.set(cron: "0 7 * * *").perform_later
|
|
||||||
|
|
||||||
### Voir les emails envoyés en local
|
### Voir les emails envoyés en local
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
|
|
||||||
.champs-editor {
|
.champs-editor {
|
||||||
.footer {
|
.footer {
|
||||||
margin-bottom: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttons {
|
.buttons {
|
||||||
|
|
|
@ -62,7 +62,6 @@ export function ajax(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJSON(url, data, method = 'get') {
|
export function getJSON(url, data, method = 'get') {
|
||||||
incrementActiveRequestsCount();
|
|
||||||
data = method !== 'get' ? JSON.stringify(data) : data;
|
data = method !== 'get' ? JSON.stringify(data) : data;
|
||||||
return Promise.resolve(
|
return Promise.resolve(
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -72,7 +71,7 @@ export function getJSON(url, data, method = 'get') {
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
})
|
})
|
||||||
).finally(decrementActiveRequestsCount);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scrollTo(container, scrollTo) {
|
export function scrollTo(container, scrollTo) {
|
||||||
|
@ -115,15 +114,3 @@ export function timeoutable(promise, timeoutDelay) {
|
||||||
});
|
});
|
||||||
return Promise.race([promise, timeoutPromise]);
|
return Promise.race([promise, timeoutPromise]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const DATA_ACTIVE_REQUESTS_COUNT = 'data-active-requests-count';
|
|
||||||
|
|
||||||
function incrementActiveRequestsCount() {
|
|
||||||
const count = document.body.getAttribute(DATA_ACTIVE_REQUESTS_COUNT) || '0';
|
|
||||||
document.body.setAttribute(DATA_ACTIVE_REQUESTS_COUNT, parseInt(count) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function decrementActiveRequestsCount() {
|
|
||||||
const count = document.body.getAttribute(DATA_ACTIVE_REQUESTS_COUNT) || '0';
|
|
||||||
document.body.setAttribute(DATA_ACTIVE_REQUESTS_COUNT, parseInt(count) - 1);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Administrateurs::ActivateBeforeExpirationJob < ApplicationJob
|
class AdministrateurActivateBeforeExpirationJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 8 * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
Administrateur
|
Administrateur
|
|
@ -1,5 +1,5 @@
|
||||||
class AutoArchiveProcedureJob < ApplicationJob
|
class AutoArchiveProcedureJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "* * * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
Procedure.publiees.where("auto_archive_on <= ?", Time.zone.today).each do |procedure|
|
Procedure.publiees.where("auto_archive_on <= ?", Time.zone.today).each do |procedure|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
|
||||||
queue_as :cron
|
|
||||||
|
|
||||||
def perform(procedure_id, state)
|
|
||||||
procedure = Procedure.find(procedure_id)
|
|
||||||
|
|
||||||
case state
|
|
||||||
when Dossier.states.fetch(:en_instruction)
|
|
||||||
procedure
|
|
||||||
.dossiers
|
|
||||||
.state_en_construction
|
|
||||||
.find_each(&:passer_automatiquement_en_instruction!)
|
|
||||||
when Dossier.states.fetch(:accepte)
|
|
||||||
procedure
|
|
||||||
.dossiers
|
|
||||||
.state_en_construction
|
|
||||||
.find_each(&:accepter_automatiquement!)
|
|
||||||
else
|
|
||||||
raise "Receiving Procedure##{procedure_id} in invalid state \"#{state}\""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
29
app/jobs/cron_job.rb
Normal file
29
app/jobs/cron_job.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
class CronJob < ApplicationJob
|
||||||
|
queue_as :cron
|
||||||
|
class_attribute :cron_expression
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def schedule
|
||||||
|
remove if cron_expression_changed?
|
||||||
|
set(cron: cron_expression).perform_later if !scheduled?
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove
|
||||||
|
delayed_job.destroy if scheduled?
|
||||||
|
end
|
||||||
|
|
||||||
|
def scheduled?
|
||||||
|
delayed_job.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def cron_expression_changed?
|
||||||
|
scheduled? && delayed_job.cron != cron_expression
|
||||||
|
end
|
||||||
|
|
||||||
|
def delayed_job
|
||||||
|
Delayed::Job
|
||||||
|
.where('handler LIKE ?', "%job_class: #{name}%")
|
||||||
|
.first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
class DeclarativeProceduresJob < ApplicationJob
|
class DeclarativeProceduresJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "* * * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
Procedure.declarative.find_each(&:process_dossiers!)
|
Procedure.declarative.find_each(&:process_dossiers!)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class DiscardedDossiersDeletionJob < ApplicationJob
|
class DiscardedDossiersDeletionJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 7 * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
Dossier.discarded_brouillon_expired.destroy_all
|
Dossier.discarded_brouillon_expired.destroy_all
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
class EtablissementUpdateJob < ApplicationJob
|
class EtablissementUpdateJob < ApplicationJob
|
||||||
queue_as :default
|
|
||||||
|
|
||||||
def perform(dossier, siret)
|
def perform(dossier, siret)
|
||||||
begin
|
begin
|
||||||
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure_id)
|
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure_id)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class ExpiredDossiersDeletionJob < ApplicationJob
|
class ExpiredDossiersDeletionJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 7 * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
ExpiredDossiersDeletionService.process_expired_dossiers_brouillon
|
ExpiredDossiersDeletionService.process_expired_dossiers_brouillon
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class FindDubiousProceduresJob < ApplicationJob
|
class FindDubiousProceduresJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 0 * * *"
|
||||||
|
|
||||||
FORBIDDEN_KEYWORDS = [
|
FORBIDDEN_KEYWORDS = [
|
||||||
'NIR', 'NIRPP', 'race', 'religion',
|
'NIR', 'NIRPP', 'race', 'religion',
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class InstructeurEmailNotificationJob < ApplicationJob
|
class InstructeurEmailNotificationJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 10 * * MON-FRI"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
NotificationService.send_instructeur_email_notification
|
NotificationService.send_instructeur_email_notification
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class NotifyDraftNotSubmittedJob < ApplicationJob
|
class NotifyDraftNotSubmittedJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 7 * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
Dossier.notify_draft_not_submitted
|
Dossier.notify_draft_not_submitted
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class OperationsSignatureJob < ApplicationJob
|
class OperationsSignatureJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 6 * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
last_midnight = Time.zone.today.beginning_of_day
|
last_midnight = Time.zone.today.beginning_of_day
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class PurgeStaleExportsJob < ApplicationJob
|
class PurgeStaleExportsJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "*/5 * * * *"
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
Export.stale.destroy_all
|
Export.stale.destroy_all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class PurgeUnattachedBlobsJob < ApplicationJob
|
class PurgeUnattachedBlobsJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 0 * * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
ActiveStorage::Blob.unattached
|
ActiveStorage::Blob.unattached
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class UpdateAdministrateurUsageStatisticsJob < ApplicationJob
|
class UpdateAdministrateurUsageStatisticsJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 10 * * *"
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
AdministrateurUsageStatisticsService.new.update_administrateurs
|
AdministrateurUsageStatisticsService.new.update_administrateurs
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class WarnExpiringDossiersJob < ApplicationJob
|
class WarnExpiringDossiersJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 0 1 * *"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
expiring, expired = Dossier
|
expiring, expired = Dossier
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
class WebHookJob < ApplicationJob
|
class WebHookJob < ApplicationJob
|
||||||
queue_as :default
|
|
||||||
|
|
||||||
TIMEOUT = 10
|
TIMEOUT = 10
|
||||||
|
|
||||||
def perform(procedure, dossier)
|
def perform(procedure, dossier)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class WeeklyOverviewJob < ApplicationJob
|
class WeeklyOverviewJob < CronJob
|
||||||
queue_as :cron
|
self.cron_expression = "0 7 * * MON"
|
||||||
|
|
||||||
def perform(*args)
|
def perform(*args)
|
||||||
# Feature flipped to avoid mails in staging due to unprocessed dossier
|
# Feature flipped to avoid mails in staging due to unprocessed dossier
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
class Champs::PieceJustificativeChamp < Champ
|
class Champs::PieceJustificativeChamp < Champ
|
||||||
PIECE_JUSTIFICATIVE_FILE_MAX_SIZE = 200.megabytes
|
MAX_SIZE = 200.megabytes
|
||||||
|
|
||||||
PIECE_JUSTIFICATIVE_FILE_ACCEPTED_FORMATS = [
|
ACCEPTED_FORMATS = [
|
||||||
|
"text/plain",
|
||||||
"application/pdf",
|
"application/pdf",
|
||||||
"application/msword",
|
"application/msword",
|
||||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
|
@ -16,6 +17,13 @@ class Champs::PieceJustificativeChamp < Champ
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# TODO: once we're running on Rails 6, re-enable this validation.
|
||||||
|
# See https://github.com/betagouv/demarches-simplifiees.fr/issues/4926
|
||||||
|
#
|
||||||
|
# validates :piece_justificative_file,
|
||||||
|
# content_type: ACCEPTED_FORMATS,
|
||||||
|
# size: { less_than: MAX_SIZE }
|
||||||
|
|
||||||
def main_value_name
|
def main_value_name
|
||||||
:piece_justificative_file
|
:piece_justificative_file
|
||||||
end
|
end
|
||||||
|
@ -28,28 +36,6 @@ class Champs::PieceJustificativeChamp < Champ
|
||||||
mandatory? && !piece_justificative_file.attached?
|
mandatory? && !piece_justificative_file.attached?
|
||||||
end
|
end
|
||||||
|
|
||||||
def piece_justificative_file_errors
|
|
||||||
errors = []
|
|
||||||
|
|
||||||
if piece_justificative_file.attached? && piece_justificative_file.previous_changes.present?
|
|
||||||
if piece_justificative_file.blob.byte_size > PIECE_JUSTIFICATIVE_FILE_MAX_SIZE
|
|
||||||
errors << "Le fichier #{piece_justificative_file.filename} est trop lourd, il doit faire au plus #{PIECE_JUSTIFICATIVE_FILE_MAX_SIZE.to_s(:human_size, precision: 2)}"
|
|
||||||
end
|
|
||||||
|
|
||||||
if !piece_justificative_file.blob.content_type.in?(PIECE_JUSTIFICATIVE_FILE_ACCEPTED_FORMATS)
|
|
||||||
errors << "Le fichier #{piece_justificative_file.filename} est dans un format que nous n'acceptons pas"
|
|
||||||
end
|
|
||||||
|
|
||||||
# FIXME: add Clamav check
|
|
||||||
end
|
|
||||||
|
|
||||||
if errors.present?
|
|
||||||
piece_justificative_file.purge_later
|
|
||||||
end
|
|
||||||
|
|
||||||
errors
|
|
||||||
end
|
|
||||||
|
|
||||||
def for_api
|
def for_api
|
||||||
if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?)
|
if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?)
|
||||||
piece_justificative_file.service_url
|
piece_justificative_file.service_url
|
||||||
|
|
|
@ -38,12 +38,12 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p
|
||||||
|
|
||||||
pdf.bounding_box([0, pdf.cursor], width: body_width, height: body_height) do
|
pdf.bounding_box([0, pdf.cursor], width: body_width, height: body_height) do
|
||||||
if logo.present?
|
if logo.present?
|
||||||
logo_file = if logo.is_a?(ActiveStorage::Attached::One)
|
logo_content = if logo.is_a?(ActiveStorage::Attached::One)
|
||||||
logo.download
|
logo.download
|
||||||
else
|
else
|
||||||
logo.read
|
logo.rewind && logo.read
|
||||||
end
|
end
|
||||||
pdf.image StringIO.new(logo_file), fit: [max_logo_width , max_logo_height], position: :center
|
pdf.image StringIO.new(logo_content), fit: [max_logo_width , max_logo_height], position: :center
|
||||||
end
|
end
|
||||||
|
|
||||||
pdf.fill_color grey
|
pdf.fill_color grey
|
||||||
|
@ -57,12 +57,12 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p
|
||||||
|
|
||||||
if signature.present?
|
if signature.present?
|
||||||
pdf.pad_top(40) do
|
pdf.pad_top(40) do
|
||||||
signature_file = if signature.is_a?(ActiveStorage::Attached::One)
|
signature_content = if signature.is_a?(ActiveStorage::Attached::One)
|
||||||
signature.download
|
signature.download
|
||||||
else
|
else
|
||||||
signature.read
|
signature.rewind && signature.read
|
||||||
end
|
end
|
||||||
pdf.image StringIO.new(signature_file), fit: [max_signature_size , max_signature_size], position: :right
|
pdf.image StringIO.new(signature_content), fit: [max_signature_size , max_signature_size], position: :right
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,6 +64,16 @@ namespace :after_party do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
namespace :jobs_schedule do
|
||||||
|
desc "Run jobs_schedule tasks."
|
||||||
|
task :run do
|
||||||
|
command %{
|
||||||
|
echo "-----> Running jobs_schedule"
|
||||||
|
#{echo_cmd %[bundle exec rake jobs:schedule]}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
namespace :service do
|
namespace :service do
|
||||||
desc "Restart puma"
|
desc "Restart puma"
|
||||||
task :restart_puma do
|
task :restart_puma do
|
||||||
|
@ -123,4 +133,5 @@ task :post_deploy do
|
||||||
command 'cd /home/ds/current'
|
command 'cd /home/ds/current'
|
||||||
|
|
||||||
invoke :'after_party:run'
|
invoke :'after_party:run'
|
||||||
|
invoke :'jobs_schedule:run'
|
||||||
end
|
end
|
||||||
|
|
4
config/locales/active_storage_validations.fr.yml
Normal file
4
config/locales/active_storage_validations.fr.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
fr:
|
||||||
|
errors:
|
||||||
|
messages:
|
||||||
|
content_type_invalid: n’est pas d’un type accepté
|
|
@ -3,3 +3,4 @@ fr:
|
||||||
attributes:
|
attributes:
|
||||||
champ:
|
champ:
|
||||||
value: La valeur du champ
|
value: La valeur du champ
|
||||||
|
piece_justificative_file: La pièce justificative
|
||||||
|
|
8
lib/tasks/jobs.rake
Normal file
8
lib/tasks/jobs.rake
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
namespace :jobs do
|
||||||
|
desc 'Schedule all cron jobs'
|
||||||
|
task schedule: :environment do
|
||||||
|
glob = Rails.root.join('app', 'jobs', '**', '*_job.rb')
|
||||||
|
Dir.glob(glob).each { |f| require f }
|
||||||
|
CronJob.subclasses.each(&:schedule)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Admin::AssignsController, type: :controller do
|
describe Admin::AssignsController, type: :controller do
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
include ActionDispatch::TestProcess
|
include ActionDispatch::TestProcess
|
||||||
|
|
||||||
describe Admin::AttestationTemplatesController, type: :controller do
|
describe Admin::AttestationTemplatesController, type: :controller do
|
||||||
let!(:attestation_template) { create(:attestation_template) }
|
let!(:attestation_template) { create(:attestation_template) }
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
|
@ -17,6 +18,14 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
||||||
|
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
|
||||||
|
shared_examples 'rendering a PDF successfully' do
|
||||||
|
render_views
|
||||||
|
it 'renders a PDF' do
|
||||||
|
expect(subject.status).to eq(200)
|
||||||
|
expect(subject.content_type).to eq('application/pdf')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'POST #preview' do
|
describe 'POST #preview' do
|
||||||
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }
|
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }
|
||||||
|
|
||||||
|
@ -36,31 +45,44 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
||||||
|
|
||||||
context 'if an attestation template does not exist on the procedure' do
|
context 'if an attestation template does not exist on the procedure' do
|
||||||
let(:attestation_template) { nil }
|
let(:attestation_template) { nil }
|
||||||
it { expect(subject.status).to eq(200) }
|
|
||||||
|
context 'with images' do
|
||||||
|
let(:upload_params) { { title: 't', body: 'b', footer: 'f', logo: interlaced_logo } }
|
||||||
|
|
||||||
|
it { expect(assigns(:attestation)).to include({ title: 't', body: 'b', footer: 'f' }) }
|
||||||
|
it { expect(assigns(:attestation)[:logo]).to be_present }
|
||||||
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'without images' do
|
||||||
|
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }
|
||||||
|
|
||||||
it { expect(assigns(:attestation)).to include(upload_params) }
|
it { expect(assigns(:attestation)).to include(upload_params) }
|
||||||
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'if an attestation template exists on the procedure' do
|
context 'if an attestation template exists on the procedure' do
|
||||||
after { procedure.attestation_template.destroy }
|
after { procedure.attestation_template.destroy }
|
||||||
|
|
||||||
context 'with logos' do
|
context 'with images' do
|
||||||
let!(:attestation_template) do
|
let!(:attestation_template) do
|
||||||
create(:attestation_template, logo: logo, signature: signature)
|
create(:attestation_template, logo: logo, signature: signature)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject.status).to eq(200) }
|
|
||||||
it { expect(assigns(:attestation)).to include(upload_params) }
|
it { expect(assigns(:attestation)).to include(upload_params) }
|
||||||
it { expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now) }
|
it { expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now) }
|
||||||
it { expect(assigns(:attestation)[:logo].download).to eq(logo2.read) }
|
it { expect(assigns(:attestation)[:logo].download).to eq(logo2.read) }
|
||||||
it { expect(assigns(:attestation)[:signature].download).to eq(signature2.read) }
|
it { expect(assigns(:attestation)[:signature].download).to eq(signature2.read) }
|
||||||
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with empty logo' do
|
context 'without images' do
|
||||||
it { expect(subject.status).to eq(200) }
|
|
||||||
it { expect(assigns(:attestation)).to include(upload_params) }
|
it { expect(assigns(:attestation)).to include(upload_params) }
|
||||||
it { expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now) }
|
it { expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now) }
|
||||||
it { expect(assigns(:attestation)[:logo]).to eq(nil) }
|
it { expect(assigns(:attestation)[:logo]).to eq(nil) }
|
||||||
it { expect(assigns(:attestation)[:signature]).to eq(nil) }
|
it { expect(assigns(:attestation)[:signature]).to eq(nil) }
|
||||||
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Admin::InstructeursController, type: :controller do
|
describe Admin::InstructeursController, type: :controller do
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
let(:email_2) { 'plip@octo.com' }
|
let(:email_2) { 'plip@octo.com' }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Admin::MailTemplatesController, type: :controller do
|
describe Admin::MailTemplatesController, type: :controller do
|
||||||
let(:procedure) { create :procedure }
|
let(:procedure) { create :procedure }
|
||||||
let(:initiated_mail) { Mails::InitiatedMail.default_for_procedure(procedure) }
|
let(:initiated_mail) { Mails::InitiatedMail.default_for_procedure(procedure) }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
require 'uri'
|
require 'uri'
|
||||||
|
|
||||||
describe Admin::ProceduresController, type: :controller do
|
describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Administrations::OmniauthCallbacksController, type: :controller do
|
describe Administrations::OmniauthCallbacksController, type: :controller do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@request.env["devise.mapping"] = Devise.mappings[:administration]
|
@request.env["devise.mapping"] = Devise.mappings[:administration]
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe API::V1::DossiersController do
|
describe API::V1::DossiersController do
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
let(:token) { admin.renew_api_token }
|
let(:token) { admin.renew_api_token }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe API::V2::GraphqlController do
|
describe API::V2::GraphqlController do
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
let(:token) { admin.renew_api_token }
|
let(:token) { admin.renew_api_token }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe APIController, type: :controller do
|
describe APIController, type: :controller do
|
||||||
describe 'valid_token_for_procedure?' do
|
describe 'valid_token_for_procedure?' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ApplicationController, type: :controller do
|
describe ApplicationController, type: :controller do
|
||||||
describe 'before_action: set_raven_context' do
|
describe 'before_action: set_raven_context' do
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe AttachmentsController, type: :controller do
|
describe AttachmentsController, type: :controller do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Champs::CarteController, type: :controller do
|
describe Champs::CarteController, type: :controller do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Champs::DossierLinkController, type: :controller do
|
describe Champs::DossierLinkController, type: :controller do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Champs::SiretController, type: :controller do
|
describe Champs::SiretController, type: :controller do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe ProcedureContextConcern, type: :controller do
|
RSpec.describe ProcedureContextConcern, type: :controller do
|
||||||
class TestController < ActionController::Base
|
class TestController < ActionController::Base
|
||||||
include ProcedureContextConcern
|
include ProcedureContextConcern
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Devise::StoreLocationExtension, type: :controller do
|
RSpec.describe Devise::StoreLocationExtension, type: :controller do
|
||||||
class TestController < ActionController::Base
|
class TestController < ActionController::Base
|
||||||
include Devise::Controllers::StoreLocation
|
include Devise::Controllers::StoreLocation
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Instructeurs::AvisController, type: :controller do
|
describe Instructeurs::AvisController, type: :controller do
|
||||||
context 'with a instructeur signed in' do
|
context 'with a instructeur signed in' do
|
||||||
render_views
|
render_views
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Instructeurs::DossiersController, type: :controller do
|
describe Instructeurs::DossiersController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Instructeurs::InstructeurController, type: :controller do
|
describe Instructeurs::InstructeurController, type: :controller do
|
||||||
describe 'before actions: authenticate_instructeur!' do
|
describe 'before actions: authenticate_instructeur!' do
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Instructeurs::ProceduresController, type: :controller do
|
describe Instructeurs::ProceduresController, type: :controller do
|
||||||
describe "before_action: ensure_ownership!" do
|
describe "before_action: ensure_ownership!" do
|
||||||
it "is present" do
|
it "is present" do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Instructeurs::RechercheController, type: :controller do
|
describe Instructeurs::RechercheController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, :en_construction) }
|
let(:dossier) { create(:dossier, :en_construction) }
|
||||||
let(:dossier2) { create(:dossier, :en_construction, procedure: dossier.procedure) }
|
let(:dossier2) { create(:dossier, :en_construction, procedure: dossier.procedure) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe InvitesController, type: :controller do
|
describe InvitesController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, :en_construction) }
|
let(:dossier) { create(:dossier, :en_construction) }
|
||||||
let(:email) { 'plop@octo.com' }
|
let(:email) { 'plop@octo.com' }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe PingController, type: :controller do
|
describe PingController, type: :controller do
|
||||||
describe 'GET #index' do
|
describe 'GET #index' do
|
||||||
subject { get :index }
|
subject { get :index }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe RootController, type: :controller do
|
describe RootController, type: :controller do
|
||||||
subject { get :index }
|
subject { get :index }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe StatsController, type: :controller do
|
describe StatsController, type: :controller do
|
||||||
describe "#last_four_months_hash" do
|
describe "#last_four_months_hash" do
|
||||||
context "while a regular user is logged in" do
|
context "while a regular user is logged in" do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe SupportController, type: :controller do
|
describe SupportController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Users::CommencerController, type: :controller do
|
describe Users::CommencerController, type: :controller do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:published_procedure) { create(:procedure, :published) }
|
let(:published_procedure) { create(:procedure, :published) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Users::ConfirmationsController, type: :controller do
|
describe Users::ConfirmationsController, type: :controller do
|
||||||
let!(:user) { create(:user, :unconfirmed) }
|
let!(:user) { create(:user, :unconfirmed) }
|
||||||
let(:confirmation_token) { user.confirmation_token }
|
let(:confirmation_token) { user.confirmation_token }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Users::DossiersController, type: :controller do
|
describe Users::DossiersController, type: :controller do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require "spec_helper"
|
|
||||||
|
|
||||||
describe Users::PasswordsController, type: :controller do
|
describe Users::PasswordsController, type: :controller do
|
||||||
before do
|
before do
|
||||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Users::ProfilController, type: :controller do
|
describe Users::ProfilController, type: :controller do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Users::UserController, type: :controller do
|
describe Users::UserController, type: :controller do
|
||||||
describe 'before actions: authenticate_instructeur!' do
|
describe 'before actions: authenticate_instructeur!' do
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe WebhookController, type: :controller do
|
describe WebhookController, type: :controller do
|
||||||
describe '#helpscout' do
|
describe '#helpscout' do
|
||||||
before { allow(controller).to receive(:verify_signature!).and_return(true) }
|
before { allow(controller).to receive(:verify_signature!).and_return(true) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'As an administrateur', js: true do
|
feature 'As an administrateur', js: true do
|
||||||
let(:administration) { create(:administration) }
|
let(:administration) { create(:administration) }
|
||||||
let(:admin_email) { 'new_admin@gouv.fr' }
|
let(:admin_email) { 'new_admin@gouv.fr' }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
require 'features/admin/procedure_spec_helper'
|
require 'features/admin/procedure_spec_helper'
|
||||||
|
|
||||||
feature 'As an administrateur I wanna clone a procedure', js: true do
|
feature 'As an administrateur I wanna clone a procedure', js: true do
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
require 'features/admin/procedure_spec_helper'
|
require 'features/admin/procedure_spec_helper'
|
||||||
|
|
||||||
feature 'As an administrateur I wanna create a new procedure', js: true do
|
feature 'As an administrateur I wanna create a new procedure', js: true do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'procedure locked' do
|
feature 'procedure locked' do
|
||||||
let(:administrateur) { create(:administrateur) }
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
require 'features/admin/procedure_spec_helper'
|
require 'features/admin/procedure_spec_helper'
|
||||||
|
|
||||||
feature 'Administrateurs can edit procedures', js: true do
|
feature 'Administrateurs can edit procedures', js: true do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'France Connect Particulier Connexion' do
|
feature 'France Connect Particulier Connexion' do
|
||||||
let(:code) { 'plop' }
|
let(:code) { 'plop' }
|
||||||
let(:given_name) { 'titi' }
|
let(:given_name) { 'titi' }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Getting help:' do
|
feature 'Getting help:' do
|
||||||
scenario 'a Help button is visible on public pages' do
|
scenario 'a Help button is visible on public pages' do
|
||||||
visit '/'
|
visit '/'
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Inviting an expert:' do
|
feature 'Inviting an expert:' do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
include ActionView::Helpers
|
include ActionView::Helpers
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'As an instructeur', js: true do
|
feature 'As an instructeur', js: true do
|
||||||
let(:administrateur) { create(:administrateur, :with_procedure) }
|
let(:administrateur) { create(:administrateur, :with_procedure) }
|
||||||
let(:procedure) { administrateur.procedures.first }
|
let(:procedure) { administrateur.procedures.first }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Instructing a dossier:' do
|
feature 'Instructing a dossier:' do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require "spec_helper"
|
|
||||||
|
|
||||||
feature "procedure filters" do
|
feature "procedure filters" do
|
||||||
let(:instructeur) { create(:instructeur) }
|
let(:instructeur) { create(:instructeur) }
|
||||||
let(:procedure) { create(:procedure, :published, :with_type_de_champ, instructeurs: [instructeur]) }
|
let(:procedure) { create(:procedure, :published, :with_type_de_champ, instructeurs: [instructeur]) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'As an administrateur I can edit types de champ', js: true do
|
feature 'As an administrateur I can edit types de champ', js: true do
|
||||||
let(:administrateur) { procedure.administrateurs.first }
|
let(:administrateur) { procedure.administrateurs.first }
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Outdated browsers support:' do
|
feature 'Outdated browsers support:' do
|
||||||
context 'when the user browser is outdated' do
|
context 'when the user browser is outdated' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'The routing', js: true do
|
feature 'The routing', js: true do
|
||||||
let(:password) { 'a very complicated password' }
|
let(:password) { 'a very complicated password' }
|
||||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual) }
|
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Signin in:' do
|
feature 'Signin in:' do
|
||||||
let!(:user) { create(:user, password: password) }
|
let!(:user) { create(:user, password: password) }
|
||||||
let(:password) { 'démarches-simplifiées-pwd' }
|
let(:password) { 'démarches-simplifiées-pwd' }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
feature 'The user' do
|
feature 'The user' do
|
||||||
let(:password) { 'démarches-simplifiées-pwd' }
|
let(:password) { 'démarches-simplifiées-pwd' }
|
||||||
let!(:user) { create(:user, password: password) }
|
let!(:user) { create(:user, password: password) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Changing an email' do
|
feature 'Changing an email' do
|
||||||
let(:old_email) { 'old@email.com' }
|
let(:old_email) { 'old@email.com' }
|
||||||
let(:user) { create(:user, email: old_email) }
|
let(:user) { create(:user, email: old_email) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Creating a new dossier:' do
|
feature 'Creating a new dossier:' do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:siret) { '40307130100044' }
|
let(:siret) { '40307130100044' }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
require 'features/users/dossier_shared_examples.rb'
|
require 'features/users/dossier_shared_examples.rb'
|
||||||
|
|
||||||
feature 'Invitations' do
|
feature 'Invitations' do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'linked dropdown lists' do
|
feature 'linked dropdown lists' do
|
||||||
let(:password) { 'démarches-simplifiées-pwd' }
|
let(:password) { 'démarches-simplifiées-pwd' }
|
||||||
let!(:user) { create(:user, password: password) }
|
let!(:user) { create(:user, password: password) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe 'user access to the list of their dossiers' do
|
describe 'user access to the list of their dossiers' do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let!(:dossier_brouillon) { create(:dossier, user: user) }
|
let!(:dossier_brouillon) { create(:dossier, user: user) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Managing password:' do
|
feature 'Managing password:' do
|
||||||
context 'for simple users' do
|
context 'for simple users' do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Sign out' do
|
feature 'Sign out' do
|
||||||
context 'when a user is logged in' do
|
context 'when a user is logged in' do
|
||||||
let(:user) { create(:administrateur).user }
|
let(:user) { create(:administrateur).user }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
feature 'Signing up:' do
|
feature 'Signing up:' do
|
||||||
let(:user_email) { generate :user_email }
|
let(:user_email) { generate :user_email }
|
||||||
let(:user_password) { 'démarches-simplifiées-pwd' }
|
let(:user_password) { 'démarches-simplifiées-pwd' }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe CommentaireHelper, type: :helper do
|
RSpec.describe CommentaireHelper, type: :helper do
|
||||||
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }
|
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe ConservationDeDonneesHelper, type: :helper do
|
RSpec.describe ConservationDeDonneesHelper, type: :helper do
|
||||||
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds, duree_conservation_dossiers_hors_ds: hors_ds) }
|
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds, duree_conservation_dossiers_hors_ds: hors_ds) }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DossierHelper, type: :helper do
|
RSpec.describe DossierHelper, type: :helper do
|
||||||
describe ".highlight_if_unseen_class" do
|
describe ".highlight_if_unseen_class" do
|
||||||
let(:seen_at) { Time.zone.now }
|
let(:seen_at) { Time.zone.now }
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
require 'rails_helper'
|
RSpec.describe AdministrateurActivateBeforeExpirationJob, type: :job do
|
||||||
|
|
||||||
RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
|
|
||||||
describe 'perform' do
|
describe 'perform' do
|
||||||
let(:administrateur) { create(:administrateur) }
|
let(:administrateur) { create(:administrateur) }
|
||||||
let(:user) { administrateur.user }
|
let(:user) { administrateur.user }
|
||||||
let(:mailer_double) { double('mailer', deliver_later: true) }
|
let(:mailer_double) { double('mailer', deliver_later: true) }
|
||||||
|
|
||||||
subject { Administrateurs::ActivateBeforeExpirationJob.perform_now }
|
subject { AdministrateurActivateBeforeExpirationJob.perform_now }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(Time.zone.local(2018, 03, 20))
|
Timecop.freeze(Time.zone.local(2018, 03, 20))
|
|
@ -1,4 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
RSpec.describe ApplicationJob, type: :job do
|
RSpec.describe ApplicationJob, type: :job do
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe AutoArchiveProcedureJob, type: :job do
|
RSpec.describe AutoArchiveProcedureJob, type: :job do
|
||||||
let!(:procedure) { create(:procedure, :published, :with_instructeur, auto_archive_on: nil) }
|
let!(:procedure) { create(:procedure, :published, :with_instructeur, auto_archive_on: nil) }
|
||||||
let!(:procedure_hier) { create(:procedure, :published, :with_instructeur, auto_archive_on: 1.day.ago.to_date) }
|
let!(:procedure_hier) { create(:procedure, :published, :with_instructeur, auto_archive_on: 1.day.ago.to_date) }
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do
|
|
||||||
describe "perform" do
|
|
||||||
let(:date) { Time.utc(2017, 9, 1, 10, 5, 0) }
|
|
||||||
let(:instruction_date) { date + 120 }
|
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published, :with_instructeur) }
|
|
||||||
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
|
|
||||||
Timecop.freeze(date)
|
|
||||||
dossiers = [
|
|
||||||
nouveau_dossier1,
|
|
||||||
nouveau_dossier2,
|
|
||||||
dossier_recu,
|
|
||||||
dossier_brouillon
|
|
||||||
]
|
|
||||||
|
|
||||||
create(:attestation_template, procedure: procedure)
|
|
||||||
AutoReceiveDossiersForProcedureJob.new.perform(procedure.id, state)
|
|
||||||
|
|
||||||
dossiers.each(&:reload)
|
|
||||||
end
|
|
||||||
|
|
||||||
after { Timecop.return }
|
|
||||||
|
|
||||||
context "with some dossiers" do
|
|
||||||
context "en_construction" do
|
|
||||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
|
||||||
let(:last_operation) { nouveau_dossier1.dossier_operation_logs.last }
|
|
||||||
|
|
||||||
it {
|
|
||||||
expect(nouveau_dossier1.en_instruction?).to be true
|
|
||||||
expect(nouveau_dossier1.en_instruction_at).to eq(date)
|
|
||||||
expect(last_operation.operation).to eq('passer_en_instruction')
|
|
||||||
expect(last_operation.automatic_operation?).to be_truthy
|
|
||||||
|
|
||||||
expect(nouveau_dossier2.en_instruction?).to be true
|
|
||||||
expect(nouveau_dossier2.en_instruction_at).to eq(date)
|
|
||||||
|
|
||||||
expect(dossier_recu.en_instruction?).to be true
|
|
||||||
expect(dossier_recu.en_instruction_at).to eq(instruction_date)
|
|
||||||
|
|
||||||
expect(dossier_brouillon.brouillon?).to be true
|
|
||||||
expect(dossier_brouillon.en_instruction_at).to eq(nil)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context "accepte" do
|
|
||||||
let(:state) { Dossier.states.fetch(:accepte) }
|
|
||||||
let(:last_operation) { nouveau_dossier1.dossier_operation_logs.last }
|
|
||||||
|
|
||||||
it {
|
|
||||||
expect(nouveau_dossier1.accepte?).to be true
|
|
||||||
expect(nouveau_dossier1.en_instruction_at).to eq(date)
|
|
||||||
expect(nouveau_dossier1.processed_at).to eq(date)
|
|
||||||
expect(nouveau_dossier1.attestation).to be_present
|
|
||||||
expect(last_operation.operation).to eq('accepter')
|
|
||||||
expect(last_operation.automatic_operation?).to be_truthy
|
|
||||||
|
|
||||||
expect(nouveau_dossier2.accepte?).to be true
|
|
||||||
expect(nouveau_dossier2.en_instruction_at).to eq(date)
|
|
||||||
expect(nouveau_dossier2.processed_at).to eq(date)
|
|
||||||
expect(nouveau_dossier2.attestation).to be_present
|
|
||||||
|
|
||||||
expect(dossier_recu.en_instruction?).to be true
|
|
||||||
expect(dossier_recu.en_instruction_at).to eq(instruction_date)
|
|
||||||
expect(dossier_recu.processed_at).to eq(nil)
|
|
||||||
|
|
||||||
expect(dossier_brouillon.brouillon?).to be true
|
|
||||||
expect(dossier_brouillon.en_instruction_at).to eq(nil)
|
|
||||||
expect(dossier_brouillon.processed_at).to eq(nil)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DeclarativeProceduresJob, type: :job do
|
RSpec.describe DeclarativeProceduresJob, type: :job do
|
||||||
describe "perform" do
|
describe "perform" do
|
||||||
let(:date) { Time.utc(2017, 9, 1, 10, 5, 0) }
|
let(:date) { Time.utc(2017, 9, 1, 10, 5, 0) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe FindDubiousProceduresJob, type: :job do
|
RSpec.describe FindDubiousProceduresJob, type: :job do
|
||||||
describe 'perform' do
|
describe 'perform' do
|
||||||
let(:mailer_double) { double('mailer', deliver_later: true) }
|
let(:mailer_double) { double('mailer', deliver_later: true) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe WeeklyOverviewJob, type: :job do
|
RSpec.describe WeeklyOverviewJob, type: :job do
|
||||||
describe 'perform' do
|
describe 'perform' do
|
||||||
let!(:instructeur) { create(:instructeur) }
|
let!(:instructeur) { create(:instructeur) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ApiCarto::API do
|
describe ApiCarto::API do
|
||||||
describe '.search_qp' do
|
describe '.search_qp' do
|
||||||
subject { described_class.search_qp(geojson) }
|
subject { described_class.search_qp(geojson) }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ApiCarto::CadastreAdapter do
|
describe ApiCarto::CadastreAdapter do
|
||||||
subject { described_class.new(coordinates).results }
|
subject { described_class.new(coordinates).results }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ApiCarto::QuartiersPrioritairesAdapter do
|
describe ApiCarto::QuartiersPrioritairesAdapter do
|
||||||
subject { described_class.new(coordinates).results }
|
subject { described_class.new(coordinates).results }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ApiEntreprise::API do
|
describe ApiEntreprise::API do
|
||||||
let(:procedure_id) { 12 }
|
let(:procedure_id) { 12 }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ApiEntreprise::EntrepriseAdapter do
|
describe ApiEntreprise::EntrepriseAdapter do
|
||||||
let(:siren) { '418166096' }
|
let(:siren) { '418166096' }
|
||||||
let(:procedure_id) { 22 }
|
let(:procedure_id) { 22 }
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue