demarches-normaliennes/spec/factories/targeted_user_links.rb

18 lines
494 B
Ruby
Raw Normal View History

FactoryBot.define do
factory :targeted_user_link do
target_context { TargetedUserLink.target_contexts[:avis] }
target_model { create(:avis) }
transient do
user {}
end
after(:build) do |targeted_user_link|
case targeted_user_link.target_context
when 'avis'
targeted_user_link.user = targeted_user_link.target_model.expert.user
when 'invite'
targeted_user_link.user = targeted_user_link.target_model&.user
end
end
end
end