add template_accesses factory

This commit is contained in:
Alex Turchyn
2025-05-19 13:09:29 +03:00
committed by Pete Matsyburka
parent 0fb9c2bbf6
commit 23631b75f2
2 changed files with 21 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
# frozen_string_literal: true
FactoryBot.define do
factory :template_access do
template
user
end
end
+13
View File
@@ -14,6 +14,7 @@ FactoryBot.define do
%w[text date checkbox radio signature number multiple select initials image file stamp cells phone payment]
end
except_field_types { [] }
private_access_user { nil }
end
after(:create) do |template, ev|
@@ -343,5 +344,17 @@ FactoryBot.define do
template.save!
end
trait :with_admin_only_access do
after(:create) do |template|
create(:template_access, template:, user_id: TemplateAccess::ADMIN_USER_ID)
end
end
trait :with_private_access do
after(:create) do |template, ev|
create(:template_access, template:, user: ev.private_access_user || template.author)
end
end
end
end