scinote-web/spec/factories/repository_date_time_values.rb

31 lines
1.1 KiB
Ruby
Raw Normal View History

2019-11-18 22:21:57 +08:00
# frozen_string_literal: true
FactoryBot.define do
2019-12-06 21:20:37 +08:00
factory :repository_date_time_value_base do
2019-11-18 22:21:57 +08:00
created_by { create :user }
last_modified_by { created_by }
data { Time.zone.now }
2019-12-06 21:20:37 +08:00
end
2019-11-18 22:21:57 +08:00
2019-12-06 21:20:37 +08:00
factory :repository_date_time_value, parent: :repository_date_time_value_base, class: 'RepositoryDateTimeValue' do
2019-11-18 22:21:57 +08:00
after(:build) do |value|
value.repository_cell ||= build(:repository_cell, :date_time_value, repository_date_time_value: value)
value.repository_cell.value = value
2019-11-18 22:21:57 +08:00
end
end
factory :repository_time_value, parent: :repository_date_time_value_base, class: 'RepositoryTimeValue' do
after(:build) do |value|
value.repository_cell ||= build(:repository_cell, :time_value, repository_time_value: value)
value.repository_cell.value = value
end
end
factory :repository_date_value, parent: :repository_date_time_value_base, class: 'RepositoryDateValue' do
after(:build) do |value|
value.repository_cell ||= build(:repository_cell, :date_value, repository_date_value: value)
value.repository_cell.value = value
end
end
2019-11-18 22:21:57 +08:00
end