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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
50768a25
Commit
50768a25
authored
Jan 08, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add uniqueness validation to url column in Releases::Link model
Add test Add changelog
parent
ba5a9033
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
app/models/releases/link.rb
app/models/releases/link.rb
+1
-1
changelogs/unreleased/add-uniqueness-validation-to-url-column-in-releases-link-model.yml
...eness-validation-to-url-column-in-releases-link-model.yml
+5
-0
spec/models/releases/link_spec.rb
spec/models/releases/link_spec.rb
+10
-0
No files found.
app/models/releases/link.rb
View file @
50768a25
...
@@ -6,7 +6,7 @@ module Releases
...
@@ -6,7 +6,7 @@ module Releases
belongs_to
:release
belongs_to
:release
validates
:url
,
presence:
true
,
url:
true
validates
:url
,
presence:
true
,
url:
true
,
uniqueness:
{
scope: :release
}
validates
:name
,
presence:
true
,
uniqueness:
{
scope: :release
}
validates
:name
,
presence:
true
,
uniqueness:
{
scope: :release
}
scope
:sorted
,
->
{
order
(
created_at: :desc
)
}
scope
:sorted
,
->
{
order
(
created_at: :desc
)
}
...
...
changelogs/unreleased/add-uniqueness-validation-to-url-column-in-releases-link-model.yml
0 → 100644
View file @
50768a25
---
title
:
Add uniqueness validation to url column in Releases::Link model
merge_request
:
24223
author
:
type
:
other
spec/models/releases/link_spec.rb
View file @
50768a25
...
@@ -31,6 +31,16 @@ describe Releases::Link do
...
@@ -31,6 +31,16 @@ describe Releases::Link do
end
.
to
raise_error
(
ActiveRecord
::
RecordInvalid
)
end
.
to
raise_error
(
ActiveRecord
::
RecordInvalid
)
end
end
end
end
context
'when duplicate url is added to a release'
do
let!
(
:link
)
{
create
(
:release_link
,
url:
'http://gitlab.com'
,
release:
release
)
}
it
'raises an error'
do
expect
do
create
(
:release_link
,
url:
'http://gitlab.com'
,
release:
release
)
end
.
to
raise_error
(
ActiveRecord
::
RecordInvalid
)
end
end
end
end
describe
'.sorted'
do
describe
'.sorted'
do
...
...
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