gitlab-org--gitlab-foss/spec/factories/boards.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
970 B
Ruby
Raw Normal View History

# frozen_string_literal: true
FactoryBot.define do
2016-07-27 17:46:03 -04:00
factory :board do
2018-02-19 14:06:16 -05:00
transient do
project { nil }
group { nil }
project_id { nil }
group_id { nil }
resource_parent { nil }
2018-02-19 14:06:16 -05:00
end
after(:build, :stub) do |board, evaluator|
if evaluator.group
board.group = evaluator.group
elsif evaluator.group_id
board.group_id = evaluator.group_id
elsif evaluator.project
board.project = evaluator.project
elsif evaluator.project_id
board.project_id = evaluator.project_id
elsif evaluator.resource_parent
id = evaluator.resource_parent.id
evaluator.resource_parent.is_a?(Group) ? board.group_id = id : evaluator.project_id = id
2018-02-19 14:06:16 -05:00
else
board.project = create(:project, :empty_repo)
end
end
after(:create) do |board|
board.lists.create!(list_type: :closed)
end
2016-07-27 17:46:03 -04:00
end
factory :group_board, parent: :board do
group
end
2016-07-27 17:46:03 -04:00
end