When using user_param, the user object is not expected. If passed, it will be discarded.
authorradhika chippada <radhika@radhika.curoverse>
Wed, 19 Mar 2014 16:00:10 +0000 (12:00 -0400)
committerradhika chippada <radhika@radhika.curoverse>
Wed, 19 Mar 2014 16:00:10 +0000 (12:00 -0400)
services/api/app/controllers/arvados/v1/users_controller.rb
services/api/test/functional/arvados/v1/users_controller_test.rb

index ebb5203ee70597bf8862a607ba58139b47b7ab6d..a929476a2b1b5d9cf855253d0b07059b72d64f2c 100644 (file)
@@ -109,6 +109,7 @@ class Arvados::V1::UsersController < ApplicationController
                  end
 
                        if !@object_found
+                               @object = User.new              # when user_param is used, it will be used as user object
                                @object[:email] = params[:user_param]                           
                        need_to_create = true
                        else
index 379db9b4f519d8da7451629b9e9d4b0fce3d1011..b7ad8ddd827d7de6abe51d83f833deae90a517f8 100644 (file)
@@ -162,6 +162,24 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_equal response_object['email'], 'abc@xyz.com', 'expecting given email'
        end
 
+       test "create user with user_param and user which will be ignored" do
+    authorize_with :admin
+
+    post :create, {
+      user_param: 'abc@xyz.com',
+      repo_name: 'test_repo',
+                       vm_uuid: 'no_such_vm',
+      user: {
+                               email: 'will_be_ignored@xyz.om'
+                       }
+    }
+
+    assert_response :success
+    response_object = JSON.parse(@response.body)
+    assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
+    assert_equal response_object['email'], 'abc@xyz.com', 'expecting user_param as email'
+       end
+
        test "create user with valid email user_param, vm and repo as input with opt.n" do
     authorize_with :admin