Skip to content
Snippets Groups Projects
Commit 7047a44a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Sett iid on create. Use iid as value to_param

parent 125c07fa
No related branches found
No related tags found
1 merge request!5081fixed command to update init script
Loading
Loading
@@ -16,6 +16,7 @@ module Issuable
 
validates :author, presence: true
validates :title, presence: true, length: { within: 0..255 }
validates :iid, presence: true, numericality: true
 
scope :authored, ->(user) { where(author_id: user) }
scope :assigned_to, ->(u) { where(assignee_id: u.id)}
Loading
Loading
@@ -24,6 +25,8 @@ module Issuable
scope :unassigned, -> { where("assignee_id IS NULL") }
scope :of_projects, ->(ids) { where(project_id: ids) }
 
validate :set_iid, on: :create
delegate :name,
:email,
to: :author,
Loading
Loading
@@ -44,6 +47,15 @@ module Issuable
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?
Date.today == created_at.to_date
end
Loading
Loading
Loading
Loading
@@ -250,6 +250,10 @@ class MergeRequest < ActiveRecord::Base
(source_project.root_ref? source_branch) || for_fork?
end
 
def project
target_project
end
private
 
def dump_commits(commits)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment