Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAngus MacArthur <amacarthur@rim.com>2012-11-15 00:37:52 +0400
committerAngus MacArthur <amacarthur@blackberry.com>2013-03-05 19:38:43 +0400
commit61ffcab60fef2efcd54b8496aa09de79ee999a2c (patch)
tree7a493e25800421cdb94607b52836d50274d5c0f7 /spec
parentd5663e148fdf8d1c767479e62c86c7a2b4db654e (diff)
Additional Admin APIs
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/groups_spec.rb23
-rw-r--r--spec/requests/api/projects_spec.rb41
-rw-r--r--spec/requests/api/users_spec.rb16
3 files changed, 80 insertions, 0 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index c39a4228408..63616eef1bb 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -90,4 +90,27 @@ describe Gitlab::API do
end
end
end
+
+ describe "POST /groups/:id/projects/:project_id" do
+ let(:project) { create(:project) }
+ before(:each) do
+ project.stub!(:transfer).and_return(true)
+ Project.stub(:find).and_return(project)
+ end
+
+
+ context "when authenticated as user" do
+ it "should not transfer project to group" do
+ post api("/groups/#{group1.id}/projects/#{project.id}", user2)
+ response.status.should == 403
+ end
+ end
+
+ context "when authenticated as admin" do
+ it "should transfer project to group" do
+ project.should_receive(:transfer)
+ post api("/groups/#{group1.id}/projects/#{project.id}", admin)
+ end
+ end
+ end
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index d410885bd22..d64ed58348b 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') }
@@ -90,6 +91,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)
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 33254eed31c..e6ac892dfc4 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -105,6 +105,22 @@ describe Gitlab::API do
end
end
+ describe "POST /users/:id/keys" do
+ before { admin }
+
+ it "should not create invalid ssh key" do
+ post api("/users/#{user.id}/keys", admin), { title: "invalid key" }
+ response.status.should == 404
+ end
+
+ it "should create ssh key" do
+ key_attrs = attributes_for :key
+ expect {
+ post api("/users/#{user.id}/keys", admin), key_attrs
+ }.to change{ user.keys.count }.by(1)
+ end
+ end
+
describe "DELETE /users/:id" do
before { admin }