Commit 7825830c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Allow project name, path etc start with number. Fixed specs

parent a36195bd
......@@ -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 }
......
......@@ -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
......@@ -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]}&hellip;"
commit.title.should == "#{message[0..79]}&hellip;"
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]}&hellip;"
commit.title.should == "#{message[0..79]}&hellip;"
end
end
......
......@@ -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
......
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