diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-07 10:57:24 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-07 10:57:24 +0400 |
commit | 7c408960ce9cf8a20941c99fd64aa5b1f472f9a0 (patch) | |
tree | 7e81d11387865cd41279c6ba2672c019e1550052 /spec/requests/api/projects_spec.rb | |
parent | 52bf5b0e78edeb1acc8254b00ba164d48a88f39e (diff) | |
parent | 47abdc10ca7daceac8206a65166b42409a76b459 (diff) |
Merge pull request #3146 from amacarthur/AdminAPIs
Additional Admin APIs
Diffstat (limited to 'spec/requests/api/projects_spec.rb')
-rw-r--r-- | spec/requests/api/projects_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 422ccbf6f68..72f93c46ce4 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -6,6 +6,7 @@ describe Gitlab::API do let(:user) { create(:user) } let(:user2) { create(:user) } let(:user3) { create(:user) } + let(:admin) { create(:admin) } let!(:hook) { create(:project_hook, project: project, url: "http://example.com") } let!(:project) { create(:project, namespace: user.namespace ) } let!(:snippet) { create(:snippet, author: user, project: project, title: 'example') } @@ -92,6 +93,46 @@ describe Gitlab::API do end end + describe "POST /projects/user/:id" do + before { admin } + + it "should create new project without path" do + expect { post api("/projects/user/#{user.id}", admin), name: 'foo' }.to change {Project.count}.by(1) + end + + it "should not create new project without name" do + expect { post api("/projects/user/#{user.id}", admin) }.to_not change {Project.count} + end + + it "should respond with 201 on success" do + post api("/projects/user/#{user.id}", admin), name: 'foo' + response.status.should == 201 + end + + it "should respond with 404 on failure" do + post api("/projects/user/#{user.id}", admin) + response.status.should == 404 + end + + it "should assign attributes to project" do + project = attributes_for(:project, { + description: Faker::Lorem.sentence, + default_branch: 'stable', + issues_enabled: false, + wall_enabled: false, + merge_requests_enabled: false, + wiki_enabled: false + }) + + post api("/projects/user/#{user.id}", admin), project + + project.each_pair do |k,v| + next if k == :path + json_response[k.to_s].should == v + end + end + end + describe "GET /projects/:id" do it "should return a project by id" do get api("/projects/#{project.id}", user) |