Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index d0b2165fcc7..b9b481ac29b 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -71,7 +71,7 @@ class Issue < ApplicationRecord
attr_spammable :title, spam_title: true
attr_spammable :description, spam_description: true
- state_machine :state, initial: :opened do
+ state_machine :state_id, initial: :opened do
event :close do
transition [:opened] => :closed
end
@@ -80,8 +80,8 @@ class Issue < ApplicationRecord
transition closed: :opened
end
- state :opened
- state :closed
+ state :opened, value: Issue.available_states[:opened]
+ state :closed, value: Issue.available_states[:closed]
before_transition any => :closed do |issue|
issue.closed_at = issue.system_note_timestamp
@@ -93,6 +93,13 @@ class Issue < ApplicationRecord
end
end
+ # Alias to state machine .with_state_id method
+ # This needs to be defined after the state machine block to avoid errors
+ class << self
+ alias_method :with_state, :with_state_id
+ alias_method :with_states, :with_state_ids
+ end
+
def self.relative_positioning_query_base(issue)
in_projects(issue.parent_ids)
end