Sha256: 47b8254e0e521ba1e12bf66016185eb6e8c3f09b5e8aeb42cfe0bcfccfe320fa

Contents?: true

Size: 1.29 KB

Versions: 50

Compression:

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

50 entries across 50 versions & 1 rubygems

Version Path
renalware-core-2.0.130 spec/factories/transplants/registrations.rb
renalware-core-2.0.129 spec/factories/transplants/registrations.rb
renalware-core-2.0.128 spec/factories/transplants/registrations.rb
renalware-core-2.0.127 spec/factories/transplants/registrations.rb
renalware-core-2.0.126 spec/factories/transplants/registrations.rb
renalware-core-2.0.125 spec/factories/transplants/registrations.rb
renalware-core-2.0.124 spec/factories/transplants/registrations.rb
renalware-core-2.0.123 spec/factories/transplants/registrations.rb
renalware-core-2.0.121 spec/factories/transplants/registrations.rb
renalware-core-2.0.120 spec/factories/transplants/registrations.rb
renalware-core-2.0.119 spec/factories/transplants/registrations.rb
renalware-core-2.0.118 spec/factories/transplants/registrations.rb
renalware-core-2.0.117 spec/factories/transplants/registrations.rb
renalware-core-2.0.116 spec/factories/transplants/registrations.rb
renalware-core-2.0.115 spec/factories/transplants/registrations.rb
renalware-core-2.0.113 spec/factories/transplants/registrations.rb
renalware-core-2.0.112 spec/factories/transplants/registrations.rb
renalware-core-2.0.111 spec/factories/transplants/registrations.rb
renalware-core-2.0.110 spec/factories/transplants/registrations.rb
renalware-core-2.0.109 spec/factories/transplants/registrations.rb