update specs; add new specs to test for reported bug related to AND query in referenced table

This commit is contained in:
Bilal
2020-04-20 22:21:26 +02:00
parent f4bec85161
commit 455845e36b
3 changed files with 140 additions and 25 deletions

View File

@@ -82,6 +82,21 @@ class DynamicModelWithTagValues < ActiveRecord::Base
has_many :tags, as: :taggable
end
class DynamicModelWithTagAndCategories < ActiveRecord::Base
self.table_name = :dynamic_models
include PgSearchable
pg_search fields: %i[dynamic_models.id dynamic_models.name dynamic_models.value], fields_mappings: {tag: 'tags.value', category: 'categories.name'}, joins: [:tags, :categories]
has_many :tags, as: :taggable
has_many :categories, as: :categoriable
end
class DynamicModelWithTagValuesAndCustomAttribute < ActiveRecord::Base
self.table_name = :dynamic_models
include PgSearchable
pg_search fields: %i[dynamic_models.id dynamic_models.name dynamic_models.value], fields_mappings: {tag: 'tags.value', custom: 'tags.custom_attribute'}, joins: [:tags]
has_many :tags, as: :taggable
end
class DynamicModelWithCategory < ActiveRecord::Base
self.table_name = :dynamic_models
include PgSearchable
@@ -112,4 +127,5 @@ end
class Category < ActiveRecord::Base
has_many :tags
belongs_to :categoriable, polymorphic: true
end