[ARVADOS] updated: 8c021e4b54a8179e86dd887e1eb8db9ef4dd9672

git at public.curoverse.com git at public.curoverse.com
Sun Mar 23 16:52:19 EDT 2014


Summary of changes:
 services/api/test/unit/user_test.rb |  213 +++++++++++++++++------------------
 1 files changed, 106 insertions(+), 107 deletions(-)

       via  8c021e4b54a8179e86dd887e1eb8db9ef4dd9672 (commit)
      from  6a18fc0d6f3f9859e905d4762796d813a157605b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 8c021e4b54a8179e86dd887e1eb8db9ef4dd9672
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Sun Mar 23 16:51:59 2014 -0400

    Fix tabs in the test class

diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb
index c1da8fa..4695c91 100644
--- a/services/api/test/unit/user_test.rb
+++ b/services/api/test/unit/user_test.rb
@@ -2,36 +2,36 @@ require 'test_helper'
 
 class UserTest < ActiveSupport::TestCase
 
-	# The fixture services/api/test/fixtures/users.yml serves as the input for this test case
-	setup do
-		@all_users = User.find(:all)
-
-		@all_users.each do |user|
-			if user.is_admin && user.is_active 
-				@admin_user = user
-			elsif user.is_active && !user.is_admin
-				@active_user = user
-			elsif !user.is_active && !user.is_invited 
-				@uninvited_user = user
-			end
-		end
-	end
+  # The fixture services/api/test/fixtures/users.yml serves as the input for this test case
+  setup do
+    @all_users = User.find(:all)
+
+    @all_users.each do |user|
+      if user.is_admin && user.is_active 
+        @admin_user = user
+      elsif user.is_active && !user.is_admin
+        @active_user = user
+      elsif !user.is_active && !user.is_invited 
+        @uninvited_user = user
+      end
+    end
+  end
 
   test "check non-admin active user properties" do
     assert !@active_user.is_admin, 'is_admin should not be set for a non-admin user'
     assert @active_user.is_active, 'user should be active'
     assert @active_user.is_invited, 'is_invited should be set'
     assert_not_nil @active_user.prefs, "user's preferences should be non-null, but may be size zero"
-		assert (@active_user.can? :read=>"#{@active_user.uuid}"), "user should be able to read own object"
-		assert (@active_user.can? :write=>"#{@active_user.uuid}"), "user should be able to write own object"
-		assert (@active_user.can? :manage=>"#{@active_user.uuid}"), "user should be able to manage own object"
+    assert (@active_user.can? :read=>"#{@active_user.uuid}"), "user should be able to read own object"
+    assert (@active_user.can? :write=>"#{@active_user.uuid}"), "user should be able to write own object"
+    assert (@active_user.can? :manage=>"#{@active_user.uuid}"), "user should be able to manage own object"
 
-		assert @active_user.groups_i_can(:read).size > 0, "active user should be able read at least one group"
+    assert @active_user.groups_i_can(:read).size > 0, "active user should be able read at least one group"
 
     # non-admin user cannot manage or write other user objects
-		assert !(@active_user.can? :read=>"#{@uninvited_user.uuid}")
-		assert !(@active_user.can? :write=>"#{@uninvited_user.uuid}")
-		assert !(@active_user.can? :manage=>"#{@uninvited_user.uuid}")
+    assert !(@active_user.can? :read=>"#{@uninvited_user.uuid}")
+    assert !(@active_user.can? :write=>"#{@uninvited_user.uuid}")
+    assert !(@active_user.can? :manage=>"#{@uninvited_user.uuid}")
   end
 
   test "check admin user properties" do
@@ -41,123 +41,122 @@ class UserTest < ActiveSupport::TestCase
     assert_not_nil @admin_user.uuid.size, "user's uuid should be non-null"
     assert_not_nil @admin_user.prefs, "user's preferences should be non-null, but may be size zero"
     assert @admin_user.identity_url.size > 0, "user's identity url is expected"
-		assert @admin_user.can? :read=>"#{@admin_user.uuid}"
-		assert @admin_user.can? :write=>"#{@admin_user.uuid}"
-		assert @admin_user.can? :manage=>"#{@admin_user.uuid}"
+    assert @admin_user.can? :read=>"#{@admin_user.uuid}"
+    assert @admin_user.can? :write=>"#{@admin_user.uuid}"
+    assert @admin_user.can? :manage=>"#{@admin_user.uuid}"
 
