2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
FactoryBot.define do
|
2016-06-02 11:05:42 +05:30
|
|
|
factory :milestone do
|
|
|
|
title
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
transient do
|
|
|
|
project nil
|
|
|
|
group nil
|
|
|
|
project_id nil
|
|
|
|
group_id nil
|
2018-03-17 18:26:18 +05:30
|
|
|
parent nil
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
trait :active do
|
|
|
|
state "active"
|
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
trait :closed do
|
2016-11-03 12:29:30 +05:30
|
|
|
state "closed"
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
trait :with_dates do
|
|
|
|
start_date { Date.new(2000, 1, 1) }
|
|
|
|
due_date { Date.new(2000, 1, 30) }
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
after(:build, :stub) do |milestone, evaluator|
|
|
|
|
if evaluator.group
|
|
|
|
milestone.group = evaluator.group
|
|
|
|
elsif evaluator.group_id
|
|
|
|
milestone.group_id = evaluator.group_id
|
|
|
|
elsif evaluator.project
|
|
|
|
milestone.project = evaluator.project
|
|
|
|
elsif evaluator.project_id
|
|
|
|
milestone.project_id = evaluator.project_id
|
2018-03-17 18:26:18 +05:30
|
|
|
elsif evaluator.parent
|
|
|
|
id = evaluator.parent.id
|
2018-11-20 20:47:30 +05:30
|
|
|
evaluator.parent.is_a?(Group) ? evaluator.group_id = id : evaluator.project_id = id
|
2017-09-10 17:25:29 +05:30
|
|
|
else
|
|
|
|
milestone.project = create(:project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
factory :active_milestone, traits: [:active]
|
2016-06-02 11:05:42 +05:30
|
|
|
factory :closed_milestone, traits: [:closed]
|
|
|
|
end
|
|
|
|
end
|