From d7e73c3c24b5307a2c9055aae566327a05034c22 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Tue, 26 Sep 2017 16:13:29 +1000 Subject: [PATCH] fix(badges): do not allow caching Ensure README badges are not cached by github --- lib/pact_broker/api/resources/badge.rb | 1 + spec/lib/pact_broker/api/resources/badge_spec.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/pact_broker/api/resources/badge.rb b/lib/pact_broker/api/resources/badge.rb index 1f7a77a04..6cd629c21 100644 --- a/lib/pact_broker/api/resources/badge.rb +++ b/lib/pact_broker/api/resources/badge.rb @@ -31,6 +31,7 @@ def forbidden? private def to_svg + response.headers['Cache-Control'] = 'no-cache' badge_service.pact_verification_badge pact, label, initials, verification_status end diff --git a/spec/lib/pact_broker/api/resources/badge_spec.rb b/spec/lib/pact_broker/api/resources/badge_spec.rb index a515edb4e..92468777e 100644 --- a/spec/lib/pact_broker/api/resources/badge_spec.rb +++ b/spec/lib/pact_broker/api/resources/badge_spec.rb @@ -76,6 +76,10 @@ module Resources expect(subject.status).to eq 200 end + it "does not allow caching" do + expect(subject.headers['Cache-Control']).to eq 'no-cache' + end + it "returns the badge" do expect(subject.body).to eq "badge" end