summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Ziebell <sebastian.ziebell@asquera.de>2013-02-13 17:45:05 +0100
committerSebastian Ziebell <sebastian.ziebell@asquera.de>2013-02-14 11:13:25 +0100
commit1a01fc0c964defe60c9dc99fa2b5fa0387f3246a (patch)
tree2483ec3989c377bd5184e4292bf2760c06ddabbb
parent6b24c375cbf39ad407b504d1ac386566a1571c76 (diff)
downloadgitlab-ce-1a01fc0c964defe60c9dc99fa2b5fa0387f3246a.tar.gz
API: tests to show incorrect behavior when reaching project limit
When reaching the project limit the API returns an error code 404 on the last possible project. The project itself is created and is available in the database (seems valid). A similar behavior can be observed when reaching the project limit via web client, but in this case the user is notified that the maximum number of projects is reached. The project itself is still created and can be accessed. Tests are added to check the behavior when reaching the project limit or one tries to exceed it via the API.
-rw-r--r--spec/requests/api/projects_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 16fd1b9307c..3256cde6b82 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -33,6 +33,20 @@ describe Gitlab::API do
end
describe "POST /projects" do
+ context "maximum number of projects reached" do
+ before do
+ (1..user2.projects_limit).each do |project|
+ post api("/projects", user2), name: "foo#{project}"
+ end
+ end
+
+ it "should not create new project" do
+ expect {
+ post api("/projects", user2), name: 'foo'
+ }.to change {Project.count}.by(0)
+ end
+ end
+
it "should create new project without path" do
expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1)
end
@@ -41,6 +55,12 @@ describe Gitlab::API do
expect { post api("/projects", user) }.to_not change {Project.count}
end
+ it "should create last project before reaching project limit" do
+ (1..user2.projects_limit-1).each { |p| post api("/projects", user2), name: "foo#{p}" }
+ post api("/projects", user2), name: "foo"
+ response.status.should == 201
+ end
+
it "should respond with 201 on success" do
post api("/projects", user), name: 'foo'
response.status.should == 201