Skip to content

Commit 78b54a2

Browse files
committed
Deflakify tests
1 parent 34d80c8 commit 78b54a2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

spec/jobs/detect_posts_language_spec.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
)
1717
Aws::Translate::Client.stubs(:new).returns(client)
1818
Discourse.redis.del(redis_key)
19-
posts.each { |post| Discourse.redis.sadd?(redis_key, post.id) }
19+
described_class.const_set(:MAX_QUEUE_SIZE, 100)
20+
posts.each { |post| Discourse.redis.sadd(redis_key, post.id) }
2021
end
2122

2223
it "processes posts in batches and updates their translations" do
@@ -38,7 +39,6 @@
3839
post.reload
3940
expect(post.detected_locale).to be_nil
4041
end
41-
4242
expect(Discourse.redis.smembers(redis_key)).to match_array(posts.map(&:id).map(&:to_s))
4343
end
4444

@@ -58,6 +58,8 @@
5858
end
5959

6060
it "removes successfully processed posts from Redis" do
61+
posts.each { |post| expect(Discourse.redis.sismember(redis_key, post.id)).to be_truthy }
62+
6163
described_class.new.execute({})
6264

6365
posts.each { |post| expect(Discourse.redis.sismember(redis_key, post.id)).to be_falsey }
@@ -77,9 +79,6 @@
7779

7880
described_class.new.execute({})
7981

80-
posts.each do |post|
81-
expect(DistributedMutex).to have_received(:synchronize).at_least(:once)
82-
expect(DistributedMutex).to have_received(:synchronize).with("detect_translation_#{post.id}")
83-
end
82+
expect(DistributedMutex).to have_received(:synchronize).at_least(5)
8483
end
8584
end

0 commit comments

Comments
 (0)