Merge branch 'dev'

This commit is contained in:
Frederic Merizen 2018-03-15 13:39:22 +01:00
commit eadafa9c22
4 changed files with 33 additions and 0 deletions

View file

@ -10,4 +10,11 @@ class Invite < ApplicationRecord
validates :email, uniqueness: { scope: :dossier_id }
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

View file

@ -50,6 +50,8 @@
- pj = champ.piece_justificative_file
%a{ href: url_for(pj), target: '_blank' }
= pj.filename.to_s
- elsif champ.type_champ == 'textarea'
= simple_format(champ.decorate.value)
- else
= sanitize(champ.decorate.value)

View file

@ -40,6 +40,12 @@
= pj.filename.to_s
- else
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
%th.libelle
= "#{c.libelle} :"

View file

@ -56,4 +56,22 @@ describe Invite do
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