recent_view.rb 469 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. FactoryBot.define do
  3. factory :recent_view do
  4. transient do
  5. o { Ticket.first }
  6. user_role { :agent }
  7. end
  8. recent_view_object_id { ObjectLookup.by_name(o.class.name) }
  9. o_id { o.id }
  10. # assign to an existing user, if possible
  11. created_by_id do
  12. User.find { |u| u.role?(user_role.capitalize) }&.id ||
  13. create(user_role).id
  14. end
  15. end
  16. end