Skip to content

Commit

Permalink
test the entire set of URLs sent to cloudflare
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Dec 13, 2024
1 parent 7aa1364 commit bffde8c
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions spec/mailboxes/post_mailbox_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,36 @@
expect(Post.last.html_body.size).to eq(26964)
end

it "purges cloudflare caches by URL" do
Rails.application.config.cloudflare_api_token = "123"
Rails.application.routes.default_url_options[:host] = "feedyouremail.test"
describe "with a cloudflare api token" do
before do
Rails.application.config.cloudflare_api_token = "123"
end

mail = Mail.read file_fixture("attachment-1.eml")
after do
Rails.application.config.cloudflare_api_token = nil
end

expect(Cloudflare).to receive(:connect)
it "purges cloudflare caches by URL" do
Rails.application.routes.default_url_options[:host] = "feedyouremail.test"

expect { process(mail) }.to change { Post.count }
mail = Mail.read file_fixture("attachment-1.eml")

zone = double("zone")
zones = double("zones", find_by_name: zone)
cf = double("cf", zones: zones)
urls = [
"http://feedyouremail.test/feeds/abc123",
"http://feedyouremail.test/feeds/abc123.atom",
"http://feedyouremail.test/feeds/abc123.json"
]

expect(zone).to receive(:purge_cache).with(files: urls)

expect(Cloudflare).to receive(:connect).with(token: "123") do |&block|
block.call(cf)
end

expect { process(mail) }.to change { Post.count }
end
end
end

0 comments on commit bffde8c

Please sign in to comment.