-		assert @admin_user.groups_i_can(:read).size > 0, "admin active user should be able read at least one group"
-		assert @admin_user.groups_i_can(:write).size > 0, "admin active user should be able write to at least one group"
-		assert @admin_user.groups_i_can(:manage).size > 0, "admin active user should be able manage at least one group"
+    assert @admin_user.groups_i_can(:read).size > 0, "admin active user should be able read at least one group"
+    assert @admin_user.groups_i_can(:write).size > 0, "admin active user should be able write to at least one group"
+    assert @admin_user.groups_i_can(:manage).size > 0, "admin active user should be able manage at least one group"
 
     # admin user can also write or manage other users
-		assert @admin_user.can? :read=>"#{@uninvited_user.uuid}"
-		assert @admin_user.can? :write=>"#{@uninvited_user.uuid}"
-		assert @admin_user.can? :manage=>"#{@uninvited_user.uuid}"
+    assert @admin_user.can? :read=>"#{@uninvited_user.uuid}"
+    assert @admin_user.can? :write=>"#{@uninvited_user.uuid}"
+    assert @admin_user.can? :manage=>"#{@uninvited_user.uuid}"
   end
 
   test "check inactive and uninvited user properties" do
     assert !@uninvited_user.is_admin, 'is_admin should not be set for a non-admin user'
     assert !@uninvited_user.is_active, 'user should be inactive'
     assert !@uninvited_user.is_invited, 'is_invited should not be set'
-		assert @uninvited_user.can? :read=>"#{@uninvited_user.uuid}"
-		assert @uninvited_user.can? :write=>"#{@uninvited_user.uuid}"
-		assert @uninvited_user.can? :manage=>"#{@uninvited_user.uuid}"
+    assert @uninvited_user.can? :read=>"#{@uninvited_user.uuid}"
+    assert @uninvited_user.can? :write=>"#{@uninvited_user.uuid}"
+    assert @uninvited_user.can? :manage=>"#{@uninvited_user.uuid}"
 
-		assert @uninvited_user.groups_i_can(:read).size == 0, "inactive and uninvited user should not be able read any groups"
-		assert @uninvited_user.groups_i_can(:write).size == 0, "inactive and uninvited user should not be able write to any groups"
-		assert @uninvited_user.groups_i_can(:manage).size == 0, "inactive and uninvited user should not be able manage any groups"
+    assert @uninvited_user.groups_i_can(:read).size == 0, "inactive and uninvited user should not be able read any groups"
+    assert @uninvited_user.groups_i_can(:write).size == 0, "inactive and uninvited user should not be able write to any groups"
+    assert @uninvited_user.groups_i_can(:manage).size == 0, "inactive and uninvited user should not be able manage any groups"
   end
 
   test "find user method checks" do
-		User.find(:all).each do |user|
-			assert_not_nil user.uuid, "non-null uuid expected for " + user.full_name
-		end
+    User.find(:all).each do |user|
+      assert_not_nil user.uuid, "non-null uuid expected for " + user.full_name
+    end
 
-    user = users(:active) 		# get the active user
+    user = users(:active)     # get the active user
 
-		found_user = User.find(user.id)		# find a user by the row id
+    found_user = User.find(user.id)   # find a user by the row id
 
     assert_equal found_user.full_name, user.first_name + ' ' + user.last_name
     assert_equal found_user.identity_url, user.identity_url
   end
 
