Sha256: 2745f79cb3b8f6580bb8d834628f30af6be564f6838b6a60c1ad354343c43cb4

Contents?: true

Size: 1.27 KB

Versions: 40

Compression:

Stored size: 1.27 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

40 entries across 40 versions & 1 rubygems

Version Path
renalware-core-2.0.42 spec/factories/transplants/registrations.rb
renalware-core-2.0.41 spec/factories/transplants/registrations.rb
renalware-core-2.0.40 spec/factories/transplants/registrations.rb
renalware-core-2.0.39 spec/factories/transplants/registrations.rb
renalware-core-2.0.38 spec/factories/transplants/registrations.rb
renalware-core-2.0.37 spec/factories/transplants/registrations.rb
renalware-core-2.0.36 spec/factories/transplants/registrations.rb
renalware-core-2.0.35 spec/factories/transplants/registrations.rb
renalware-core-2.0.34 spec/factories/transplants/registrations.rb
renalware-core-2.0.33 spec/factories/transplants/registrations.rb
renalware-core-2.0.32 spec/factories/transplants/registrations.rb
renalware-core-2.0.31 spec/factories/transplants/registrations.rb
renalware-core-2.0.30 spec/factories/transplants/registrations.rb
renalware-core-2.0.28 spec/factories/transplants/registrations.rb
renalware-core-2.0.27 spec/factories/transplants/registrations.rb
renalware-core-2.0.26 spec/factories/transplants/registrations.rb
renalware-core-2.0.25 spec/factories/transplants/registrations.rb
renalware-core-2.0.24 spec/factories/transplants/registrations.rb
renalware-core-2.0.23 spec/factories/transplants/registrations.rb
renalware-core-2.0.22 spec/factories/transplants/registrations.rb