Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ActionMailer::Base.class_eval do
DELIVERIES_CACHE_PATH =
File.join(RAILS_ROOT,'tmp','cache',"action_mailer_cache_deliveries#{ENV['TEST_ENV_NUMBER']}.cache")
def perform_delivery_cache(mail)
deliveries = File.open(DELIVERIES_CACHE_PATH, 'r') do |f|
Marshal.load(f)
end
deliveries << mail
File.open(DELIVERIES_CACHE_PATH,'w') do |f|
Marshal.dump(deliveries, f)
end
end
def self.cached_deliveries
File.open(DELIVERIES_CACHE_PATH,'r') do |f|
Marshal.load(f)
end
end
def self.clear_cache
deliveries.clear
File.open(DELIVERIES_CACHE_PATH,'w') do |f|
Marshal.dump(deliveries, f)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.