summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-05-25 20:38:14 +0000
committerRobert Speicher <robert@gitlab.com>2016-05-25 20:38:14 +0000
commit380966e861a3c0cfc1d2884939c6677599690206 (patch)
tree111c576974f92aa81bb59df7080c94b2d2ce4d6d
parent49343f9a31ffdcf4ff238189bbf58e581e41d102 (diff)
parent497a28c59f042fcce36d1d0682cf225c9743369f (diff)
downloadgitlab-ce-380966e861a3c0cfc1d2884939c6677599690206.tar.gz
Merge branch 'zero-project-creation-error-message' into 'master'
Updated error message when project limit is zero When the project limit is zero & the user tries to create a project, the error displayed is now 'Personal project creation is not allowed. Please contact your administrator with questions' Closes #17691 See merge request !4280
-rw-r--r--app/models/project.rb8
-rw-r--r--spec/models/project_spec.rb2
2 files changed, 8 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 37de1dfe4d5..f3a56b86d5a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -431,7 +431,13 @@ class Project < ActiveRecord::Base
def check_limit
unless creator.can_create_project? or namespace.kind == 'group'
- self.errors.add(:limit_reached, "Your project limit is #{creator.projects_limit} projects! Please contact your administrator to increase it")
+ projects_limit = creator.projects_limit
+
+ if projects_limit == 0
+ self.errors.add(:limit_reached, "Personal project creation is not allowed. Please contact your administrator with questions")
+ else
+ self.errors.add(:limit_reached, "Your project limit is #{projects_limit} projects! Please contact your administrator to increase it")
+ end
end
rescue
self.errors.add(:base, "Can't check your ability to create project")
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 4d36a539a69..6c1b0393682 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -60,7 +60,7 @@ describe Project, models: true do
project2 = build(:project)
allow(project2).to receive(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object)
expect(project2).not_to be_valid
- expect(project2.errors[:limit_reached].first).to match(/Your project limit is 0/)
+ expect(project2.errors[:limit_reached].first).to match(/Personal project creation is not allowed/)
end
end