update jobs specs to use revisions
This commit is contained in:
parent
6a33a8e48b
commit
d1e0b65658
2 changed files with 6 additions and 29 deletions
|
@ -1,23 +1,24 @@
|
|||
RSpec.describe FindDubiousProceduresJob, type: :job do
|
||||
describe 'perform' do
|
||||
let(:mailer_double) { double('mailer', deliver_later: true) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:allowed_tdc) { create(:type_de_champ, libelle: 'fournir') }
|
||||
let(:procedure) { create(:procedure, types_de_champ: tdcs) }
|
||||
let(:allowed_tdc) { build(:type_de_champ, libelle: 'fournir') }
|
||||
|
||||
before do
|
||||
procedure
|
||||
|
||||
allow(AdministrationMailer).to receive(:dubious_procedures) do |arg|
|
||||
@dubious_procedures_args = arg
|
||||
end.and_return(mailer_double)
|
||||
|
||||
procedure.types_de_champ << tdcs
|
||||
FindDubiousProceduresJob.new.perform
|
||||
end
|
||||
|
||||
context 'with suspicious champs' do
|
||||
let(:forbidden_tdcs) do
|
||||
[
|
||||
create(:type_de_champ, libelle: 'num de securite sociale, stp'),
|
||||
create(:type_de_champ, libelle: "t'aurais une carte bancaire ?")
|
||||
build(:type_de_champ, libelle: 'num de securite sociale, stp'),
|
||||
build(:type_de_champ, libelle: "t'aurais une carte bancaire ?")
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
RSpec.describe TmpDossiersMigrateRevisionsJob, type: :job do
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
let!(:dossier1) { create(:dossier, procedure: procedure, updated_at: 1.day.ago) }
|
||||
let!(:dossier2) { create(:dossier, procedure: procedure, updated_at: 2.days.ago) }
|
||||
|
||||
context "add revision to dossiers" do
|
||||
before do
|
||||
RevisionsMigration.add_revisions(procedure)
|
||||
end
|
||||
|
||||
it {
|
||||
expect(dossier1.revision).to be_nil
|
||||
expect(dossier2.revision).to be_nil
|
||||
|
||||
TmpDossiersMigrateRevisionsJob.new.perform([])
|
||||
[dossier1, dossier2].each(&:reload)
|
||||
|
||||
expect(dossier1.revision).to eq procedure.active_revision
|
||||
expect(dossier2.revision).to eq procedure.active_revision
|
||||
expect(dossier1.updated_at < 1.day.ago).to be_truthy
|
||||
expect(dossier2.updated_at < 1.day.ago).to be_truthy
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue