Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-12-07 13:31:21 +0300
committerRémy Coutable <remy@rymai.me>2016-12-07 13:31:21 +0300
commit5186618bb0220383ae4668b7d023bfbbb52c8948 (patch)
tree50364478658b52192e16fabec2a7326c827b28e4 /app/models/snippet.rb
parent9f8a389ac6c2065e8b4fdf174af18c93ba398d25 (diff)
parent4e249d5baea99a52915025fc2827d01ab2d77c18 (diff)
Merge branch '25209-improve-length-validators' into 'master'
Use :maximum instead of :within for length validators with a 0..N range Closes #25209 See merge request !7894
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index aa2e3a1ff18..98ccf5f331f 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -27,9 +27,9 @@ class Snippet < ActiveRecord::Base
delegate :name, :email, to: :author, prefix: true, allow_nil: true
validates :author, presence: true
- validates :title, presence: true, length: { within: 0..255 }
+ validates :title, presence: true, length: { maximum: 255 }
validates :file_name,
- length: { within: 0..255 },
+ length: { maximum: 255 },
format: { with: Gitlab::Regex.file_name_regex,
message: Gitlab::Regex.file_name_regex_message }
@@ -94,6 +94,10 @@ class Snippet < ActiveRecord::Base
0
end
+ def file_name
+ super.to_s
+ end
+
# alias for compatibility with blobs and highlighting
def path
file_name