Commit bda0a755 authored by Valeriy Sizov's avatar Valeriy Sizov

#1585 Api for user creation: rspec

parent 705e9f40
...@@ -4,6 +4,7 @@ describe Gitlab::API do ...@@ -4,6 +4,7 @@ describe Gitlab::API do
include ApiHelpers include ApiHelpers
let(:user) { Factory :user } let(:user) { Factory :user }
let(:admin) {Factory :admin}
let(:key) { Factory :key, user: user } let(:key) { Factory :key, user: user }
describe "GET /users" do describe "GET /users" do
...@@ -32,6 +33,26 @@ describe Gitlab::API do ...@@ -32,6 +33,26 @@ describe Gitlab::API do
end end
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 describe "GET /user" do
it "should return current user" do it "should return current user" do
get api("/user", user) get api("/user", user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment