Merge pull request #4967 from betagouv/dev

2020-03-31-01
This commit is contained in:
Pierre de La Morinerie 2020-03-31 13:15:35 +02:00 committed by GitHub
commit 43b2393059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
193 changed files with 396 additions and 673 deletions

2
.rspec
View file

@ -1,2 +1,2 @@
--color
--require spec_helper
--require rails_helper

View file

@ -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))
### Programmation des jobs
### Programmation des tâches récurrentes
AutoArchiveProcedureJob.set(cron: "* * * * *").perform_later
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
rails jobs:schedule
### Voir les emails envoyés en local

View file

@ -123,7 +123,7 @@
.champs-editor {
.footer {
margin-bottom: 50px;
height: 50px;
}
.buttons {

View file

@ -62,7 +62,6 @@ export function ajax(options) {
}
export function getJSON(url, data, method = 'get') {
incrementActiveRequestsCount();
data = method !== 'get' ? JSON.stringify(data) : data;
return Promise.resolve(
$.ajax({
@ -72,7 +71,7 @@ export function getJSON(url, data, method = 'get') {
contentType: 'application/json',
dataType: 'json'
})
).finally(decrementActiveRequestsCount);
);
}
export function scrollTo(container, scrollTo) {
@ -115,15 +114,3 @@ export function timeoutable(promise, timeoutDelay) {
});
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);
}

View file

@ -1,5 +1,5 @@
class Administrateurs::ActivateBeforeExpirationJob < ApplicationJob
queue_as :cron
class AdministrateurActivateBeforeExpirationJob < CronJob
self.cron_expression = "0 8 * * *"
def perform(*args)
Administrateur

View file

@ -1,5 +1,5 @@
class AutoArchiveProcedureJob < ApplicationJob
queue_as :cron
class AutoArchiveProcedureJob < CronJob
self.cron_expression = "* * * * *"
def perform(*args)
Procedure.publiees.where("auto_archive_on <= ?", Time.zone.today).each do |procedure|

View file

@ -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
View 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

View file

@ -1,5 +1,5 @@
class DeclarativeProceduresJob < ApplicationJob
queue_as :cron
class DeclarativeProceduresJob < CronJob
self.cron_expression = "* * * * *"
def perform(*args)
Procedure.declarative.find_each(&:process_dossiers!)

View file

@ -1,5 +1,5 @@
class DiscardedDossiersDeletionJob < ApplicationJob
queue_as :cron
class DiscardedDossiersDeletionJob < CronJob
self.cron_expression = "0 7 * * *"
def perform(*args)
Dossier.discarded_brouillon_expired.destroy_all

View file

@ -1,6 +1,4 @@
class EtablissementUpdateJob < ApplicationJob
queue_as :default
def perform(dossier, siret)
begin
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure_id)

View file

@ -1,5 +1,5 @@
class ExpiredDossiersDeletionJob < ApplicationJob
queue_as :cron
class ExpiredDossiersDeletionJob < CronJob
self.cron_expression = "0 7 * * *"
def perform(*args)
ExpiredDossiersDeletionService.process_expired_dossiers_brouillon

View file

