has_emails 0.1.3 → 0.1.4

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.rdoc CHANGED
@@ -1,5 +1,10 @@
1
1
  == master
2
2
 
3
+ == 0.1.4 / 2008-10-26
4
+
5
+ * Add compatibility with has_messages 0.2.0
6
+ * Change how the base module is included to prevent namespacing conflicts
7
+
3
8
  == 0.1.3 / 2008-09-07
4
9
 
5
10
  * Add compatibility with state_machine 0.3.0
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/contrib/sshpublisher'
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = 'has_emails'
8
- s.version = '0.1.3'
8
+ s.version = '0.1.4'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.summary = 'Demonstrates a reference implementation for sending emails with logging and asynchronous support.'
11
11
 
@@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s|
13
13
  s.require_path = 'lib'
14
14
  s.has_rdoc = true
15
15
  s.test_files = Dir['test/**/*_test.rb']
16
- s.add_dependency 'has_messages', '>= 0.1.3'
16
+ s.add_dependency 'has_messages', '>= 0.2.0'
17
17
  s.add_dependency 'validates_as_email_address', '>= 0.0.2'
18
18
 
19
19
  s.author = 'Aaron Pfeifer'
@@ -91,8 +91,7 @@ module PluginAWeek #:nodoc:
91
91
  def queue
92
92
  Email.transaction do
93
93
  # Create the main email
94
- email = Email.new(
95
- :sender => EmailAddress.find_or_create_by_address(from),
94
+ email = EmailAddress.find_or_create_by_address(from).emails.build(
96
95
  :subject => subject,
97
96
  :body => body,
98
97
  :to => email_addresses_for(:recipients),
data/lib/has_emails.rb CHANGED
@@ -5,12 +5,6 @@ require 'has_emails/extensions/action_mailer'
5
5
  module PluginAWeek #:nodoc:
6
6
  # Adds a generic implementation for sending emails
7
7
  module HasEmails
8
- def self.included(base) #:nodoc:
9
- base.class_eval do
10
- extend PluginAWeek::HasEmails::MacroMethods
11
- end
12
- end
13
-
14
8
  module MacroMethods
15
9
  # Creates the following email associations:
16
10
  # * +emails+ - Emails that were composed and are visible to the owner. Emails may have been sent or unsent.
@@ -61,5 +55,5 @@ module PluginAWeek #:nodoc:
61
55
  end
62
56
 
63
57
  ActiveRecord::Base.class_eval do
64
- include PluginAWeek::HasEmails
58
+ extend PluginAWeek::HasEmails::MacroMethods
65
59
  end
data/test/factory.rb CHANGED
@@ -13,12 +13,16 @@ module Factory
13
13
  def valid_attributes_for(model, attributes = {})
14
14
  name = model.to_s.underscore
15
15
  send("#{name}_attributes", attributes)
16
+ attributes.stringify_keys!
16
17
  attributes
17
18
  end
18
19
 
19
20
  # Build an unsaved record
20
21
  def new_record(model, *args)
21
- model.new(valid_attributes_for(model, *args))
22
+ attributes = valid_attributes_for(model, *args)
23
+ record = model.new(attributes)
24
+ attributes.each {|attr, value| record.send("#{attr}=", value) if model.accessible_attributes && !model.accessible_attributes.include?(attr) || model.protected_attributes && model.protected_attributes.include?(attr)}
25
+ record
22
26
  end
23
27
 
24
28
  # Build and save/reload a record
@@ -22,7 +22,7 @@ class EmailAddressByDefaultFunctionalTest < Test::Unit::TestCase
22
22
  end
23
23
  end
24
24
 
25
- class EmailAddresFunctionalsTest < Test::Unit::TestCase
25
+ class EmailAddressFunctionalTest < Test::Unit::TestCase
26
26
  def setup
27
27
  @email_address = create_email_address
28
28
  end
data/test/test_helper.rb CHANGED
@@ -8,6 +8,6 @@ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
8
8
 
9
9
  # Mixin the factory helper
10
10
  require File.expand_path("#{File.dirname(__FILE__)}/factory")
11
- class Test::Unit::TestCase #:nodoc:
11
+ Test::Unit::TestCase.class_eval do
12
12
  include Factory
13
13
  end
@@ -65,6 +65,18 @@ class EmailAddressTest < Test::Unit::TestCase
65
65
  email_address = new_email_address(:name => nil)
66
66
  assert email_address.valid?
67
67
  end
68
+
69
+ def test_should_protect_attributes_from_mass_assignment
70
+ email_address = EmailAddress.new(
71
+ :id => 1,
72
+ :name => 'John Smith',
73
+ :spec => 'john.smith@gmail.com'
74
+ )
75
+
76
+ assert_nil email_address.id
77
+ assert_equal 'John Smith', email_address.name
78
+ assert_equal 'john.smith@gmail.com', email_address.spec
79
+ end
68
80
  end
69
81
 
70
82
  class EmailAddressFromAddressTest < Test::Unit::TestCase
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_emails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-07 00:00:00 -04:00
12
+ date: 2008-10-26 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.1.3
23
+ version: 0.2.0
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: validates_as_email_address