2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module IssuableStates
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
# The state:string column is being migrated to state_id:integer column
|
2019-12-21 20:55:43 +05:30
|
|
|
# This is a temporary hook to keep state column in sync until it is removed.
|
|
|
|
# Check https: https://gitlab.com/gitlab-org/gitlab/issues/33814 for more information
|
|
|
|
# The state column can be safely removed after 2019-10-27
|
2019-07-07 11:18:12 +05:30
|
|
|
included do
|
2019-12-21 20:55:43 +05:30
|
|
|
before_save :sync_issuable_deprecated_state
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
def sync_issuable_deprecated_state
|
|
|
|
return if self.is_a?(Epic)
|
|
|
|
return unless respond_to?(:state)
|
|
|
|
return if state_id.nil?
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
deprecated_state = self.class.available_states.key(state_id)
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
self.write_attribute(:state, deprecated_state)
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|