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.77 spec/factories/transplants/registrations.rb
renalware-core-2.0.76 spec/factories/transplants/registrations.rb
renalware-core-2.0.75 spec/factories/transplants/registrations.rb
renalware-core-2.0.74 spec/factories/transplants/registrations.rb
renalware-core-2.0.73 spec/factories/transplants/registrations.rb
renalware-core-2.0.72 spec/factories/transplants/registrations.rb
renalware-core-2.0.71 spec/factories/transplants/registrations.rb
renalware-core-2.0.70 spec/factories/transplants/registrations.rb
renalware-core-2.0.69 spec/factories/transplants/registrations.rb
renalware-core-2.0.68 spec/factories/transplants/registrations.rb
renalware-core-2.0.67 spec/factories/transplants/registrations.rb
renalware-core-2.0.64 spec/factories/transplants/registrations.rb
renalware-core-2.0.63 spec/factories/transplants/registrations.rb
renalware-core-2.0.62 spec/factories/transplants/registrations.rb
renalware-core-2.0.61 spec/factories/transplants/registrations.rb
renalware-core-2.0.60 spec/factories/transplants/registrations.rb
renalware-core-2.0.58 spec/factories/transplants/registrations.rb
renalware-core-2.0.57 spec/factories/transplants/registrations.rb
renalware-core-2.0.56 spec/factories/transplants/registrations.rb
renalware-core-2.0.55 spec/factories/transplants/registrations.rb