diff options
author | Felipe Artur <felipefac@gmail.com> | 2019-02-14 21:33:26 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2019-02-14 21:33:26 +0300 |
commit | 9671a67a4ce58683ca0188ff9e75b1d5dfcc5dec (patch) | |
tree | 67f4d0852510e80ad8b7b08fca7b7ec14dda646b | |
parent | d4a5d8d07069acb6f068990633baaf56d20bc18b (diff) |
Fix broken specs
-rw-r--r-- | app/models/concerns/issuable_states.rb | 10 | ||||
-rw-r--r-- | app/models/merge_request.rb | 2 | ||||
-rw-r--r-- | db/migrate/20190211131150_add_state_id_to_issuables.rb | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/app/models/concerns/issuable_states.rb b/app/models/concerns/issuable_states.rb index a39a0ef77ed..12fa97a1469 100644 --- a/app/models/concerns/issuable_states.rb +++ b/app/models/concerns/issuable_states.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + module IssuableStates extend ActiveSupport::Concern # The state:string column is being migrated to state_id:integer column # This is a temporary hook to populate state_id column with new values - # and can be removed after the state column is removed. + # and should be removed after the state column is removed. # Check https://gitlab.com/gitlab-org/gitlab-ce/issues/51789 for more information included do before_save :set_state_id @@ -12,6 +14,12 @@ module IssuableStates def set_state_id return if state.nil? || state.empty? + # Needed to prevent breaking some migration specs that + # rollback database to a point where state_id does not exist. + # We can use this guard clause for now since this file will should + # be removed in the next release. + return unless self.respond_to?(:state_id) + states_hash = self.class.available_states self.state_id = states_hash[state] diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 0ec0789a24f..063433111cc 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -194,7 +194,7 @@ class MergeRequest < ActiveRecord::Base end def self.available_states - @states ||= super.merge(merged: 3, locked: 4) + @available_states ||= super.merge(merged: 3, locked: 4) end def rebase_in_progress? diff --git a/db/migrate/20190211131150_add_state_id_to_issuables.rb b/db/migrate/20190211131150_add_state_id_to_issuables.rb index cf3f7671a67..c1173eb4249 100644 --- a/db/migrate/20190211131150_add_state_id_to_issuables.rb +++ b/db/migrate/20190211131150_add_state_id_to_issuables.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddStateIdToIssuables < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers |