Sett iid on create. Use iid as value to_param
This commit is contained in:
parent
125c07fa0a
commit
7047a44a26
2 changed files with 16 additions and 0 deletions
|
@ -16,6 +16,7 @@ module Issuable
|
||||||
|
|
||||||
validates :author, presence: true
|
validates :author, presence: true
|
||||||
validates :title, presence: true, length: { within: 0..255 }
|
validates :title, presence: true, length: { within: 0..255 }
|
||||||
|
validates :iid, presence: true, numericality: true
|
||||||
|
|
||||||
scope :authored, ->(user) { where(author_id: user) }
|
scope :authored, ->(user) { where(author_id: user) }
|
||||||
scope :assigned_to, ->(u) { where(assignee_id: u.id)}
|
scope :assigned_to, ->(u) { where(assignee_id: u.id)}
|
||||||
|
@ -24,6 +25,8 @@ module Issuable
|
||||||
scope :unassigned, -> { where("assignee_id IS NULL") }
|
scope :unassigned, -> { where("assignee_id IS NULL") }
|
||||||
scope :of_projects, ->(ids) { where(project_id: ids) }
|
scope :of_projects, ->(ids) { where(project_id: ids) }
|
||||||
|
|
||||||
|
validate :set_iid, on: :create
|
||||||
|
|
||||||
delegate :name,
|
delegate :name,
|
||||||
:email,
|
:email,
|
||||||
to: :author,
|
to: :author,
|
||||||
|
@ -44,6 +47,15 @@ module Issuable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_iid
|
||||||
|
max_iid = project.send(self.class.name.tableize).maximum(:iid)
|
||||||
|
self.iid = max_iid.to_i + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_param
|
||||||
|
iid.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def today?
|
def today?
|
||||||
Date.today == created_at.to_date
|
Date.today == created_at.to_date
|
||||||
end
|
end
|
||||||
|
|
|
@ -250,6 +250,10 @@ class MergeRequest < ActiveRecord::Base
|
||||||
(source_project.root_ref? source_branch) || for_fork?
|
(source_project.root_ref? source_branch) || for_fork?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def project
|
||||||
|
target_project
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def dump_commits(commits)
|
def dump_commits(commits)
|
||||||
|
|
Loading…
Reference in a new issue