Sha256: e3de79adfde78d1160f95f097c39fabed26982c68017d31999f1c3ca60205809

Contents?: true

Size: 1.84 KB

Versions: 9

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

require "factory_bot"
require "securerandom"

FactoryBot.define do
  factory :meibo_role, class: "Meibo::Role" do
    initialize_with { new(**attributes) }

    transient do
      user { nil }
      organization { nil }
      user_profile { nil }
    end

    sourced_id { SecureRandom.uuid }
    user_sourced_id { user&.sourced_id }
    org_sourced_id { organization&.sourced_id }
    user_profile_sourced_id { user_profile&.sourced_id }

    trait :primary do
      role_type { Meibo::Role::TYPES[:primary] }
    end

    trait :secondary do
      role_type { Meibo::Role::TYPES[:secondary] }
    end

    trait :aide do
      role { Meibo::Role::ROLES[:aide] }
    end

    trait :counselor do
      role { Meibo::Role::ROLES[:counselor] }
    end

    trait :district_administrator do
      role { Meibo::Role::ROLES[:district_administrator] }
    end

    trait :guardian do
      role { Meibo::Role::ROLES[:guardian] }
    end

    trait :parent do
      role { Meibo::Role::ROLES[:parent] }
    end

    trait :principal do
      role { Meibo::Role::ROLES[:principal] }
    end

    trait :proctor do
      role { Meibo::Role::ROLES[:proctor] }
    end

    trait :relative do
      role { Meibo::Role::ROLES[:relative] }
    end

    trait :site_administrator do
      role { Meibo::Role::ROLES[:site_administrator] }
    end

    trait :student do
      role { Meibo::Role::ROLES[:student] }
    end

    trait :system_administrator do
      role { Meibo::Role::ROLES[:system_administrator] }
    end

    trait :teacher do
      role { Meibo::Role::ROLES[:teacher] }
    end

    trait :jp do
      jp_version { "1.1" }

      initialize_with do
        case jp_version
        when "1.1"
          Meibo::Role.new(**attributes)
        when "1.0"
          Meibo::JapanProfile::RoleJpM0.new(**attributes)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
meibo-0.27.1 lib/meibo/factory_bot/role.rb
meibo-0.27.0 lib/meibo/factory_bot/role.rb
meibo-0.26.0 lib/meibo/factory_bot/role.rb
meibo-0.25.3 lib/meibo/factory_bot/role.rb
meibo-0.25.2 lib/meibo/factory_bot/role.rb
meibo-0.25.1 lib/meibo/factory_bot/role.rb
meibo-0.25.0 lib/meibo/factory_bot/role.rb
meibo-0.24.0 lib/meibo/factory_bot/role.rb
meibo-0.23.0 lib/meibo/factory_bot/role.rb