diff --git a/app/services/edge_cache/bust/fastly.rb b/app/services/edge_cache/bust/fastly.rb index ed7f055a1..3b4985e58 100644 --- a/app/services/edge_cache/bust/fastly.rb +++ b/app/services/edge_cache/bust/fastly.rb @@ -4,18 +4,10 @@ module EdgeCache # [@forem/systems] Fastly-enabled Forems don't need "flexible" domains. def self.call(path) api_key = ApplicationConfig["FASTLY_API_KEY"] - return fastly_purge(api_key, path) if FeatureFlag.enabled?(:fastly_http_purge) - fastly_post(api_key, path) + fastly_purge(api_key, path) end - def self.fastly_post(api_key, path) - urls(path).map do |url| - HTTParty.post("https://api.fastly.com/purge/#{url}", headers: { "Fastly-Key" => api_key }) - end - end - private_class_method :fastly_post - def self.fastly_purge(api_key, path) fastly = ::Fastly.new(api_key: api_key) diff --git a/lib/data_update_scripts/20220317151317_remove_fastly_http_purge_flag.rb b/lib/data_update_scripts/20220317151317_remove_fastly_http_purge_flag.rb new file mode 100644 index 000000000..19a64227a --- /dev/null +++ b/lib/data_update_scripts/20220317151317_remove_fastly_http_purge_flag.rb @@ -0,0 +1,7 @@ +module DataUpdateScripts + class RemoveFastlyHttpPurgeFlag + def run + FeatureFlag.remove(:fastly_http_purge) + end + end +end diff --git a/spec/lib/data_update_scripts/remove_fastly_http_purge_flag_spec.rb b/spec/lib/data_update_scripts/remove_fastly_http_purge_flag_spec.rb new file mode 100644 index 000000000..a6e55144f --- /dev/null +++ b/spec/lib/data_update_scripts/remove_fastly_http_purge_flag_spec.rb @@ -0,0 +1,21 @@ +require "rails_helper" +require Rails.root.join( + "lib/data_update_scripts/20220317151317_remove_fastly_http_purge_flag.rb", +) + +describe DataUpdateScripts::RemoveFastlyHttpPurgeFlag do + it "removes the feature flag if present" do + FeatureFlag.add(:fastly_http_purge) + + described_class.new.run + + expect(FeatureFlag.exist?(:fastly_http_purge)).to be false + end + + it "is safe to run twice" do + # this is the same as "does nothing if flag not present" + 2.times { described_class.new.run } + + expect(FeatureFlag.exist?(:fastly_http_purge)).to be false + end +end