Sha256: 953abea1979613f95e67e1296882e99f40a3248195338d44684024d030d91b8d

Contents?: true

Size: 1.28 KB

Versions: 31

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :transplant_registration, class: Renalware::Transplants::Registration do
    patient { build(:transplant_patient) }

    trait :with_statuses do
      after(:create) do |registration|
        10.downto(8).each do |day|
          start_date = day.days.ago
          create(
            :transplant_registration_status,
            registration: registration,
            started_on: start_date,
            terminated_on: start_date + 1.day
          )
        end
        create(
          :transplant_registration_status,
          registration: registration,
          started_on: 7.days.ago
        )
      end
    end

    trait :in_status do
      transient do
        status { "active" }
      end

      after(:create) do |registration, evaluator|
        create(
          :transplant_registration_status,
          registration: registration,
          started_on: 7.days.ago,
          description: create(:transplant_registration_status_description,
            name: evaluator.status.humanize, code: evaluator.status)
        )
        create(
          :transplant_registration_status,
          registration: registration,
          started_on: 10.days.ago,
          terminated_on: 7.days.ago
        )
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
renalware-core-2.0.54 spec/factories/transplants/registrations.rb
renalware-core-2.0.53 spec/factories/transplants/registrations.rb
renalware-core-2.0.52 spec/factories/transplants/registrations.rb
renalware-core-2.0.51 spec/factories/transplants/registrations.rb
renalware-core-2.0.50 spec/factories/transplants/registrations.rb
renalware-core-2.0.48 spec/factories/transplants/registrations.rb
renalware-core-2.0.47 spec/factories/transplants/registrations.rb
renalware-core-2.0.46 spec/factories/transplants/registrations.rb
renalware-core-2.0.45 spec/factories/transplants/registrations.rb
renalware-core-2.0.44 spec/factories/transplants/registrations.rb
renalware-core-2.0.43 spec/factories/transplants/registrations.rb