diff options
Diffstat (limited to 'spec/factories/organizations.rb')
-rw-r--r-- | spec/factories/organizations.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb new file mode 100644 index 00000000000..7ff0493d140 --- /dev/null +++ b/spec/factories/organizations.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :organization do + sequence(:name) { |n| "Organization ##{n}" } + + trait :default do + id { Organization::DEFAULT_ORGANIZATION_ID } + name { 'Default' } + initialize_with do + # Ensure we only use one default organization + Organization.find_by(id: Organization::DEFAULT_ORGANIZATION_ID) || new(**attributes) + end + end + end +end |