From 6df02adc7a5cb7badf748be783f9a552cf19aeee Mon Sep 17 00:00:00 2001 From: Sebastian Ziebell Date: Thu, 14 Feb 2013 15:51:56 +0100 Subject: API: status code 403 returned if new project would exceed limit When the project limit is reached the user is not allowed to create new ones. Instead of error code 404 the status code 403 (Forbidden) is returned with error message via API. --- spec/requests/api/projects_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec/requests') diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index de1b1b09e5f..b635307884b 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -41,6 +41,11 @@ describe Gitlab::API do expect { post api("/projects", user) }.to_not change {Project.count} end + it "should return a 400 error if name not given" do + post api("/projects", user) + response.status.should == 400 + end + it "should respond with 201 on success" do post api("/projects", user), name: 'foo' response.status.should == 201 @@ -51,6 +56,14 @@ describe Gitlab::API do response.status.should == 400 end + it "should return a 403 error if project limit reached" do + (1..user.projects_limit).each do |p| + post api("/projects", user), name: "foo#{p}" + end + post api("/projects", user), name: 'bar' + response.status.should == 403 + end + it "should assign attributes to project" do project = attributes_for(:project, { description: Faker::Lorem.sentence, -- cgit v1.2.1