Commit b7ac654b88aa9b03f431d93c25e397ff2bc66a7a
Exists in
master
and in
4 other branches
Merge pull request #2988 from Asquera/error_project_limit
API: creating last project before limit returns 404
Showing
2 changed files
with
21 additions
and
1 deletions
Show diff stats
app/models/project.rb
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 | ... | ... |