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
143ea1da
Commit
143ea1da
authored
Jun 02, 2020
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add model validation to Design to limit filename
https://gitlab.com/gitlab-org/gitlab/-/issues/209025
parent
874dc402
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
1 deletion
+2
-1
app/models/design_management/design.rb
app/models/design_management/design.rb
+1
-1
spec/models/design_management/design_spec.rb
spec/models/design_management/design_spec.rb
+1
-0
No files found.
app/models/design_management/design.rb
View file @
143ea1da
...
...
@@ -22,7 +22,7 @@ module DesignManagement
validates
:project
,
:filename
,
presence:
true
validates
:issue
,
presence:
true
,
unless: :importing?
validates
:filename
,
uniqueness:
{
scope: :issue_id
}
validates
:filename
,
uniqueness:
{
scope: :issue_id
}
,
length:
{
maximum:
255
}
validate
:validate_file_is_image
alias_attribute
:title
,
:filename
...
...
spec/models/design_management/design_spec.rb
View file @
143ea1da
...
...
@@ -27,6 +27,7 @@ describe DesignManagement::Design do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:issue
)
}
it
{
is_expected
.
to
validate_presence_of
(
:filename
)
}
it
{
is_expected
.
to
validate_length_of
(
:filename
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:filename
).
scoped_to
(
:issue_id
)
}
it
"validates that the extension is an image"
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