Sha256: 72a19efc04ad817772a269ad33b02df31882aaa6b618ebd613b8a7027bf7550f

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "factory_bot"
require "securerandom"

FactoryBot.define do
  factory :meibo_user, class: "Meibo::User" do
    initialize_with do
      case oneroster_version
      when "1.2.1"
        new(**attributes)
      when "1.2", "1.2.0"
        Meibo::UserM0.new(**attributes)
      end
    end

    transient do
      agents { [] }
      primary_organization { nil }
      oneroster_version { "1.2.1" }
    end

    sourced_id { SecureRandom.uuid }
    sequence(:username) { |n| "user#{n}@example.com" }
    sequence(:given_name) { |n| "John#{n}" }
    sequence(:family_name) { |n| "Doe#{n}" }
    agent_sourced_ids { agents&.map(&:sourced_id) }
    primary_org_sourced_id { primary_organization&.sourced_id }

    trait :jp do
      initialize_with do
        case oneroster_version
        when "1.2.1"
          Meibo::JapanProfile::User.new(**attributes)
        when "1.2", "1.2.0"
          Meibo::JapanProfile::UserM0.new(**attributes)
        end
      end

      transient do
        homeroom { nil }
      end

      home_class { homeroom&.sourced_id }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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