Skip to content

Commit

Permalink
merge in kalins fixes to use tmail.destinations instead of trying to …
Browse files Browse the repository at this point in the history
…parse tmail.to, tmail.cc and tmail.bcc. New specs to test functionality
  • Loading branch information
benprew committed Mar 13, 2010
2 parents 4382d0a + 1cf0f88 commit 119cbe3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
3 changes: 3 additions & 0 deletions README.rdoc
Expand Up @@ -95,6 +95,9 @@ mailing list: ponyrb@googlegroups.com

== Releases

0.8
* Fix bug that was allowing nil :bcc and :cc options to be passed to smtp

0.7
* Pass :cc and :bcc options to sendmail appropriately

Expand Down
4 changes: 2 additions & 2 deletions lib/pony.rb
Expand Up @@ -31,8 +31,8 @@ def self.mail(options)
def self.build_tmail(options)
mail = TMail::Mail.new
mail.to = options[:to]
mail.cc = options[:cc] || ''
mail.bcc = options[:bcc] || ''
mail.cc = options[:cc]
mail.bcc = options[:bcc]
mail.from = options[:from] || 'pony@unknown'
mail.subject = options[:subject]
if options[:attachments]
Expand Down
2 changes: 1 addition & 1 deletion pony.gemspec
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = %q{pony}
s.version = "0.7"
s.version = "0.8"

s.description = "Send email in one command: Pony.mail(:to => 'someone@example.com', :body => 'hello')"
s.summary = s.description
Expand Down
30 changes: 16 additions & 14 deletions spec/pony_spec.rb
Expand Up @@ -141,25 +141,27 @@
Net::SMTP.stub!(:new).and_return(@smtp)
end

it "passes cc and bcc as the list of recipients" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'cc', 'bcc'])
Pony.transport_via_smtp(mock('tmail', :to => ['to'], :cc => ['cc'], :from => ['from'], :to_s => 'message', :bcc => ['bcc'], :destinations => ['to', 'cc', 'bcc']))
end
it "passes cc and bcc as the list of recipients" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'cc', 'bcc'])
Pony.transport_via_smtp(mock('tmail', :to => ['to'], :cc => ['cc'], :from => ['from'], :to_s => 'message', :bcc => ['bcc'], :destinations => ['to', 'cc', 'bcc']))
@smtp.should_receive(:send_message).with("message", 'from', ['to', 'cc'])
Pony.transport_via_smtp(mock('tmail', :to => 'to', :cc => 'cc', :from => 'from', :to_s => 'message', :bcc => nil, :destinations => ['to', 'cc']))
end

it "only pass cc as the list of recipients" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'cc' ])
it "only pass cc as the list of recipients" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'cc' ])
Pony.transport_via_smtp(mock('tmail', :to => ['to'], :cc => ['cc'], :from => ['from'], :to_s => 'message', :bcc => nil, :destinations => ['to', 'cc']))
end
end

it "only pass bcc as the list of recipients" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'bcc' ])
it "only pass bcc as the list of recipients" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'bcc' ])
Pony.transport_via_smtp(mock('tmail', :to => ['to'], :cc => nil, :from => ['from'], :to_s => 'message', :bcc => ['bcc'], :destinations => ['to', 'bcc']))
end
it "passes cc and bcc as the list of recipients when there are a few of them" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'to2', 'cc', 'bcc', 'bcc2', 'bcc3'])
end

it "passes cc and bcc as the list of recipients when there are a few of them" do
@smtp.should_receive(:send_message).with("message", ['from'], ['to', 'to2', 'cc', 'bcc', 'bcc2', 'bcc3'])
Pony.transport_via_smtp(mock('tmail', :to => ['to', 'to2'], :cc => ['cc'], :from => ['from'], :to_s => 'message', :bcc => ['bcc', 'bcc2', 'bcc3'], :destinations => ['to', 'to2', 'cc', 'bcc', 'bcc2', 'bcc3']))
end
end

it "defaults to localhost as the SMTP server" do
Net::SMTP.should_receive(:new).with('localhost', '25').and_return(@smtp)
Expand Down

0 comments on commit 119cbe3

Please sign in to comment.