BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0af2ab18
Commit
0af2ab18
authored
May 08, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decouple to_params from AtomicInternalId concern
parent
632b87a8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
6 deletions
+15
-6
pipeline.rb
app/models/ci/pipeline.rb
+1
-1
atomic_internal_id.rb
app/models/concerns/atomic_internal_id.rb
+1
-5
iid_routes.rb
app/models/concerns/iid_routes.rb
+9
-0
deployment.rb
app/models/deployment.rb
+1
-0
issue.rb
app/models/issue.rb
+1
-0
merge_request.rb
app/models/merge_request.rb
+1
-0
milestone.rb
app/models/milestone.rb
+1
-0
No files found.
app/models/ci/pipeline.rb
View file @
0af2ab18
...
...
@@ -14,7 +14,7 @@ module Ci
belongs_to
:auto_canceled_by
,
class_name:
'Ci::Pipeline'
belongs_to
:pipeline_schedule
,
class_name:
'Ci::PipelineSchedule'
has_internal_id
:iid
,
scope: :project
,
presence:
false
,
to_param:
false
,
init:
->
do
|
s
|
has_internal_id
:iid
,
scope: :project
,
presence:
false
,
init:
->
do
|
s
|
s
&
.
project
&
.
pipelines
&
.
maximum
(
:iid
)
||
s
&
.
project
&
.
pipelines
.
count
end
...
...
app/models/concerns/atomic_internal_id.rb
View file @
0af2ab18
...
...
@@ -25,7 +25,7 @@ module AtomicInternalId
extend
ActiveSupport
::
Concern
module
ClassMethods
def
has_internal_id
(
column
,
scope
:,
init
:,
presence:
true
,
to_param:
true
)
# rubocop:disable Naming/PredicateName
def
has_internal_id
(
column
,
scope
:,
init
:,
presence:
true
)
# rubocop:disable Naming/PredicateName
before_validation
:"ensure_
#{
column
}
!"
,
on: :create
validates
column
,
presence:
presence
,
numericality:
true
...
...
@@ -42,10 +42,6 @@ module AtomicInternalId
read_attribute
(
column
)
end
define_method
(
"to_param"
)
do
read_attribute
(
column
)
end
if
to_param
end
end
end
app/models/concerns/iid_routes.rb
0 → 100644
View file @
0af2ab18
module
IIDRoutes
##
# This automagically enforces all related routes to use `iid` instead of `id`
# If you want to use `iid` for some routes and `id` for other routes, this module should not to be included,
# instead you should define `iid` or `id` explictly at each route generators. e.g. pipeline_path(project.id, pipeline.iid)
def
to_param
iid
.
to_s
end
end
app/models/deployment.rb
View file @
0af2ab18
class
Deployment
<
ActiveRecord
::
Base
include
AtomicInternalId
include
IIDRoutes
belongs_to
:project
,
required:
true
belongs_to
:environment
,
required:
true
...
...
app/models/issue.rb
View file @
0af2ab18
...
...
@@ -2,6 +2,7 @@ require 'carrierwave/orm/activerecord'
class
Issue
<
ActiveRecord
::
Base
include
AtomicInternalId
include
IIDRoutes
include
Issuable
include
Noteable
include
Referable
...
...
app/models/merge_request.rb
View file @
0af2ab18
class
MergeRequest
<
ActiveRecord
::
Base
include
AtomicInternalId
include
IIDRoutes
include
Issuable
include
Noteable
include
Referable
...
...
app/models/milestone.rb
View file @
0af2ab18
...
...
@@ -9,6 +9,7 @@ class Milestone < ActiveRecord::Base
include
CacheMarkdownField
include
AtomicInternalId
include
IIDRoutes
include
Sortable
include
Referable
include
StripAttribute
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment