From 7ca88538615e3b07856d75a676be146caf133472 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 25 Oct 2017 13:22:50 +1100 Subject: [PATCH] don't risk being stuck in readonly --- spec/models/application_request_spec.rb | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/spec/models/application_request_spec.rb b/spec/models/application_request_spec.rb index 3f3e215bf1f..8fceea83f12 100644 --- a/spec/models/application_request_spec.rb +++ b/spec/models/application_request_spec.rb @@ -19,20 +19,26 @@ describe ApplicationRequest do ApplicationRequest.last_flush = Time.now.utc end - it 'works even if redis is in readonly' do - disable_date_flush! + context "readonly test" do + after do + $redis.slaveof("no", "one") + end - inc(:http_total) - inc(:http_total) + it 'works even if redis is in readonly' do + disable_date_flush! - $redis.slaveof("127.0.0.1", 666) + inc(:http_total) + inc(:http_total) - # flush will be deferred no error raised - inc(:http_total, autoflush: 3) - $redis.slaveof("no", "one") + $redis.slaveof("127.0.0.1", 666) - inc(:http_total, autoflush: 3) - expect(ApplicationRequest.http_total.first.count).to eq(3) + # flush will be deferred no error raised + inc(:http_total, autoflush: 3) + $redis.slaveof("no", "one") + + inc(:http_total, autoflush: 3) + expect(ApplicationRequest.http_total.first.count).to eq(3) + end end it 'logs nothing for an unflushed increment' do