-	test "create new user" do 
-		Thread.current[:user] = @admin_user 	# set admin user as the current user
-
-		user = User.new
-		user.first_name = "first_name_for_newly_created_user"
-		user.save
-
-		# verify there is one extra user in the db now
-		assert (User.find(:all).size == @all_users.size+1)
-
-		user = User.find(user.id)		# get the user back
-		assert_equal(user.first_name, 'first_name_for_newly_created_user')
-		assert_not_nil user.uuid, 'uuid should be set for newly created user'
-		assert_nil user.email, 'email should be null for newly created user, because it was not passed in'
-		assert_nil user.identity_url, 'identity_url should be null for newly created user, because it was not passed in'
-
-		user.first_name = 'first_name_for_newly_created_user_updated'
-		user.save
-		user = User.find(user.id)		# get the user back
-		assert_equal(user.first_name, 'first_name_for_newly_created_user_updated')
-	end
-
-	test "update existing user" do 
-		Thread.current[:user] = @active_user 		# set active user as current user
-		@active_user.first_name = "first_name_changed"
-		@active_user.save
-
-		@active_user = User.find(@active_user.id)		# get the user back
-		assert_equal(@active_user.first_name, 'first_name_changed')
-
-		# admin user also should be able to update the "active" user info
-		Thread.current[:user] = @admin_user # set admin user as current user
-		@active_user.first_name = "first_name_changed_by_admin_for_active_user"
-		@active_user.save
-
-		@active_user = User.find(@active_user.id)		# get the user back
-		assert_equal(@active_user.first_name, 'first_name_changed_by_admin_for_active_user')
-	end
-	
-	test "delete a user and verify" do 
-		active_user_uuid = @active_user.uuid
-
-		Thread.current[:user] = @admin_user 		
-		@active_user.delete
-
-		found_deleted_user = false
-		User.find(:all).each do |user| 
-			if user.uuid == active_user_uuid 
-				found_deleted_user = true
-				break
-			end			
-		end
-		assert !found_deleted_user, "found deleted user: "+active_user_uuid
-	
-	end
-
-	test "create new user as non-admin user" do
-		Thread.current[:user] = @active_user
+  test "create new user" do 
+    Thread.current[:user] = @admin_user   # set admin user as the current user
+
+    user = User.new
+    user.first_name = "first_name_for_newly_created_user"
+    user.save
+
+    # verify there is one extra user in the db now
+    assert (User.find(:all).size == @all_users.size+1)
+
+    user = User.find(user.id)   # get the user back
+    assert_equal(user.first_name, 'first_name_for_newly_created_user')
+    assert_not_nil user.uuid, 'uuid should be set for newly created user'
+    assert_nil user.email, 'email should be null for newly created user, because it was not passed in'
+    assert_nil user.identity_url, 'identity_url should be null for newly created user, because it was not passed in'
+
+    user.first_name = 'first_name_for_newly_created_user_updated'
+    user.save
+    user = User.find(user.id)   # get the user back
+    assert_equal(user.first_name, 'first_name_for_newly_created_user_updated')
+  end
+
+  test "update existing user" do 
+    Thread.current[:user] = @active_user    # set active user as current user
+    @active_user.first_name = "first_name_changed"
+    @active_user.save
+
+    @active_user = User.find(@active_user.id)   # get the user back
+    assert_equal(@active_user.first_name, 'first_name_changed')
+
+    # admin user also should be able to update the "active" user info
+    Thread.current[:user] = @admin_user # set admin user as current user
+    @active_user.first_name = "first_name_changed_by_admin_for_active_user"
+    @active_user.save
+
+    @active_user = User.find(@active_user.id)   # get the user back
+    assert_equal(@active_user.first_name, 'first_name_changed_by_admin_for_active_user')
+  end
+  
+  test "delete a user and verify" do 
+    active_user_uuid = @active_user.uuid
+
+    Thread.current[:user] = @admin_user     
+    @active_user.delete
+
+    found_deleted_user = false
+    User.find(:all).each do |user| 
+      if user.uuid == active_user_uuid 
+        found_deleted_user = true
+        break
+      end     
+    end
+    assert !found_deleted_user, "found deleted user: "+active_user_uuid
+  
+  end
+
+  test "create new user as non-admin user" do
+    Thread.current[:user] = @active_user
 
     begin
-  		user = User.new
-	  	user.save
+      user = User.new
+      user.save
     rescue ArvadosModel::PermissionDeniedError
     end
-	end
+  end
 
-	test "setup new user as non-admin user" do
-		Thread.current[:user] = @active_user
+  test "setup new user as non-admin user" do
+    Thread.current[:user] = @active_user
 
     begin
       user = User.new
       user.email = 'abc at xyz.com'
-  		
+      
       User.setup user, 'http://openid/prefix'
     rescue ArvadosModel::PermissionDeniedError
     end
-	end
+  end
 
 end
-

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list