debian-mirror-gitlab/spec/factories/design_management/design_at_version.rb

24 lines
541 B
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
FactoryBot.define do
factory :design_at_version, class: 'DesignManagement::DesignAtVersion' do
skip_create # This is not an Active::Record model.
design { nil }
version { nil }
transient do
2021-01-29 00:20:46 +05:30
issue { design&.issue || version&.issue || association(:issue) }
2020-05-24 23:13:21 +05:30
end
initialize_with do
attrs = attributes.dup
2021-01-29 00:20:46 +05:30
attrs[:design] ||= association(:design, issue: issue)
attrs[:version] ||= association(:design_version, issue: issue)
2020-05-24 23:13:21 +05:30
2021-03-11 19:13:27 +05:30
new(**attrs)
2020-05-24 23:13:21 +05:30
end
end
end