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

38 lines
800 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
FactoryGirl.define do
factory :milestone do
title
2017-09-10 17:25:29 +05:30
transient do
project nil
group nil
project_id nil
group_id nil
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
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
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