Remove fastly http purge feature flag and conditional behavior (#16903)
* Always use purge, never post, to fastly * Remove unneeded feature flag
This commit is contained in:
parent
c4073ab217
commit
c6c30d58ab
3 changed files with 29 additions and 9 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
module DataUpdateScripts
|
||||
class RemoveFastlyHttpPurgeFlag
|
||||
def run
|
||||
FeatureFlag.remove(:fastly_http_purge)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue