Merge branch 'dev'
This commit is contained in:
commit
eadafa9c22
4 changed files with 33 additions and 0 deletions
|
@ -10,4 +10,11 @@ class Invite < ApplicationRecord
|
||||||
validates :email, uniqueness: { scope: :dossier_id }
|
validates :email, uniqueness: { scope: :dossier_id }
|
||||||
|
|
||||||
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
|
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
|
||||||
|
|
||||||
|
# #1619 When an administrateur deletes a `Procedure`, its `hidden_at` field, and
|
||||||
|
# the `hidden_at` field of its `Dossier`s, get set, effectively removing the Procedure
|
||||||
|
# and Dossier from their respective `default_scope`s.
|
||||||
|
# Therefore, we also remove `Invite`s for such effectively deleted `Dossier`s
|
||||||
|
# from their default scope.
|
||||||
|
default_scope { joins(:dossier).where(dossiers: { hidden_at: nil }) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
- pj = champ.piece_justificative_file
|
- pj = champ.piece_justificative_file
|
||||||
%a{ href: url_for(pj), target: '_blank' }
|
%a{ href: url_for(pj), target: '_blank' }
|
||||||
= pj.filename.to_s
|
= pj.filename.to_s
|
||||||
|
- elsif champ.type_champ == 'textarea'
|
||||||
|
= simple_format(champ.decorate.value)
|
||||||
- else
|
- else
|
||||||
= sanitize(champ.decorate.value)
|
= sanitize(champ.decorate.value)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@
|
||||||
= pj.filename.to_s
|
= pj.filename.to_s
|
||||||
- else
|
- else
|
||||||
Pièce justificative non fournie
|
Pièce justificative non fournie
|
||||||
|
- when "textarea"
|
||||||
|
%th.libelle
|
||||||
|
= "#{c.libelle} :"
|
||||||
|
%td.rich-text
|
||||||
|
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||||
|
= simple_format(c.value)
|
||||||
- else
|
- else
|
||||||
%th.libelle
|
%th.libelle
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
|
|
|
@ -56,4 +56,22 @@ describe Invite do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#default_scope" do
|
||||||
|
let(:dossier) { create(:dossier, hidden_at: hidden_at) }
|
||||||
|
let!(:invite) { create(:invite, email: "email@totor.com", dossier: dossier) }
|
||||||
|
|
||||||
|
context "when dossier is not hidden" do
|
||||||
|
let(:hidden_at) { nil }
|
||||||
|
|
||||||
|
it { expect(Invite.count).to eq(1) }
|
||||||
|
it { expect(Invite.all).to include(invite) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when dossier is hidden" do
|
||||||
|
let(:hidden_at) { 1.day.ago }
|
||||||
|
|
||||||
|
it { expect(Invite.count).to eq(0) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue