Make snippet filename optional.

Fixes #2384.
This commit is contained in:
Nicolas 2015-06-12 16:15:44 +02:00
parent e9c40a9c0f
commit aecc989154
3 changed files with 1 additions and 3 deletions

View File

@ -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 }

View File

@ -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'

View File

@ -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) }