debian-mirror-gitlab/spec/factories/import_states.rb

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

50 lines
1,009 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
FactoryBot.define do
2020-03-13 15:44:24 +05:30
factory :import_state, class: 'ProjectImportState' do
2019-12-21 20:55:43 +05:30
status { :none }
2018-10-15 14:42:47 +05:30
association :project, factory: :project
transient do
import_url { generate(:url) }
2019-12-21 20:55:43 +05:30
import_type { nil }
2018-10-15 14:42:47 +05:30
end
trait :repository do
association :project, factory: [:project, :repository]
end
trait :none do
2019-12-21 20:55:43 +05:30
status { :none }
2018-10-15 14:42:47 +05:30
end
trait :scheduled do
2019-12-21 20:55:43 +05:30
status { :scheduled }
2018-10-15 14:42:47 +05:30
end
trait :started do
2019-12-21 20:55:43 +05:30
status { :started }
2018-10-15 14:42:47 +05:30
end
trait :finished do
2019-12-21 20:55:43 +05:30
status { :finished }
2018-10-15 14:42:47 +05:30
end
trait :failed do
2019-12-21 20:55:43 +05:30
status { :failed }
2018-10-15 14:42:47 +05:30
end
2022-08-13 15:12:31 +05:30
trait :canceled do
status { :canceled }
end
2018-10-15 14:42:47 +05:30
after(:create) do |import_state, evaluator|
2019-02-15 15:39:39 +05:30
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-10-15 14:42:47 +05:30
end
end
end