summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-04-02 08:39:53 +0000
committerSean McGivern <sean@gitlab.com>2019-04-02 08:39:53 +0000
commitf87b7fe3b386962c45e83486634352da544857fb (patch)
tree4c3fc969e0306e9877d22f787e8064126bfdef75 /spec/models
parent5ddd4f0f0708921ca0c8a9a941cfb4c0fb868b00 (diff)
parentf2b7da4bf507691cffd419d3dd759fcf6311cdd6 (diff)
downloadgitlab-ce-f87b7fe3b386962c45e83486634352da544857fb.tar.gz
Merge branch 'issue_51789_part_1' into 'master'
Migrate issuable states to integer patch 1 of 2 Closes #51789 See merge request gitlab-org/gitlab-ce!25107
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/issuable_states_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/concerns/issuable_states_spec.rb b/spec/models/concerns/issuable_states_spec.rb
new file mode 100644
index 00000000000..70450159cc0
--- /dev/null
+++ b/spec/models/concerns/issuable_states_spec.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+# This spec checks if state_id column of issues and merge requests
+# are being synced on every save.
+# It can be removed in the next release. Check https://gitlab.com/gitlab-org/gitlab-ce/issues/51789 for more information.
+describe IssuableStates do
+ [Issue, MergeRequest].each do |klass|
+ it "syncs state_id column when #{klass.model_name.human} gets created" do
+ klass.available_states.each do |state, state_id|
+ issuable = build(klass.model_name.param_key, state: state.to_s)
+
+ issuable.save!
+
+ expect(issuable.state_id).to eq(state_id)
+ end
+ end
+
+ it "syncs state_id column when #{klass.model_name.human} gets updated" do
+ klass.available_states.each do |state, state_id|
+ issuable = create(klass.model_name.param_key, state: state.to_s)
+
+ issuable.update(state: state)
+
+ expect(issuable.state_id).to eq(state_id)
+ end
+ end
+ end
+end