21815: Remove UUID and hash columns from trigram indexes
[arvados.git] / services / api / test / test_helper.rb
index 843d4f1b23fccfb8777883c3021ab54187b3cf57..e0b1068a7ac8a8e30dcc3d1662222a0a372b96ab 100644 (file)
@@ -2,7 +2,7 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-require 'update_permissions'
+require_relative '../lib/update_permissions'
 
 ENV["RAILS_ENV"] = "test"
 unless ENV["NO_COVERAGE_TEST"]
@@ -49,6 +49,44 @@ module ArvadosTestSupport
     {'HTTP_AUTHORIZATION' => "Bearer #{api_token(api_client_auth_name)}"}
   end
 
+  def full_text_excluded_columns
+    [
+      # All the columns that end with "hash" or "uuid" as of June 2024/Arvados 3.0.
+      # It's okay if this list isn't complete, it just needs to be complete
+      # enough to test that full text indexes exclude the right columns.
+      "authorized_user_uuid",
+      "auth_uuid",
+      "cancelled_by_client_uuid",
+      "cancelled_by_user_uuid",
+      "container_uuid",
+      "current_version_uuid",
+      "for_container_uuid",
+      "frozen_by_uuid",
+      "group_uuid",
+      "head_uuid",
+      "is_locked_by_uuid",
+      "locked_by_uuid",
+      "log_uuid",
+      "modified_by_client_uuid",
+      "modified_by_user_uuid",
+      "node_uuid",
+      "object_owner_uuid",
+      "object_uuid",
+      "output_uuid",
+      "owner_uuid",
+      "perm_origin_uuid",
+      "portable_data_hash",
+      "pri_container_uuid",
+      "redirect_to_user_uuid",
+      "requesting_container_uuid",
+      "starting_uuid",
+      "tail_uuid",
+      "target_uuid",
+      "user_uuid",
+      "uuid",
+    ]
+  end
+
   def show_errors model
     return lambda { model.errors.full_messages.inspect }
   end
@@ -179,21 +217,21 @@ class ActionController::TestCase
   end
 
   [:get, :post, :put, :patch, :delete].each do |method|
-    define_method method do |action, *args|
+    define_method method do |action, **kwargs|
       check_counter action
       # After Rails 5.0 upgrade, some params don't get properly serialized.
       # One case are filters: [['attr', 'op', 'val']] become [['attr'], ['op'], ['val']]
       # if not passed upstream as a JSON string.
-      if args[0].is_a?(Hash) && args[0][:params].is_a?(Hash)
-        args[0][:params].each do |key, _|
+      if kwargs[:params].is_a?(Hash)
+        kwargs[:params].each do |key, _|
           next if key == :exclude_script_versions # Job Reuse tests
           # Keys could be: :filters, :where, etc
-          if [Array, Hash].include?(args[0][:params][key].class)
-            args[0][:params][key] = SafeJSON.dump(args[0][:params][key])
+          if [Array, Hash].include?(kwargs[:params][key].class)
+            kwargs[:params][key] = SafeJSON.dump(kwargs[:params][key])
           end
         end
       end
-      super action, *args
+      super action, **kwargs
     end
   end