Merge branch 'main' into feature/prefill_repetible
This commit is contained in:
commit
4a07fd6223
5 changed files with 13 additions and 2 deletions
|
@ -28,7 +28,7 @@ class Avis < ApplicationRecord
|
||||||
has_one :expert, through: :experts_procedure
|
has_one :expert, through: :experts_procedure
|
||||||
has_one :procedure, through: :experts_procedure
|
has_one :procedure, through: :experts_procedure
|
||||||
|
|
||||||
has_many :targeted_user_links, dependent: :destroy, inverse_of: :target_model, foreign_key: 'target_model_id'
|
has_many :targeted_user_links, as: :target_model, dependent: :destroy, inverse_of: :target_model
|
||||||
|
|
||||||
FILE_MAX_SIZE = 20.megabytes
|
FILE_MAX_SIZE = 20.megabytes
|
||||||
validates :piece_justificative_file,
|
validates :piece_justificative_file,
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Invite < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :dossier, optional: false
|
belongs_to :dossier, optional: false
|
||||||
belongs_to :user, optional: true
|
belongs_to :user, optional: true
|
||||||
has_one :targeted_user_link, dependent: :destroy, inverse_of: :target_model, foreign_key: 'target_model_id'
|
has_one :targeted_user_link, as: :target_model, dependent: :destroy, inverse_of: :target_model
|
||||||
|
|
||||||
before_validation -> { sanitize_email(:email) }
|
before_validation -> { sanitize_email(:email) }
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,7 @@ ActiveRecord::Schema.define(version: 2023_01_26_145329) do
|
||||||
t.string "email"
|
t.string "email"
|
||||||
t.bigint "experts_procedure_id"
|
t.bigint "experts_procedure_id"
|
||||||
t.text "introduction"
|
t.text "introduction"
|
||||||
|
t.datetime "reminded_at"
|
||||||
t.datetime "revoked_at"
|
t.datetime "revoked_at"
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.datetime "reminded_at"
|
t.datetime "reminded_at"
|
||||||
|
|
|
@ -51,6 +51,15 @@ RSpec.describe InviteMailer, type: :mailer do
|
||||||
.from(0).to(1)
|
.from(0).to(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when an avis exists with same id' do
|
||||||
|
it 'associate the TargetedUserLink to the good model [does not search by id only]' do
|
||||||
|
avis = create(:avis, id: invite.id)
|
||||||
|
link_on_avis_with_same_id = create(:targeted_user_link, target_model: avis, target_context: TargetedUserLink.target_contexts[:avis])
|
||||||
|
deliver
|
||||||
|
expect(invite.targeted_user_link).not_to eq(link_on_avis_with_same_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when it fails' do
|
context 'when it fails' do
|
||||||
it 'creates only one target_user_link' do
|
it 'creates only one target_user_link' do
|
||||||
send_mail_values = [:raise, true]
|
send_mail_values = [:raise, true]
|
||||||
|
|
|
@ -61,6 +61,7 @@ describe 'Invitations' do
|
||||||
|
|
||||||
invitation_email = open_email(user.email)
|
invitation_email = open_email(user.email)
|
||||||
targeted_user_link = TargetedUserLink.last
|
targeted_user_link = TargetedUserLink.last
|
||||||
|
expect(targeted_user_link.user.email).to eq(user.email)
|
||||||
expect(invitation_email).to have_link(targeted_user_link_url(targeted_user_link))
|
expect(invitation_email).to have_link(targeted_user_link_url(targeted_user_link))
|
||||||
invitation_email.click_on targeted_user_link_url(targeted_user_link)
|
invitation_email.click_on targeted_user_link_url(targeted_user_link)
|
||||||
expect(page).to have_current_path("/users/sign_in")
|
expect(page).to have_current_path("/users/sign_in")
|
||||||
|
|
Loading…
Reference in a new issue