Skip to content

Commit e3e1fa6

Browse files
authored
Merge pull request #1091 from workarea-commerce/verify-mongoid8-any-of-1083
WA-VERIFY-091: Audit and fix Mongoid 8 any_of scoping semantics
2 parents 4f50606 + 97a3852 commit e3e1fa6

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

admin/app/controllers/workarea/admin/help_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ def show
2727
search = Search::RelatedHelp.new(ids: [@help_article.id])
2828
@related = Admin::HelpSearchViewModel.new(search, view_model_options)
2929
@article_body = Redcarpet::Markdown.new(
30-
Redcarpet::Render::HTML.new(hard_wrap: true)
30+
Redcarpet::Render::HTML.new(
31+
hard_wrap: true,
32+
filter_html: true,
33+
safe_links_only: true
34+
)
3135
).render(@help_article.body.to_s)
3236
end
3337

admin/app/view_models/workarea/admin/activity_view_model.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ def scoped_entries
6060
end
6161

6262
if options[:id].present?
63-
Array(options[:id]).each do |id|
64-
criteria = criteria.any_of(
63+
clauses = Array(options[:id]).flat_map do |id|
64+
[
6565
{ audited_id: id },
6666
{ 'document_path.id' => convert_to_object_id(id) }
67-
)
67+
]
6868
end
69+
criteria = criteria.any_of(*clauses) unless clauses.empty?
6970
end
7071

7172
if options[:created_at_greater_than].present?

core/app/models/workarea/tax/rate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def self.search(query)
4343
clauses = [{ region: regex }, { postal_code: regex }]
4444
clauses << { country: country } if country.present?
4545

46-
any_of(clauses)
46+
any_of(*clauses)
4747
end
4848

4949
def self.sorts

0 commit comments

Comments
 (0)