Merge pull request #2988 from Asquera/error_project_limit
API: creating last project before limit returns 404
This commit is contained in:
commit
b7ac654b88
2 changed files with 21 additions and 1 deletions
|
@ -146,7 +146,7 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def saved?
|
def saved?
|
||||||
id && valid?
|
id && persisted?
|
||||||
end
|
end
|
||||||
|
|
||||||
def import?
|
def import?
|
||||||
|
|
|
@ -33,6 +33,20 @@ describe Gitlab::API do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /projects" do
|
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
|
it "should create new project without path" do
|
||||||
expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1)
|
expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1)
|
||||||
end
|
end
|
||||||
|
@ -41,6 +55,12 @@ describe Gitlab::API do
|
||||||
expect { post api("/projects", user) }.to_not change {Project.count}
|
expect { post api("/projects", user) }.to_not change {Project.count}
|
||||||
end
|
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
|
it "should respond with 201 on success" do
|
||||||
post api("/projects", user), name: 'foo'
|
post api("/projects", user), name: 'foo'
|
||||||
response.status.should == 201
|
response.status.should == 201
|
||||||
|
|
Loading…
Reference in a new issue