[arvados] updated: 2.7.0-6628-gdf9503c818

git repository hosting git at public.arvados.org
Thu May 30 18:03:59 UTC 2024


Summary of changes:
 services/api/test/unit/arvados_model_test.rb | 59 ++++++++++------------------
 1 file changed, 21 insertions(+), 38 deletions(-)

       via  df9503c818bb07f86669ef20f014647203d77d6f (commit)
      from  55009aa6c287dc7ef98e68d2225a3469a601c674 (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 df9503c818bb07f86669ef20f014647203d77d6f
Author: Tom Clegg <tom at curii.com>
Date:   Thu May 30 14:03:12 2024 -0400

    20640: Fix test for table_name override / no searchable columns.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/services/api/test/unit/arvados_model_test.rb b/services/api/test/unit/arvados_model_test.rb
index 341a8462dd..7ce5f87ebc 100644
--- a/services/api/test/unit/arvados_model_test.rb
+++ b/services/api/test/unit/arvados_model_test.rb
@@ -126,45 +126,28 @@ class ArvadosModelTest < ActiveSupport::TestCase
   end
 
   test "search index exists on models that go into projects" do
-    all_tables =  ActiveRecord::Base.connection.tables - [
-      'ar_internal_metadata',
-      'permission_refresh_lock',
-      'schema_migrations',
-      # tables that may still exist in the database even though model
-      # classes have been deleted:
-      'humans',
-      'jobs',
-      'job_tasks',
-      'keep_disks',
-      'nodes',
-      'pipeline_instances',
-      'pipeline_templates',
-      'repositories',
-      'specimens',
-      'traits',
-    ]
-
-    all_tables.each do |table|
-      table_class = table.classify.constantize
-      if table_class.respond_to?('searchable_columns')
-        search_index_columns = table_class.searchable_columns('ilike')
-        # Disappointing, but text columns aren't indexed yet.
-        search_index_columns -= table_class.columns.select { |c|
-          c.type == :text or c.name == 'description' or c.name == 'file_names'
-        }.collect(&:name)
-
-        indexes = ActiveRecord::Base.connection.indexes(table)
-        search_index_by_columns = indexes.select do |index|
-          # After rails 5.0 upgrade, AR::Base.connection.indexes() started to include
-          # GIN indexes, with its 'columns' attribute being a String like
-          # 'to_tsvector(...)'
-          index.columns.is_a?(Array) ? index.columns.sort == search_index_columns.sort : false
-        end
-        search_index_by_name = indexes.select do |index|
-          index.name == "#{table}_search_index"
-        end
-        assert !search_index_by_columns.empty?, "#{table} has no search index with columns #{search_index_columns}. Instead found search index with columns #{search_index_by_name.first.andand.columns}"
+    ActiveRecord::Base.descendants.each do |model_class|
+      next if model_class.abstract_class?
+      next if !model_class.respond_to?('searchable_columns')
+
+      search_index_columns = model_class.searchable_columns('ilike')
+      # Disappointing, but text columns aren't indexed yet.
+      search_index_columns -= model_class.columns.select { |c|
+        c.type == :text or c.name == 'description' or c.name == 'file_names'
+      }.collect(&:name)
+      next if search_index_columns.empty?
+
+      indexes = ActiveRecord::Base.connection.indexes(model_class.table_name)
+      search_index_by_columns = indexes.select do |index|
+        # After rails 5.0 upgrade, AR::Base.connection.indexes() started to include
+        # GIN indexes, with its 'columns' attribute being a String like
+        # 'to_tsvector(...)'
+        index.columns.is_a?(Array) ? index.columns.sort == search_index_columns.sort : false
+      end
+      search_index_by_name = indexes.select do |index|
+        index.name == "#{model_class.table_name}_search_index"
       end
+      assert !search_index_by_columns.empty?, "#{model_class.table_name} (#{model_class.to_s}) has no search index with columns #{search_index_columns}. Instead found search index with columns #{search_index_by_name.first.andand.columns}"
     end
   end
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list