correctif(dossier_transfer): le transfer de dossier vers un email contenant des majuscule ne fonctionnait pas
This commit is contained in:
parent
472759f688
commit
88553eec9b
3 changed files with 9 additions and 5 deletions
|
@ -26,11 +26,7 @@ module Users
|
|||
@dossiers_invites = current_user.dossiers_invites.merge(dossiers_visibles)
|
||||
@dossiers_supprimes_recemment = current_user.dossiers.hidden_by_user.merge(dossiers)
|
||||
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.order_by_updated_at.page(page)
|
||||
@dossier_transfers = DossierTransfer
|
||||
.includes(dossiers: :user)
|
||||
.with_dossiers
|
||||
.where(email: current_user.email)
|
||||
.page(page)
|
||||
@dossier_transfers = DossierTransfer.for_email(current_user.email).page(page)
|
||||
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
|
||||
end
|
||||
|
||||
|
|
|
@ -8,15 +8,18 @@
|
|||
# updated_at :datetime not null
|
||||
#
|
||||
class DossierTransfer < ApplicationRecord
|
||||
include EmailSanitizableConcern
|
||||
has_many :dossiers, dependent: :nullify
|
||||
|
||||
EXPIRATION_LIMIT = 2.weeks
|
||||
|
||||
validates :email, format: { with: Devise.email_regexp }
|
||||
before_validation -> { sanitize_email(:email) }
|
||||
|
||||
scope :pending, -> { where('created_at > ?', (Time.zone.now - EXPIRATION_LIMIT)) }
|
||||
scope :stale, -> { where('created_at < ?', (Time.zone.now - EXPIRATION_LIMIT)) }
|
||||
scope :with_dossiers, -> { joins(:dossiers).merge(Dossier.visible_by_user) }
|
||||
scope :for_email, -> (email) { includes(dossiers: :user).with_dossiers.where(email: email) }
|
||||
|
||||
after_create_commit :send_notification
|
||||
|
||||
|
|
|
@ -26,6 +26,11 @@ describe Users::TransfersController, type: :controller do
|
|||
it { expect(DossierTransfer.last.dossiers).to eq([dossier]) }
|
||||
end
|
||||
|
||||
context 'with upper case email' do
|
||||
let(:email) { "Test@rspec.net" }
|
||||
it { expect(DossierTransfer.last.email).to eq(email.strip.downcase) }
|
||||
end
|
||||
|
||||
shared_examples 'email error' do
|
||||
it { expect { subject }.not_to change { DossierTransfer.count } }
|
||||
it { expect(flash.alert).to match([/invalide/]) }
|
||||
|
|
Loading…
Reference in a new issue