Sha256: 86c318e7f91db47be18bcba235ca3ec5725a12166a4ca0b3ce0b481263d71af1

Contents?: true

Size: 789 Bytes

Versions: 6

Compression:

Stored size: 789 Bytes

Contents

FactoryBot.define do
  factory :insights_facet do
    # sequence(:uuid) { |n| "uuid-#{n}" }

    trait :with_hits do
      hits do
        Array.new(1) { association(:insights_hit, host_id: host_id) }
      end
    end
  end

  factory :insights_hit do
    last_seen { Date.yesterday }
    sequence(:title) { |n| "hit title #{n}" }
    sequence(:solution_url) { |n| "http://example.com/solutions/#{n}" }
    total_risk { 1 }
    likelihood { 2 }
    publish_date { Time.now }
    sequence(:results_url) { |n| "http://example.com/results/#{n}" }
  end
end

FactoryBot.modify do
  factory :host do
    trait :with_insights_hits do
      after(:create) do |host, _evaluator|
        host.insights = FactoryBot.create(:insights_facet, :with_hits, host_id: host.id)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_rh_cloud-0.9.14 test/factories/insights_factories.rb
foreman_rh_cloud-0.9.13.1 test/factories/insights_factories.rb
foreman_rh_cloud-0.9.13 test/factories/insights_factories.rb
foreman_rh_cloud-0.9.12 test/factories/insights_factories.rb
foreman_rh_cloud-0.9.11 test/factories/insights_factories.rb
foreman_rh_cloud-0.9.10 test/factories/insights_factories.rb