Commit bda0a75581d29cd0afb74a8a34ca69e75ab1c352

Authored by Valeriy Sizov
1 parent 705e9f40

#1585 Api for user creation: rspec

Showing 1 changed file with 21 additions and 0 deletions   Show diff stats
spec/requests/api/users_spec.rb
... ... @@ -4,6 +4,7 @@ describe Gitlab::API do
4 4 include ApiHelpers
5 5  
6 6 let(:user) { Factory :user }
  7 + let(:admin) {Factory :admin}
7 8 let(:key) { Factory :key, user: user }
8 9  
9 10 describe "GET /users" do
... ... @@ -32,6 +33,26 @@ describe Gitlab::API do
32 33 end
33 34 end
34 35  
  36 + describe "POST /users" do
  37 + before{ admin }
  38 +
  39 + it "should not create invalid user" do
  40 + post api("/users", admin), { email: "invalid email" }
  41 + response.status.should == 404
  42 + end
  43 +
  44 + it "should create user" do
  45 + expect{
  46 + post api("/users", admin), Factory.attributes(:user)
  47 + }.to change{User.count}.by(1)
  48 + end
  49 +
  50 + it "shouldn't available for non admin users" do
  51 + post api("/users", user), Factory.attributes(:user)
  52 + response.status.should == 403
  53 + end
  54 + end
  55 +
35 56 describe "GET /user" do
36 57 it "should return current user" do
37 58 get api("/user", user)
... ...