Skip to content

Commit

Permalink
test purge cache url generation
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Dec 13, 2024
1 parent 341ce94 commit 7aa1364
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ group :development do
end

group :production do
gem "cloudflare", "~> 4.4"
gem "cloudflare-rails", "~> 6.2"
gem "honeybadger", "~> 5.26"
gem "lograge", "~> 0.14.0"
Expand All @@ -47,6 +46,7 @@ end
gem "better_html", "~> 2.1"
gem "bootsnap", "~> 1.18", require: false
gem "brotli", "~> 0.6.0"
gem "cloudflare", "~> 4.4"
gem "data_migrate", "~> 11.2"
gem "importmap-rails", "~> 2.0"
gem "jb", "~> 0.8.2"
Expand Down
4 changes: 4 additions & 0 deletions app/mailboxes/post_mailbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def depart(mail)
document.to_s
end

def feed_url(*, **)
Rails.application.routes.url_helpers.feed_url(*, **)
end

def purge_cache(feed)
return unless Rails.application.config.cloudflare_api_token

Expand Down
11 changes: 11 additions & 0 deletions spec/mailboxes/post_mailbox_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,15 @@
expect { process(mail) }.to change { Post.count }
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"

mail = Mail.read file_fixture("attachment-1.eml")

expect(Cloudflare).to receive(:connect)

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

0 comments on commit 7aa1364

Please sign in to comment.