Commit 1a01fc0c964defe60c9dc99fa2b5fa0387f3246a

Authored by Sebastian Ziebell
1 parent 6b24c375

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.
Showing 1 changed file with 20 additions and 0 deletions   Show diff stats
spec/requests/api/projects_spec.rb
... ... @@ -33,6 +33,20 @@ describe Gitlab::API do
33 33 end
34 34  
35 35 describe "POST /projects" do
  36 + context "maximum number of projects reached" do
  37 + before do
  38 + (1..user2.projects_limit).each do |project|
  39 + post api("/projects", user2), name: "foo#{project}"
  40 + end
  41 + end
  42 +
  43 + it "should not create new project" do
  44 + expect {
  45 + post api("/projects", user2), name: 'foo'
  46 + }.to change {Project.count}.by(0)
  47 + end
  48 + end
  49 +
36 50 it "should create new project without path" do
37 51 expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1)
38 52 end
... ... @@ -41,6 +55,12 @@ describe Gitlab::API do
41 55 expect { post api("/projects", user) }.to_not change {Project.count}
42 56 end
43 57  
  58 + it "should create last project before reaching project limit" do
  59 + (1..user2.projects_limit-1).each { |p| post api("/projects", user2), name: "foo#{p}" }
  60 + post api("/projects", user2), name: "foo"
  61 + response.status.should == 201
  62 + end
  63 +
44 64 it "should respond with 201 on success" do
45 65 post api("/projects", user), name: 'foo'
46 66 response.status.should == 201
... ...