Skip to content

Commit 0e96217

Browse files
committed
test order
1 parent 6592e21 commit 0e96217

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spec/jobs/detect_posts_locale_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@
3535
job.execute({})
3636
end
3737

38+
it "detects most recently updated posts first" do
39+
post_2 = Fabricate(:post, locale: nil)
40+
post_3 = Fabricate(:post, locale: nil)
41+
42+
post.update!(updated_at: 3.days.ago)
43+
post_2.update!(updated_at: 2.day.ago)
44+
post_3.update!(updated_at: 4.day.ago)
45+
46+
original_batch = described_class::BATCH_SIZE
47+
described_class.const_set(:BATCH_SIZE, 1)
48+
49+
DiscourseTranslator::PostLocaleDetector.expects(:detect_locale).with(post_2).once
50+
DiscourseTranslator::PostLocaleDetector.expects(:detect_locale).with(post).never
51+
DiscourseTranslator::PostLocaleDetector.expects(:detect_locale).with(post_3).never
52+
53+
job.execute({})
54+
ensure
55+
described_class.const_set(:BATCH_SIZE, original_batch)
56+
end
57+
3858
it "skips bot posts" do
3959
post.update!(user: Discourse.system_user)
4060
DiscourseTranslator::PostLocaleDetector.expects(:detect_locale).with(post).never

0 commit comments

Comments
 (0)