[ARVADOS] created: 2.1.0-1968-gdf9e445e9
Git user
git at public.arvados.org
Fri Feb 25 17:06:55 UTC 2022
at df9e445e9f663fec6e33723aa45817c2edacac3d (commit)
commit df9e445e9f663fec6e33723aa45817c2edacac3d
Author: Tom Clegg <tom at curii.com>
Date: Fri Feb 25 12:05:46 2022 -0500
18803: Save empty identity_url to database as null.
Allows multiple records to have empty identity_url without hitting
unique constraint.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index febb8ea51..811cd8975 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -21,6 +21,7 @@ class User < ArvadosModel
uniqueness: true,
allow_nil: true)
validate :must_unsetup_to_deactivate
+ validate :identity_url_nil_if_empty
before_update :prevent_privilege_escalation
before_update :prevent_inactive_admin
before_update :verify_repositories_empty, :if => Proc.new {
@@ -810,4 +811,10 @@ SELECT target_uuid, perm_level
repo.save!
end
end
+
+ def identity_url_nil_if_empty
+ if identity_url == ""
+ self.identity_url = nil
+ end
+ end
end
diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb
index 7368d8937..9a0e1dbf9 100644
--- a/services/api/test/unit/user_test.rb
+++ b/services/api/test/unit/user_test.rb
@@ -797,4 +797,12 @@ class UserTest < ActiveSupport::TestCase
assert user.save
end
+ test "empty identity_url saves as null" do
+ set_user_from_auth :admin
+ user = users(:active)
+ assert user.update_attributes(identity_url: '')
+ user.reload
+ assert_nil user.identity_url
+ end
+
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list