Commit c0df5ff1 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'snippet_optional_filename' into 'master'

Make snippet filename optional.

Fixes #2384.

See merge request !1866
parents 473fb23a aecc9891
...@@ -34,7 +34,6 @@ class Snippet < ActiveRecord::Base ...@@ -34,7 +34,6 @@ class Snippet < ActiveRecord::Base
validates :author, presence: true validates :author, presence: true
validates :title, presence: true, length: { within: 0..255 } validates :title, presence: true, length: { within: 0..255 }
validates :file_name, validates :file_name,
presence: true,
length: { within: 0..255 }, length: { within: 0..255 },
format: { with: Gitlab::Regex.file_name_regex, format: { with: Gitlab::Regex.file_name_regex,
message: Gitlab::Regex.file_name_regex_message } message: Gitlab::Regex.file_name_regex_message }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
.col-sm-10 .col-sm-10
.file-holder.snippet .file-holder.snippet
.file-title .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 .file-content.code
%pre#editor= @snippet.content %pre#editor= @snippet.content
= f.hidden_field :content, class: 'snippet-file-content' = f.hidden_field :content, class: 'snippet-file-content'
......
...@@ -40,7 +40,6 @@ describe Snippet do ...@@ -40,7 +40,6 @@ describe Snippet do
it { is_expected.to validate_presence_of(:title) } 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_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_length_of(:file_name).is_within(0..255) }
it { is_expected.to validate_presence_of(:content) } it { is_expected.to validate_presence_of(:content) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment