Commit 7047a44a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Sett iid on create. Use iid as value to_param

parent 125c07fa
...@@ -16,6 +16,7 @@ module Issuable ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment