summaryrefslogtreecommitdiff
path: root/spec/requests/api/users_spec.rb
diff options
context:
space:
mode:
authorValeriy Sizov <vsv2711@gmail.com>2012-10-02 13:59:22 +0300
committerValeriy Sizov <vsv2711@gmail.com>2012-10-02 13:59:22 +0300
commitbda0a75581d29cd0afb74a8a34ca69e75ab1c352 (patch)
tree81bef1f1a9f8dbbb792f8cf19b62042bc3f94eed /spec/requests/api/users_spec.rb
parent705e9f402ed4601e502e51b46a181e3701490321 (diff)
downloadgitlab-ce-bda0a75581d29cd0afb74a8a34ca69e75ab1c352.tar.gz
#1585 Api for user creation: rspec
Diffstat (limited to 'spec/requests/api/users_spec.rb')
-rw-r--r--spec/requests/api/users_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 243f70f5230..e3049e09016 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -4,6 +4,7 @@ describe Gitlab::API do
include ApiHelpers
let(:user) { Factory :user }
+ let(:admin) {Factory :admin}
let(:key) { Factory :key, user: user }
describe "GET /users" do
@@ -32,6 +33,26 @@ describe Gitlab::API do
end
end
+ describe "POST /users" do
+ before{ admin }
+
+ it "should not create invalid user" do
+ post api("/users", admin), { email: "invalid email" }
+ response.status.should == 404
+ end
+
+ it "should create user" do
+ expect{
+ post api("/users", admin), Factory.attributes(:user)
+ }.to change{User.count}.by(1)
+ end
+
+ it "shouldn't available for non admin users" do
+ post api("/users", user), Factory.attributes(:user)
+ response.status.should == 403
+ end
+ end
+
describe "GET /user" do
it "should return current user" do
get api("/user", user)