mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-31 06:31:41 +00:00
Order BatchTaggableTagsQuery by name for consistency and to avoid flakey test failure
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"],
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user