2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-02 09:35:04 -04:00
|
|
|
FactoryBot.define do
|
2020-01-09 13:07:52 -05:00
|
|
|
factory :import_state, class: 'ProjectImportState' do
|
2019-10-01 20:06:26 -04:00
|
|
|
status { :none }
|
2018-05-02 09:35:04 -04:00
|
|
|
association :project, factory: :project
|
|
|
|
|
|
|
|
transient do
|
|
|
|
import_url { generate(:url) }
|
2019-10-01 20:06:26 -04:00
|
|
|
import_type { nil }
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :repository do
|
|
|
|
association :project, factory: [:project, :repository]
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :none do
|
2019-10-01 20:06:26 -04:00
|
|
|
status { :none }
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :scheduled do
|
2019-10-01 20:06:26 -04:00
|
|
|
status { :scheduled }
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :started do
|
2019-10-01 20:06:26 -04:00
|
|
|
status { :started }
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :finished do
|
2019-10-01 20:06:26 -04:00
|
|
|
status { :finished }
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :failed do
|
2019-10-01 20:06:26 -04:00
|
|
|
status { :failed }
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
|
2022-07-05 11:08:48 -04:00
|
|
|
trait :canceled do
|
|
|
|
status { :canceled }
|
|
|
|
end
|
|
|
|
|
2018-05-02 09:35:04 -04:00
|
|
|
after(:create) do |import_state, evaluator|
|
2018-11-27 04:41:27 -05:00
|
|
|
columns = {}
|
|
|
|
columns[:import_url] = evaluator.import_url unless evaluator.import_url.blank?
|
|
|
|
columns[:import_type] = evaluator.import_type unless evaluator.import_type.blank?
|
|
|
|
|
|
|
|
import_state.project.update_columns(columns)
|
2018-05-02 09:35:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|