diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-08-13 12:24:10 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-08-13 12:24:10 +0300 |
commit | 7825830ca51dc7bf84ca6216c3b66e3ce1c63c44 (patch) | |
tree | 17f05aaab8b6178ce20213447f3cea64722dceed | |
parent | a36195bd2853bfef1b6883eef64334767e12fcf1 (diff) | |
download | gitlab-ce-7825830ca51dc7bf84ca6216c3b66e3ce1c63c44.tar.gz |
Allow project name, path etc start with number. Fixed specs
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/regex.rb | 4 | ||||
-rw-r--r-- | spec/models/commit_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 7 |
4 files changed, 11 insertions, 10 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 096b65587c9..8f9464b5652 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -73,11 +73,11 @@ class Project < ActiveRecord::Base validates :description, length: { within: 0..2000 } validates :name, presence: true, length: { within: 0..255 }, format: { with: Gitlab::Regex.project_name_regex, - message: "only letters, digits, spaces & '_' '-' '.' allowed. Letter should be first" } + message: "only letters, digits, spaces & '_' '-' '.' allowed. Letter or digit should be first" } validates :path, presence: true, length: { within: 0..255 }, exclusion: { in: Gitlab::Blacklist.path }, format: { with: Gitlab::Regex.path_regex, - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } + message: "only letters, digits & '_' '-' '.' allowed. Letter or digit should be first" } validates :issues_enabled, :wall_enabled, :merge_requests_enabled, :wiki_enabled, inclusion: { in: [true, false] } validates :issues_tracker_id, length: { within: 0..255 } diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 5eeb7c80184..b4be46d3b42 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -7,7 +7,7 @@ module Gitlab end def project_name_regex - /\A[a-zA-Z][a-zA-Z0-9_\-\. ]*\z/ + /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/ end def name_regex @@ -21,7 +21,7 @@ module Gitlab protected def default_regex - /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/ + /\A[a-zA-Z0-9][a-zA-Z0-9_\-\.]*\z/ end end end diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index b84f24bf3ad..73418efd3f2 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -9,11 +9,11 @@ describe Commit do commit.title.should == "--no commit message" end - it "truncates a message without a newline at 70 characters" do + it "truncates a message without a newline at 80 characters" do message = commit.safe_message * 10 commit.stub(:safe_message).and_return(message) - commit.title.should == "#{message[0..69]}…" + commit.title.should == "#{message[0..79]}…" end it "truncates a message with a newline before 80 characters at the newline" do @@ -27,7 +27,7 @@ describe Commit do message = (commit.safe_message * 10) + "\n" commit.stub(:safe_message).and_return(message) - commit.title.should == "#{message[0..69]}…" + commit.title.should == "#{message[0..79]}…" end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 65acf0c2498..05a54f760f1 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -68,9 +68,10 @@ describe Project do it { should ensure_length_of(:issues_tracker_id).is_within(0..255) } it "should not allow new projects beyond user limits" do - project.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 1)) - project.should_not be_valid - project.errors[:limit_reached].first.should match(/Your own projects limit is 1/) + project2 = build(:project) + project2.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 0)) + project2.should_not be_valid + project2.errors[:limit_reached].first.should match(/Your own projects limit is 0/) end end |