2018-05-08 10:10:19 +00:00
|
|
|
FactoryBot.define do
|
|
|
|
factory :recent_view do
|
2018-09-10 12:38:33 +00:00
|
|
|
transient do
|
2019-02-10 12:24:22 +00:00
|
|
|
o { Ticket.first }
|
2018-09-10 12:38:33 +00:00
|
|
|
user_role { :agent }
|
|
|
|
end
|
|
|
|
|
2019-02-10 12:24:22 +00:00
|
|
|
recent_view_object_id { ObjectLookup.by_name(o.class.name) }
|
|
|
|
o_id { o.id }
|
2018-09-10 12:38:33 +00:00
|
|
|
|
|
|
|
# assign to an existing user, if possible
|
|
|
|
created_by_id do
|
|
|
|
User.find { |u| u.role?(user_role.capitalize) }&.id ||
|
2020-06-19 09:17:18 +00:00
|
|
|
create(user_role).id
|
2018-09-10 12:38:33 +00:00
|
|
|
end
|
2018-05-08 10:10:19 +00:00
|
|
|
end
|
|
|
|
end
|