Order BatchTaggableTagsQuery by name for consistency and to avoid flakey test failure

This commit is contained in:
Cillian O'Ruanaidh
2022-11-18 15:05:03 +00:00
parent a8816b3788
commit b33d382069
2 changed files with 3 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
class BatchTaggableTagsQuery
def self.call(taggables)
tags = ::ActsAsTaggableOn::Tag.
::ActsAsTaggableOn::Tag.
joins(:taggings).
includes(:taggings).
where(taggings:
@@ -10,9 +10,7 @@ class BatchTaggableTagsQuery
taggable_type: taggables.model.to_s,
taggable_id: taggables,
context: 'tags'
})
tags.each_with_object({}) do |tag, indexed_hash|
}).order("tags.name").each_with_object({}) do |tag, indexed_hash|
tag.taggings.each do |tagging|
indexed_hash[tagging.taggable_id] ||= []
indexed_hash[tagging.taggable_id] << tag.name

View File

@@ -13,7 +13,7 @@ describe BatchTaggableTagsQuery do
)
expect(tags).to eq(
{
customer_i.id => ["volunteer", "member"],
customer_i.id => ["member", "volunteer"],
customer_ii.id => ["member"],
}
)