summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas <nicolas@gitlab.com>2015-06-12 16:15:44 +0200
committerNicolas <nicolas@gitlab.com>2015-06-20 01:06:57 +0200
commitaecc989154ccb3cf044cff0341c0b7c195a9a572 (patch)
treeb9ca81b631342c61636a2cc908b4ecaa8c3be885
parente9c40a9c0f306c1600312e5a82ba657c84ecbca8 (diff)
downloadgitlab-ce-aecc989154ccb3cf044cff0341c0b7c195a9a572.tar.gz
Make snippet filename optional.
Fixes #2384.
-rw-r--r--app/models/snippet.rb1
-rw-r--r--app/views/shared/snippets/_form.html.haml2
-rw-r--r--spec/models/snippet_spec.rb1
3 files changed, 1 insertions, 3 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 3ab9e834c63..b0831982aa7 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -34,7 +34,6 @@ class Snippet < ActiveRecord::Base
validates :author, presence: true
validates :title, presence: true, length: { within: 0..255 }
validates :file_name,
- presence: true,
length: { within: 0..255 },
format: { with: Gitlab::Regex.file_name_regex,
message: Gitlab::Regex.file_name_regex_message }
diff --git a/app/views/shared/snippets/_form.html.haml b/app/views/shared/snippets/_form.html.haml
index 2feeeecc48b..6b136302b65 100644
--- a/app/views/shared/snippets/_form.html.haml
+++ b/app/views/shared/snippets/_form.html.haml
@@ -18,7 +18,7 @@
.col-sm-10
.file-holder.snippet
.file-title
- = f.text_field :file_name, placeholder: "example.rb", class: 'form-control snippet-file-name', required: true
+ = f.text_field :file_name, placeholder: "Optionally name this file to add code highlighting, e.g. example.rb for Ruby.", class: 'form-control snippet-file-name'
.file-content.code
%pre#editor= @snippet.content
= f.hidden_field :content, class: 'snippet-file-content'
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
index c786d0bf103..81581838675 100644
--- a/spec/models/snippet_spec.rb
+++ b/spec/models/snippet_spec.rb
@@ -40,7 +40,6 @@ describe Snippet do
it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_length_of(:title).is_within(0..255) }
- it { is_expected.to validate_presence_of(:file_name) }
it { is_expected.to validate_length_of(:file_name).is_within(0..255) }
it { is_expected.to validate_presence_of(:content) }