Skip to content

Instantly share code, notes, and snippets.

@iafonov
Created January 30, 2012 08:09
Show Gist options
  • Save iafonov/e224c4cf78102f44c498 to your computer and use it in GitHub Desktop.
Save iafonov/e224c4cf78102f44c498 to your computer and use it in GitHub Desktop.
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