Commit 7825830ca51dc7bf84ca6216c3b66e3ce1c63c44
1 parent
a36195bd
Exists in
master
and in
4 other branches
Allow project name, path etc start with number. Fixed specs
Showing
4 changed files
with
11 additions
and
10 deletions
Show diff stats
app/models/project.rb
| ... | ... | @@ -73,11 +73,11 @@ class Project < ActiveRecord::Base |
| 73 | 73 | validates :description, length: { within: 0..2000 } |
| 74 | 74 | validates :name, presence: true, length: { within: 0..255 }, |
| 75 | 75 | format: { with: Gitlab::Regex.project_name_regex, |
| 76 | - message: "only letters, digits, spaces & '_' '-' '.' allowed. Letter should be first" } | |
| 76 | + message: "only letters, digits, spaces & '_' '-' '.' allowed. Letter or digit should be first" } | |
| 77 | 77 | validates :path, presence: true, length: { within: 0..255 }, |
| 78 | 78 | exclusion: { in: Gitlab::Blacklist.path }, |
| 79 | 79 | format: { with: Gitlab::Regex.path_regex, |
| 80 | - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | |
| 80 | + message: "only letters, digits & '_' '-' '.' allowed. Letter or digit should be first" } | |
| 81 | 81 | validates :issues_enabled, :wall_enabled, :merge_requests_enabled, |
| 82 | 82 | :wiki_enabled, inclusion: { in: [true, false] } |
| 83 | 83 | validates :issues_tracker_id, length: { within: 0..255 } | ... | ... |
lib/gitlab/regex.rb
| ... | ... | @@ -7,7 +7,7 @@ module Gitlab |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | def project_name_regex |
| 10 | - /\A[a-zA-Z][a-zA-Z0-9_\-\. ]*\z/ | |
| 10 | + /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/ | |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | def name_regex |
| ... | ... | @@ -21,7 +21,7 @@ module Gitlab |
| 21 | 21 | protected |
| 22 | 22 | |
| 23 | 23 | def default_regex |
| 24 | - /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/ | |
| 24 | + /\A[a-zA-Z0-9][a-zA-Z0-9_\-\.]*\z/ | |
| 25 | 25 | end |
| 26 | 26 | end |
| 27 | 27 | end | ... | ... |
spec/models/commit_spec.rb
| ... | ... | @@ -9,11 +9,11 @@ describe Commit do |
| 9 | 9 | commit.title.should == "--no commit message" |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | - it "truncates a message without a newline at 70 characters" do | |
| 12 | + it "truncates a message without a newline at 80 characters" do | |
| 13 | 13 | message = commit.safe_message * 10 |
| 14 | 14 | |
| 15 | 15 | commit.stub(:safe_message).and_return(message) |
| 16 | - commit.title.should == "#{message[0..69]}…" | |
| 16 | + commit.title.should == "#{message[0..79]}…" | |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | it "truncates a message with a newline before 80 characters at the newline" do |
| ... | ... | @@ -27,7 +27,7 @@ describe Commit do |
| 27 | 27 | message = (commit.safe_message * 10) + "\n" |
| 28 | 28 | |
| 29 | 29 | commit.stub(:safe_message).and_return(message) |
| 30 | - commit.title.should == "#{message[0..69]}…" | |
| 30 | + commit.title.should == "#{message[0..79]}…" | |
| 31 | 31 | end |
| 32 | 32 | end |
| 33 | 33 | ... | ... |
spec/models/project_spec.rb
| ... | ... | @@ -68,9 +68,10 @@ describe Project do |
| 68 | 68 | it { should ensure_length_of(:issues_tracker_id).is_within(0..255) } |
| 69 | 69 | |
| 70 | 70 | it "should not allow new projects beyond user limits" do |
| 71 | - project.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 1)) | |
| 72 | - project.should_not be_valid | |
| 73 | - project.errors[:limit_reached].first.should match(/Your own projects limit is 1/) | |
| 71 | + project2 = build(:project) | |
| 72 | + project2.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 0)) | |
| 73 | + project2.should_not be_valid | |
| 74 | + project2.errors[:limit_reached].first.should match(/Your own projects limit is 0/) | |
| 74 | 75 | end |
| 75 | 76 | end |
| 76 | 77 | ... | ... |