diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 62670188f..0626cccd1 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -3,7 +3,7 @@ FactoryBot.define do sequence(:email) { "test#{SecureRandom.hex}@example.com" } name { "Danny Rojas" } password { "pAssword1" } - organisation + organisation { association :organisation, with_dsa: is_dpo ? false : true } role { "data_provider" } phone { "1234512345123" } trait :data_provider do @@ -26,5 +26,15 @@ FactoryBot.define do transient do old_user_id { SecureRandom.uuid } end + + after(:create) do |user, _evaluator| + unless user.organisation.data_protection_confirmed? + create( + :data_protection_confirmation, + organisation: user.organisation, + data_protection_officer: user, + ) + end + end end end