Merge branch 'dm-project-factory-import-state' into 'master'
Fix project factory `import_*` traits Closes gitlab-ee#5904 See merge request gitlab-org/gitlab-ce!18780
This commit is contained in:
commit
f9fcd2b410
2 changed files with 22 additions and 46 deletions
|
@ -657,8 +657,8 @@ class Project < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_import_state
|
def ensure_import_state(force: false)
|
||||||
return if self[:import_status] == 'none' || self[:import_status].nil?
|
return if !force && (self[:import_status] == 'none' || self[:import_status].nil?)
|
||||||
return unless import_state.nil?
|
return unless import_state.nil?
|
||||||
|
|
||||||
create_import_state(import_state_args)
|
create_import_state(import_state_args)
|
||||||
|
@ -667,39 +667,39 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_schedule
|
def import_schedule
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.schedule
|
import_state.schedule
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_import_start
|
def force_import_start
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.force_start
|
import_state.force_start
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_start
|
def import_start
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.start
|
import_state.start
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_fail
|
def import_fail
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.fail_op
|
import_state.fail_op
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_finish
|
def import_finish
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.finish
|
import_state.finish
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_jid=(new_jid)
|
def import_jid=(new_jid)
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.jid = new_jid
|
import_state.jid = new_jid
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_jid
|
def import_jid
|
||||||
|
@ -709,9 +709,9 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_error=(new_error)
|
def import_error=(new_error)
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.last_error = new_error
|
import_state.last_error = new_error
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_error
|
def import_error
|
||||||
|
@ -721,9 +721,9 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_status=(new_status)
|
def import_status=(new_status)
|
||||||
ensure_import_state
|
ensure_import_state(force: true)
|
||||||
|
|
||||||
import_state&.status = new_status
|
import_state.status = new_status
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_status
|
def import_status
|
||||||
|
|
|
@ -69,43 +69,19 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :import_scheduled do
|
trait :import_scheduled do
|
||||||
transient do
|
import_status :scheduled
|
||||||
status :scheduled
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:create) do |project, evaluator|
|
|
||||||
project.create_import_state(status: evaluator.status)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :import_started do
|
trait :import_started do
|
||||||
transient do
|
import_status :started
|
||||||
status :started
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:create) do |project, evaluator|
|
|
||||||
project.create_import_state(status: evaluator.status)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :import_finished do
|
trait :import_finished do
|
||||||
transient do
|
import_status :finished
|
||||||
status :finished
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:create) do |project, evaluator|
|
|
||||||
project.create_import_state(status: evaluator.status)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :import_failed do
|
trait :import_failed do
|
||||||
transient do
|
import_status :failed
|
||||||
status :failed
|
|
||||||
end
|
|
||||||
|
|
||||||
before(:create) do |project, evaluator|
|
|
||||||
project.create_import_state(status: evaluator.status)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :archived do
|
trait :archived do
|
||||||
|
|
Loading…
Reference in a new issue