Commit 7047a44a26f0f75ab23c58c47d096060c01256ed
1 parent
125c07fa
Exists in
master
and in
4 other branches
Sett iid on create. Use iid as value to_param
Showing
2 changed files
with
16 additions
and
0 deletions
Show diff stats
app/models/concerns/issuable.rb
@@ -16,6 +16,7 @@ module Issuable | @@ -16,6 +16,7 @@ module Issuable | ||
16 | 16 | ||
17 | validates :author, presence: true | 17 | validates :author, presence: true |
18 | validates :title, presence: true, length: { within: 0..255 } | 18 | validates :title, presence: true, length: { within: 0..255 } |
19 | + validates :iid, presence: true, numericality: true | ||
19 | 20 | ||
20 | scope :authored, ->(user) { where(author_id: user) } | 21 | scope :authored, ->(user) { where(author_id: user) } |
21 | scope :assigned_to, ->(u) { where(assignee_id: u.id)} | 22 | scope :assigned_to, ->(u) { where(assignee_id: u.id)} |
@@ -24,6 +25,8 @@ module Issuable | @@ -24,6 +25,8 @@ module Issuable | ||
24 | scope :unassigned, -> { where("assignee_id IS NULL") } | 25 | scope :unassigned, -> { where("assignee_id IS NULL") } |
25 | scope :of_projects, ->(ids) { where(project_id: ids) } | 26 | scope :of_projects, ->(ids) { where(project_id: ids) } |
26 | 27 | ||
28 | + validate :set_iid, on: :create | ||
29 | + | ||
27 | delegate :name, | 30 | delegate :name, |
28 | :email, | 31 | :email, |
29 | to: :author, | 32 | to: :author, |
@@ -44,6 +47,15 @@ module Issuable | @@ -44,6 +47,15 @@ module Issuable | ||
44 | end | 47 | end |
45 | end | 48 | end |
46 | 49 | ||
50 | + def set_iid | ||
51 | + max_iid = project.send(self.class.name.tableize).maximum(:iid) | ||
52 | + self.iid = max_iid.to_i + 1 | ||
53 | + end | ||
54 | + | ||
55 | + def to_param | ||
56 | + iid.to_s | ||
57 | + end | ||
58 | + | ||
47 | def today? | 59 | def today? |
48 | Date.today == created_at.to_date | 60 | Date.today == created_at.to_date |
49 | end | 61 | end |
app/models/merge_request.rb
@@ -250,6 +250,10 @@ class MergeRequest < ActiveRecord::Base | @@ -250,6 +250,10 @@ class MergeRequest < ActiveRecord::Base | ||
250 | (source_project.root_ref? source_branch) || for_fork? | 250 | (source_project.root_ref? source_branch) || for_fork? |
251 | end | 251 | end |
252 | 252 | ||
253 | + def project | ||
254 | + target_project | ||
255 | + end | ||
256 | + | ||
253 | private | 257 | private |
254 | 258 | ||
255 | def dump_commits(commits) | 259 | def dump_commits(commits) |