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 <main>'
```
This commit is contained in:
Jarek Radosz 2022-06-23 15:38:12 +02:00 committed by GitHub
parent 16550537d0
commit 20e34b5da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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