Fix a nil check
[arvados.git] / services / api / test / functional / arvados / v1 / users_controller_test.rb
index 6d129d898fc370d0f8b02d0276f7ecfbcf5fd082..4e04363f3087dc0a7ce665b75ab5734ae81299d5 100644 (file)
@@ -38,4 +38,40 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_equal true, me['is_active']
   end
 
+  test "create new user" do
+    authorize_with :admin
+    post :create, user: {
+      first_name: "test_first_name",
+      last_name: "test_last_name",
+                       email: "test@abc.com"
+    }
+    assert_response :success
+    created = JSON.parse(@response.body)
+    assert_equal 'test_first_name', created['first_name']
+    assert_not_nil created['uuid'], 'expected non-null uuid for the newly created user'
+    assert_not_nil created['email'], 'since email was given, expected non-nil email'
+    assert_nil created['identity_url'], 'even though email is provided, expected no identity_url since users_controller only creates user at this time'
+  end
+
+       test "create user with vm and repo" do
+    authorize_with :admin
+
+    post :create, {
+      repo_name: 'test_repo',
+                       vm_uuid: 'abcdefg',
+      user: {
+                   uuid: "shouldnotbeused",                
+                               first_name: "in_create_test_first_name",
+                   last_name: "test_last_name",
+                               email: "test@abc.com"
+      }
+    }
+    assert_response :success
+    created = JSON.parse(@response.body)
+    assert_equal 'in_create_test_first_name', created['first_name']
+    assert_not_nil created['uuid'], 'expected non-null uuid for the newly created user'
+    assert_not_nil created['email'], 'since email was given, expected non-nil email'
+    assert_nil created['identity_url'], 'even though email is provided, expected no identity_url since users_controller only creates user' 
+       end
+
 end