@ -1,5 +1,5 @@
class FindDubiousProceduresJob < ApplicationJob
queue_as :cron
class FindDubiousProceduresJob < CronJob
self.cron_expression = "0 0 * * *"
FORBIDDEN_KEYWORDS = [
'NIR', 'NIRPP', 'race', 'religion',

View file

@ -1,5 +1,5 @@
class InstructeurEmailNotificationJob < ApplicationJob
queue_as :cron
class InstructeurEmailNotificationJob < CronJob
self.cron_expression = "0 10 * * MON-FRI"
def perform(*args)
NotificationService.send_instructeur_email_notification

View file

@ -1,5 +1,5 @@
class NotifyDraftNotSubmittedJob < ApplicationJob
queue_as :cron
class NotifyDraftNotSubmittedJob < CronJob
self.cron_expression = "0 7 * * *"
def perform(*args)
Dossier.notify_draft_not_submitted

View file

@ -1,5 +1,5 @@
class OperationsSignatureJob < ApplicationJob
queue_as :cron
class OperationsSignatureJob < CronJob
self.cron_expression = "0 6 * * *"
def perform(*args)
last_midnight = Time.zone.today.beginning_of_day

View file

@ -1,5 +1,5 @@
class PurgeStaleExportsJob < ApplicationJob
queue_as :cron
class PurgeStaleExportsJob < CronJob
self.cron_expression = "*/5 * * * *"
def perform
Export.stale.destroy_all

View file

@ -1,5 +1,5 @@
class PurgeUnattachedBlobsJob < ApplicationJob
queue_as :cron
class PurgeUnattachedBlobsJob < CronJob
self.cron_expression = "0 0 * * *"
def perform(*args)
ActiveStorage::Blob.unattached

View file

@ -1,5 +1,5 @@
class UpdateAdministrateurUsageStatisticsJob < ApplicationJob
queue_as :cron
class UpdateAdministrateurUsageStatisticsJob < CronJob
self.cron_expression = "0 10 * * *"
def perform
AdministrateurUsageStatisticsService.new.update_administrateurs

View file

@ -1,5 +1,5 @@
class WarnExpiringDossiersJob < ApplicationJob
queue_as :cron
class WarnExpiringDossiersJob < CronJob
self.cron_expression = "0 0 1 * *"
def perform(*args)
expiring, expired = Dossier

View file

@ -1,6 +1,4 @@
class WebHookJob < ApplicationJob
queue_as :default
TIMEOUT = 10
def perform(procedure, dossier)

View file

@ -1,5 +1,5 @@
class WeeklyOverviewJob < ApplicationJob
queue_as :cron
class WeeklyOverviewJob < CronJob
self.cron_expression = "0 7 * * MON"
def perform(*args)
# Feature flipped to avoid mails in staging due to unprocessed dossier

View file

@ -1,7 +1,8 @@
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/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
@ -16,6 +17,13 @@ class Champs::PieceJustificativeChamp < Champ
"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
:piece_justificative_file
end
@ -28,28 +36,6 @@ class Champs::PieceJustificativeChamp < Champ
mandatory? && !piece_justificative_file.attached?
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
if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?)
piece_justificative_file.service_url

View file

@ -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
if logo.present?
logo_file = if logo.is_a?(ActiveStorage::Attached::One)
logo_content = if logo.is_a?(ActiveStorage::Attached::One)
logo.download
else
logo.read
logo.rewind && logo.read
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
pdf.fill_color grey
@ -57,12 +57,12 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p
if signature.present?
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
else
signature.read
signature.rewind && signature.read
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

View file

@ -64,6 +64,16 @@ namespace :after_party do
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
desc "Restart puma"
task :restart_puma do
@ -123,4 +133,5 @@ task :post_deploy do
command 'cd /home/ds/current'
invoke :'after_party:run'
invoke :'jobs_schedule:run'
end

View file

@ -0,0 +1,4 @@
fr:
errors:
messages:
content_type_invalid: nest pas dun type accepté

View file

@ -3,3 +3,4 @@ fr:
attributes:
champ:
value: La valeur du champ
piece_justificative_file: La pièce justificative

8
lib/tasks/jobs.rake Normal file
View 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

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Admin::AssignsController, type: :controller do
let(:admin) { create(:administrateur) }

View file

@ -1,4 +1,5 @@
include ActionDispatch::TestProcess
describe Admin::AttestationTemplatesController, type: :controller do
let!(:attestation_template) { create(:attestation_template) }
let(:admin) { create(:administrateur) }
@ -17,6 +18,14 @@ describe Admin::AttestationTemplatesController, type: :controller do
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
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
let(:attestation_template) { nil }
it { expect(subject.status).to eq(200) }
it { expect(assigns(:attestation)).to include(upload_params) }
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_behaves_like 'rendering a PDF successfully'
end
end
context 'if an attestation template exists on the procedure' do
after { procedure.attestation_template.destroy }
context 'with logos' do
context 'with images' do
let!(:attestation_template) do
create(:attestation_template, logo: logo, signature: signature)
end
it { expect(subject.status).to eq(200) }
it { expect(assigns(:attestation)).to include(upload_params) }
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)[:signature].download).to eq(signature2.read) }
it_behaves_like 'rendering a PDF successfully'
end
context 'with empty logo' do
it { expect(subject.status).to eq(200) }
context 'without images' do
it { expect(assigns(:attestation)).to include(upload_params) }
it { expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now) }
it { expect(assigns(:attestation)[:logo]).to eq(nil) }
it { expect(assigns(:attestation)[:signature]).to eq(nil) }
it_behaves_like 'rendering a PDF successfully'
end
end
end

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Admin::InstructeursController, type: :controller do
let(:admin) { create(:administrateur) }
let(:email_2) { 'plip@octo.com' }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Admin::MailTemplatesController, type: :controller do
let(:procedure) { create :procedure }
let(:initiated_mail) { Mails::InitiatedMail.default_for_procedure(procedure) }

