From 20e34b5da6e776088326387049891b0d105035d1 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Thu, 23 Jun 2022 15:38:12 +0200 Subject: [PATCH] DEV: Stabilize watched words order (#17215) Fixes a flaky spec: ``` 1) WordWatcher.word_matcher_regexp format of the result regexp is correct when watched_words_regular_expressions = true Failure/Error: expect(regexp.inspect).to eq("/(#{word1})|(#{word2})/i") expected: "/(word35)|(word36)/i" got: "/(word36)|(word35)/i" (compared using ==) # ./spec/services/word_watcher_spec.rb:19:in `block (4 levels) in
' ``` --- app/services/word_watcher.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/word_watcher.rb b/app/services/word_watcher.rb index bc056fd6b46..443533a0c12 100644 --- a/app/services/word_watcher.rb +++ b/app/services/word_watcher.rb @@ -21,6 +21,7 @@ class WordWatcher words = WatchedWord .where(action: WatchedWord.actions[action.to_sym]) .limit(WatchedWord::MAX_WORDS_PER_ACTION) + .order(:id) if WatchedWord.has_replacement?(action.to_sym) words.pluck(:word, :replacement).to_h