recent_view.rb 392 B

1234567891011121314151617
  1. FactoryBot.define do
  2. factory :recent_view do
  3. transient do
  4. o { Ticket.first }
  5. user_role { :agent }
  6. end
  7. recent_view_object_id { ObjectLookup.by_name(o.class.name) }
  8. o_id { o.id }
  9. # assign to an existing user, if possible
  10. created_by_id do
  11. User.find { |u| u.role?(user_role.capitalize) }&.id ||
  12. create(user_role).id
  13. end
  14. end
  15. end