Issue uses StateMachine now
This commit is contained in:
parent
0b512af803
commit
1644117a1a
13 changed files with 144 additions and 145 deletions
|
@ -9,7 +9,7 @@
|
|||
# project_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# closed :boolean default(FALSE), not null
|
||||
# state :string default(FALSE), not null
|
||||
# position :integer default(0)
|
||||
# branch_name :string(255)
|
||||
# description :text
|
||||
|
@ -19,11 +19,29 @@
|
|||
class Issue < ActiveRecord::Base
|
||||
include Issuable
|
||||
|
||||
attr_accessible :title, :assignee_id, :closed, :position, :description,
|
||||
:milestone_id, :label_list, :author_id_of_changes
|
||||
attr_accessible :title, :assignee_id, :position, :description,
|
||||
:milestone_id, :label_list, :author_id_of_changes,
|
||||
:state_event
|
||||
|
||||
acts_as_taggable_on :labels
|
||||
|
||||
state_machine :state, :initial => :opened do
|
||||
event :close do
|
||||
transition [:reopened, :opened] => :closed
|
||||
end
|
||||
|
||||
event :reopen do
|
||||
transition :closed => :reopened
|
||||
end
|
||||
|
||||
state :opened
|
||||
|
||||
state :reopened
|
||||
|
||||
state :closed
|
||||
end
|
||||
|
||||
|
||||
def self.open_for(user)
|
||||
opened.assigned(user)
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ class Project < ActiveRecord::Base
|
|||
|
||||
has_many :events, dependent: :destroy
|
||||
has_many :merge_requests, dependent: :destroy
|
||||
has_many :issues, dependent: :destroy, order: "closed, created_at DESC"
|
||||
has_many :issues, dependent: :destroy, order: "state, created_at DESC"
|
||||
has_many :milestones, dependent: :destroy
|
||||
has_many :users_projects, dependent: :destroy
|
||||
has_many :notes, dependent: :destroy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue