Sha256: 106569089be9bbf79bc8d53c66f98f6738437dbfa86f2079c250aa9d2d0a6634

Contents?: true

Size: 1.3 KB

Versions: 37

Compression:

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

37 entries across 37 versions & 1 rubygems

Version Path
renalware-core-2.1.1 spec/factories/transplants/registrations.rb
renalware-core-2.1.0 spec/factories/transplants/registrations.rb
renalware-core-2.0.167 spec/factories/transplants/registrations.rb
renalware-core-2.0.166 spec/factories/transplants/registrations.rb
renalware-core-2.0.165 spec/factories/transplants/registrations.rb
renalware-core-2.0.164 spec/factories/transplants/registrations.rb
renalware-core-2.0.163 spec/factories/transplants/registrations.rb
renalware-core-2.0.162 spec/factories/transplants/registrations.rb
renalware-core-2.0.161 spec/factories/transplants/registrations.rb
renalware-core-2.0.160 spec/factories/transplants/registrations.rb
renalware-core-2.0.159 spec/factories/transplants/registrations.rb
renalware-core-2.0.158 spec/factories/transplants/registrations.rb
renalware-core-2.0.157 spec/factories/transplants/registrations.rb
renalware-core-2.0.156 spec/factories/transplants/registrations.rb
renalware-core-2.0.155 spec/factories/transplants/registrations.rb
renalware-core-2.0.153 spec/factories/transplants/registrations.rb
renalware-core-2.0.152 spec/factories/transplants/registrations.rb
renalware-core-2.0.151 spec/factories/transplants/registrations.rb
renalware-core-2.0.149 spec/factories/transplants/registrations.rb
renalware-core-2.0.148 spec/factories/transplants/registrations.rb