debian-mirror-gitlab/spec/factories/milestones.rb

49 lines
1.2 KiB
Ruby
Raw Normal View History

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
2019-12-21 20:55:43 +05:30
project { nil }
group { nil }
project_id { nil }
group_id { nil }
resource_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
2019-12-21 20:55:43 +05:30
state { "active" }
2016-11-03 12:29:30 +05:30
end
2016-06-02 11:05:42 +05:30
trait :closed do
2019-12-21 20:55:43 +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
2019-12-21 20:55:43 +05:30
elsif evaluator.resource_parent
id = evaluator.resource_parent.id
evaluator.resource_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