sending csv as a file
This commit is contained in:
parent
24545743e2
commit
9cadb99f8a
3 changed files with 13 additions and 1 deletions
|
|
@ -16,12 +16,19 @@ class Notifier < ActionMailer::Base
|
||||||
@receiver = recipient
|
@receiver = recipient
|
||||||
@string = string.html_safe
|
@string = string.html_safe
|
||||||
|
|
||||||
|
if attach = opts.delete(:attachments)
|
||||||
|
attach.each{ |f|
|
||||||
|
attachments[f[:name]] = f[:file]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
default_opts = {:to => @receiver.email,
|
default_opts = {:to => @receiver.email,
|
||||||
:from => AppConfig[:smtp_sender_address],
|
:from => AppConfig[:smtp_sender_address],
|
||||||
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host}
|
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host}
|
||||||
default_opts.merge!(opts)
|
default_opts.merge!(opts)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mail(default_opts)
|
mail(default_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace :stats do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
emails = Notifier.admin(string, admins, {:subject => "retention numbers #{Time.now.to_s}"})
|
emails = Notifier.admin( "here are some retention stats", admins, {:subject => "retention numbers #{Time.now.to_s}", :attachments => [:name => "retention_numbers_#{Time.now.to_s}.csv", :file => string]})
|
||||||
emails.each {|e| e.deliver!}
|
emails.each {|e| e.deliver!}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,11 @@ describe Notifier do
|
||||||
mail = Notifier.single_admin("Welcome to bureaucracy!", bob)
|
mail = Notifier.single_admin("Welcome to bureaucracy!", bob)
|
||||||
mail.body.encoded.should match /change your notification settings/
|
mail.body.encoded.should match /change your notification settings/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has an optional attachment' do
|
||||||
|
mail = Notifier.single_admin("Welcome to bureaucracy!", bob, :attachments => [{:name => "retention stats", :file => "here is some file content"}])
|
||||||
|
mail.attachments.length.should == 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".started_sharing" do
|
describe ".started_sharing" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue