2019-07-25 05:11:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-14 00:13:44 +00:00
|
|
|
FactoryBot.define do
|
2016-02-17 03:55:24 +00:00
|
|
|
factory :issue do
|
2017-03-23 16:37:14 +00:00
|
|
|
title { generate(:title) }
|
2017-08-02 19:55:11 +00:00
|
|
|
project
|
2017-08-04 17:14:04 +00:00
|
|
|
author { project.creator }
|
2018-06-01 15:09:08 +00:00
|
|
|
updated_by { author }
|
2016-02-17 03:55:24 +00:00
|
|
|
|
2016-03-17 19:38:51 +00:00
|
|
|
trait :confidential do
|
2019-10-02 00:06:26 +00:00
|
|
|
confidential { true }
|
2016-03-17 19:38:51 +00:00
|
|
|
end
|
|
|
|
|
2017-04-25 10:36:18 +00:00
|
|
|
trait :opened do
|
2019-10-18 11:11:44 +00:00
|
|
|
state_id { Issue.available_states[:opened] }
|
2017-04-25 10:36:18 +00:00
|
|
|
end
|
|
|
|
|
2018-09-20 14:41:15 +00:00
|
|
|
trait :locked do
|
2019-10-02 00:06:26 +00:00
|
|
|
discussion_locked { true }
|
2018-09-20 14:41:15 +00:00
|
|
|
end
|
|
|
|
|
2016-02-17 03:55:24 +00:00
|
|
|
trait :closed do
|
2019-10-18 11:11:44 +00:00
|
|
|
state_id { Issue.available_states[:closed] }
|
2017-09-19 15:25:42 +00:00
|
|
|
closed_at { Time.now }
|
2016-02-17 03:55:24 +00:00
|
|
|
end
|
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
after(:build) do |issue, evaluator|
|
|
|
|
issue.state_id = Issue.available_states[evaluator.state]
|
|
|
|
end
|
|
|
|
|
2016-02-17 03:55:24 +00:00
|
|
|
factory :closed_issue, traits: [:closed]
|
2017-07-19 14:03:50 +00:00
|
|
|
factory :reopened_issue, traits: [:opened]
|
2016-07-20 22:45:19 +00:00
|
|
|
|
|
|
|
factory :labeled_issue do
|
|
|
|
transient do
|
2019-10-02 00:06:26 +00:00
|
|
|
labels { [] }
|
2016-07-20 22:45:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |issue, evaluator|
|
2018-07-02 10:43:06 +00:00
|
|
|
issue.update(labels: evaluator.labels)
|
2016-07-20 22:45:19 +00:00
|
|
|
end
|
|
|
|
end
|
2016-02-17 03:55:24 +00:00
|
|
|
end
|
|
|
|
end
|