View file

@ -1,4 +1,3 @@
require 'spec_helper'
require 'uri'
describe Admin::ProceduresController, type: :controller do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Administrations::OmniauthCallbacksController, type: :controller do
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:administration]

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe API::V1::DossiersController do
let(:admin) { create(:administrateur) }
let(:token) { admin.renew_api_token }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe API::V2::GraphqlController do
let(:admin) { create(:administrateur) }
let(:token) { admin.renew_api_token }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe APIController, type: :controller do
describe 'valid_token_for_procedure?' do
let(:procedure) { create(:procedure) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe ApplicationController, type: :controller do
describe 'before_action: set_raven_context' do
it 'is present' do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe AttachmentsController, type: :controller do
let(:user) { create(:user) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Champs::CarteController, type: :controller do
let(:user) { create(:user) }
let(:procedure) { create(:procedure, :published) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Champs::DossierLinkController, type: :controller do
let(:user) { create(:user) }
let(:procedure) { create(:procedure, :published) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Champs::SiretController, type: :controller do
let(:user) { create(:user) }
let(:procedure) { create(:procedure, :published) }

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe ProcedureContextConcern, type: :controller do
class TestController < ActionController::Base
include ProcedureContextConcern

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe Devise::StoreLocationExtension, type: :controller do
class TestController < ActionController::Base
include Devise::Controllers::StoreLocation

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Instructeurs::AvisController, type: :controller do
context 'with a instructeur signed in' do
render_views

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Instructeurs::DossiersController, type: :controller do
render_views

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Instructeurs::InstructeurController, type: :controller do
describe 'before actions: authenticate_instructeur!' do
it 'is present' do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Instructeurs::ProceduresController, type: :controller do
describe "before_action: ensure_ownership!" do
it "is present" do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Instructeurs::RechercheController, type: :controller do
let(:dossier) { create(:dossier, :en_construction) }
let(:dossier2) { create(:dossier, :en_construction, procedure: dossier.procedure) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe InvitesController, type: :controller do
let(:dossier) { create(:dossier, :en_construction) }
let(:email) { 'plop@octo.com' }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe PingController, type: :controller do
describe 'GET #index' do
subject { get :index }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe RootController, type: :controller do
subject { get :index }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe StatsController, type: :controller do
describe "#last_four_months_hash" do
context "while a regular user is logged in" do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe SupportController, type: :controller do
render_views

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Users::CommencerController, type: :controller do
let(:user) { create(:user) }
let(:published_procedure) { create(:procedure, :published) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Users::ConfirmationsController, type: :controller do
let!(:user) { create(:user, :unconfirmed) }
let(:confirmation_token) { user.confirmation_token }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Users::DossiersController, type: :controller do
let(:user) { create(:user) }

View file

@ -1,5 +1,3 @@
require "spec_helper"
describe Users::PasswordsController, type: :controller do
before do
@request.env["devise.mapping"] = Devise.mappings[:user]

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Users::ProfilController, type: :controller do
include ActiveJob::TestHelper

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe Users::UserController, type: :controller do
describe 'before actions: authenticate_instructeur!' do
it 'is present' do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe WebhookController, type: :controller do
describe '#helpscout' do
before { allow(controller).to receive(:verify_signature!).and_return(true) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'As an administrateur', js: true do
let(:administration) { create(:administration) }
let(:admin_email) { 'new_admin@gouv.fr' }

View file

@ -1,4 +1,3 @@
require 'spec_helper'
require 'features/admin/procedure_spec_helper'
feature 'As an administrateur I wanna clone a procedure', js: true do

View file

@ -1,4 +1,3 @@
require 'spec_helper'
require 'features/admin/procedure_spec_helper'
feature 'As an administrateur I wanna create a new procedure', js: true do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'procedure locked' do
let(:administrateur) { create(:administrateur) }

View file

@ -1,4 +1,3 @@
require 'spec_helper'
require 'features/admin/procedure_spec_helper'
feature 'Administrateurs can edit procedures', js: true do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'France Connect Particulier Connexion' do
let(:code) { 'plop' }
let(:given_name) { 'titi' }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Getting help:' do
scenario 'a Help button is visible on public pages' do
visit '/'

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Inviting an expert:' do
include ActiveJob::TestHelper
include ActionView::Helpers

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'As an instructeur', js: true do
let(:administrateur) { create(:administrateur, :with_procedure) }
let(:procedure) { administrateur.procedures.first }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Instructing a dossier:' do
include ActiveJob::TestHelper

View file

@ -1,5 +1,3 @@
require "spec_helper"
feature "procedure filters" do
let(:instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure, :published, :with_type_de_champ, instructeurs: [instructeur]) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'As an administrateur I can edit types de champ', js: true do
let(:administrateur) { procedure.administrateurs.first }
let(:procedure) { create(:procedure) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Outdated browsers support:' do
context 'when the user browser is outdated' do
before(:each) do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'The routing', js: true do
let(:password) { 'a very complicated password' }
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Signin in:' do
let!(:user) { create(:user, password: password) }
let(:password) { 'démarches-simplifiées-pwd' }

View file

@ -1,5 +1,3 @@
require 'rails_helper'
feature 'The user' do
let(:password) { 'démarches-simplifiées-pwd' }
let!(:user) { create(:user, password: password) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Changing an email' do
let(:old_email) { 'old@email.com' }
let(:user) { create(:user, email: old_email) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Creating a new dossier:' do
let(:user) { create(:user) }
let(:siret) { '40307130100044' }

View file

@ -1,4 +1,3 @@
require 'spec_helper'
require 'features/users/dossier_shared_examples.rb'
feature 'Invitations' do

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'linked dropdown lists' do
let(:password) { 'démarches-simplifiées-pwd' }
let!(:user) { create(:user, password: password) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe 'user access to the list of their dossiers' do
let(:user) { create(:user) }
let!(:dossier_brouillon) { create(:dossier, user: user) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Managing password:' do
context 'for simple users' do
let(:user) { create(:user) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Sign out' do
context 'when a user is logged in' do
let(:user) { create(:administrateur).user }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
feature 'Signing up:' do
let(:user_email) { generate :user_email }
let(:user_password) { 'démarches-simplifiées-pwd' }

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe CommentaireHelper, type: :helper do
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe ConservationDeDonneesHelper, type: :helper do
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds, duree_conservation_dossiers_hors_ds: hors_ds) }

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe DossierHelper, type: :helper do
describe ".highlight_if_unseen_class" do
let(:seen_at) { Time.zone.now }

View file

@ -1,12 +1,10 @@
require 'rails_helper'
RSpec.describe Administrateurs::ActivateBeforeExpirationJob, type: :job do
RSpec.describe AdministrateurActivateBeforeExpirationJob, type: :job do
describe 'perform' do
let(:administrateur) { create(:administrateur) }
let(:user) { administrateur.user }
let(:mailer_double) { double('mailer', deliver_later: true) }
subject { Administrateurs::ActivateBeforeExpirationJob.perform_now }
subject { AdministrateurActivateBeforeExpirationJob.perform_now }
before do
Timecop.freeze(Time.zone.local(2018, 03, 20))

View file

@ -1,4 +1,3 @@
require 'rails_helper'
include ActiveJob::TestHelper
RSpec.describe ApplicationJob, type: :job do

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe AutoArchiveProcedureJob, type: :job do
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) }

View file

@ -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

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe DeclarativeProceduresJob, type: :job do
describe "perform" do
let(:date) { Time.utc(2017, 9, 1, 10, 5, 0) }

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe FindDubiousProceduresJob, type: :job do
describe 'perform' do
let(:mailer_double) { double('mailer', deliver_later: true) }

View file

@ -1,5 +1,3 @@
require 'rails_helper'
RSpec.describe WeeklyOverviewJob, type: :job do
describe 'perform' do
let!(:instructeur) { create(:instructeur) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe ApiCarto::API do
describe '.search_qp' do
subject { described_class.search_qp(geojson) }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe ApiCarto::CadastreAdapter do
subject { described_class.new(coordinates).results }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe ApiCarto::QuartiersPrioritairesAdapter do
subject { described_class.new(coordinates).results }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe ApiEntreprise::API do
let(:procedure_id) { 12 }

View file

@ -1,5 +1,3 @@
require 'spec_helper'
describe ApiEntreprise::EntrepriseAdapter do
let(:siren) { '418166096' }
let(:procedure_id) { 22 }

Some files were not shown because too many files have changed in this diff Show more