active_mailer 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog.md ADDED
@@ -0,0 +1,3 @@
1
+ = 0.0.5
2
+ * Fixed bug where the subject was not being set correctly.
3
+ * The ActionMailer object used behind the scenese is now available through #mailer
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_mailer (0.0.2)
4
+ active_mailer (0.0.4)
5
5
  activesupport (~> 3.2)
6
6
  rails (~> 3.2)
7
7
 
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.authors = ["Matt Gordon"]
8
8
  s.email = 'support@expectedbehavior.com'
9
9
  s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
10
- s.version = "0.0.4"
10
+ s.version = "0.0.5"
11
11
  s.homepage =
12
12
  'https://github.com/expectedbehavior/active_mailer'
13
13
 
@@ -123,12 +123,16 @@ module ActiveMailer #:nodoc:
123
123
  # self.send(:define_method, name, &block)
124
124
  # end
125
125
  end
126
+
127
+ def mailer(reload = false)
128
+ @mailer ||= DefaultActionMailer.send("#{self.class.default_email_method_name}".to_sym, self.mailer_variables)
129
+ end
126
130
 
127
131
  def send! # should take false to avoid validations i.e. sending it again
128
132
  if self.save!
129
133
  logger.info "sending email to #{self.recipients.join(", ")}"
130
134
  self.class.define_action_mailer_method
131
- sent_mail = DefaultActionMailer.send("#{self.class.default_email_method_name}".to_sym, self.mailer_variables).deliver
135
+ sent_mail = mailer.deliver
132
136
  self.rendered_contents = sent_mail.body.to_s # in case someone wants to save it
133
137
  logger.info "email #{self.class.default_email_method_name} sent to #{self.recipients.map(&:email_address).join(", ")} from #{self.sender.email_address}"
134
138
  self.update_attribute("sent_at", Time.now)
@@ -156,6 +160,7 @@ module ActiveMailer #:nodoc:
156
160
  DefaultActionMailer.instance_eval do
157
161
  define_method(method_name) do |*args|
158
162
  options = args[0]
163
+ options = options.with_indifferent_access
159
164
  attachments_to_set = (options[:attachments] || [])
160
165
  options.keys.each do |k|
161
166
  self.instance_eval("@#{k.to_s} = options[k]") if options[k]
@@ -13,4 +13,13 @@ class ActiveMailerTest < ActiveSupport::TestCase
13
13
  assert { email.save }
14
14
  deny { email.recipients.length == 2 }
15
15
  end
16
+
17
+ test "sends with correct subject" do
18
+ email = InvitationEmail.new(:sender => "spammy@example.com",
19
+ :recipients => ["takesit@upemail.com", nil],
20
+ :subject => "YOU GUYS!"
21
+ )
22
+ assert { email.send! }
23
+ assert { email.mailer.subject == email.subject }
24
+ end
16
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
12
+ date: 2013-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -52,6 +52,7 @@ extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
54
  - .gitignore
55
+ - ChangeLog.md
55
56
  - Gemfile
56
57
  - Gemfile.lock
57
58
  - MIT-LICENSE