Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bbe9cd8d
Commit
bbe9cd8d
authored
Apr 27, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validates self relation
parent
d52237a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
app/models/related_issue.rb
app/models/related_issue.rb
+11
-0
No files found.
app/models/related_issue.rb
View file @
bbe9cd8d
...
@@ -5,4 +5,15 @@ class RelatedIssue < ActiveRecord::Base
...
@@ -5,4 +5,15 @@ class RelatedIssue < ActiveRecord::Base
validates
:issue
,
presence:
true
validates
:issue
,
presence:
true
validates
:related_issue
,
presence:
true
validates
:related_issue
,
presence:
true
validates
:issue
,
uniqueness:
{
scope: :related_issue_id
,
message:
'is already related'
}
validates
:issue
,
uniqueness:
{
scope: :related_issue_id
,
message:
'is already related'
}
validate
:check_self_relation
private
def
check_self_relation
return
unless
issue
||
related_issue
if
issue
==
related_issue
errors
.
add
(
:issue
,
'cannot be related to itself'
)
end
end
end
end
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