Files
nairobi/spec/factories/milestones.rb
Javi Martín 614b4fbe4c Add and apply FactoryBot/AssociationStyle rule
This rule was added in rubocop-factory_bot 2.23.0. We were following it
sometimes, and sometimes we were not.
2023-09-08 13:52:54 +02:00

40 lines
1.1 KiB
Ruby

FactoryBot.define do
factory :milestone_status, class: "Milestone::Status" do
sequence(:name) { |n| "Milestone status #{n} name" }
sequence(:description) { |n| "Milestone status #{n} description" }
end
factory :milestone do
milestoneable factory: :budget_investment
status factory: :milestone_status
sequence(:title) { |n| "Milestone #{n} title" }
description { "Milestone description" }
publication_date { Date.current }
trait :with_image do
transient { image_title { "Current status of the project" } }
after(:create) do |milestone, evaluator|
create(:image, imageable: milestone, title: evaluator.image_title)
end
end
factory :milestone_with_description do
status { nil }
end
end
factory :progress_bar do
progressable factory: :budget_investment
percentage { rand(0..100) }
kind { :primary }
trait(:secondary) do
kind { :secondary }
sequence(:title) { |n| "Progress bar #{n} title" }
end
factory :secondary_progress_bar, traits: [:secondary]
end
end