has_emails 0.2.1 → 0.3.0
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 +5 -1
- data/LICENSE +2 -2
- data/README.rdoc +10 -10
- data/Rakefile +2 -2
- data/app/models/email_address.rb +9 -8
- data/lib/has_emails.rb +6 -3
- data/test/app_root/config/environment.rb +2 -2
- data/test/app_root/db/migrate/001_migrate_has_messages_to_version_2.rb +11 -2
- data/test/app_root/db/migrate/002_migrate_has_emails_to_version_1.rb +6 -2
- data/test/app_root/vendor/plugins/plugin_tracker/init.rb +5 -0
- data/test/functional/has_emails_test.rb +6 -6
- data/test/unit/action_mailer_test.rb +11 -15
- data/test/unit/email_address_test.rb +6 -6
- data/test/unit/email_test.rb +1 -1
- metadata +8 -7
- data/test/app_root/app/models/empty +0 -0
data/CHANGELOG.rdoc
CHANGED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2006-
|
1
|
+
Copyright (c) 2006-2009 Aaron Pfeifer
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -23,16 +23,17 @@ Source
|
|
23
23
|
|
24
24
|
== Description
|
25
25
|
|
26
|
-
Emailing between users and other parts of a system is a fairly common feature
|
27
|
-
web applications, especially for those that support social networking.
|
28
|
-
doesn't necessarily need to be between users, but can also act as a
|
29
|
-
web application to send notices and other notifications to users.
|
26
|
+
Emailing between users and other parts of a system is a fairly common feature
|
27
|
+
in web applications, especially for those that support social networking.
|
28
|
+
Emailing doesn't necessarily need to be between users, but can also act as a
|
29
|
+
way for the web application to send notices and other notifications to users.
|
30
30
|
|
31
31
|
Rails already provides ActionMailer as a way of sending emails. However, the
|
32
|
-
framework does not provide an easy way to persist emails, track their status,
|
33
|
-
process them asynchronously. Designing and building a framework that
|
34
|
-
can be complex and takes away from the business focus. This
|
35
|
-
that process by demonstrating a
|
32
|
+
framework does not provide an easy way to persist emails, track their status,
|
33
|
+
and process them asynchronously. Designing and building a framework that
|
34
|
+
supports this can be complex and takes away from the business focus. This
|
35
|
+
plugin can help ease that process by demonstrating a reference implementation
|
36
|
+
of these features.
|
36
37
|
|
37
38
|
== Usage
|
38
39
|
|
@@ -90,7 +91,6 @@ To run against a specific version of Rails:
|
|
90
91
|
|
91
92
|
== Dependencies
|
92
93
|
|
93
|
-
* Rails 2.
|
94
|
+
* Rails 2.3 or later
|
94
95
|
* has_messages[http://github.com/pluginaweek/has_messages]
|
95
96
|
* state_machine[http://github.com/pluginaweek/state_machine]
|
96
|
-
* plugins_plus[http://github.com/pluginaweek/plugins_plugins] (optional if app files are copied to your project tree)
|
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.
|
8
|
+
s.version = '0.3.0'
|
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.
|
16
|
+
s.add_dependency 'has_messages', '>= 0.4.0'
|
17
17
|
s.add_dependency 'validates_as_email_address', '>= 0.0.2'
|
18
18
|
|
19
19
|
s.author = 'Aaron Pfeifer'
|
data/app/models/email_address.rb
CHANGED
@@ -6,19 +6,20 @@
|
|
6
6
|
#
|
7
7
|
# == Associations
|
8
8
|
#
|
9
|
-
# Email addresses have the following associations defined as a result of using
|
10
|
-
# +has_emails+ macro:
|
11
|
-
# * +emails+ - Emails that were composed and are visible to the owner. Emails
|
12
|
-
#
|
9
|
+
# Email addresses have the following associations defined as a result of using
|
10
|
+
# the +has_emails+ macro:
|
11
|
+
# * +emails+ - Emails that were composed and are visible to the owner. Emails
|
12
|
+
# may have been sent or unsent.
|
13
|
+
# * +received_emails+ - Emails that have been received from others and are
|
14
|
+
# visible. Emails may have been read or unread.
|
13
15
|
# * +unsent_emails+ - Emails that have not yet been delivered
|
14
16
|
# * +sent_emails+ - Emails that have already been delivered
|
15
17
|
class EmailAddress < ActiveRecord::Base
|
16
18
|
has_emails
|
17
19
|
|
18
|
-
validates_presence_of
|
19
|
-
validates_as_email_address
|
20
|
-
validates_uniqueness_of
|
21
|
-
:scope => 'name'
|
20
|
+
validates_presence_of :spec
|
21
|
+
validates_as_email_address :spec
|
22
|
+
validates_uniqueness_of :spec, :scope => 'name'
|
22
23
|
|
23
24
|
class << self
|
24
25
|
# Finds or create an email address based on the given value
|
data/lib/has_emails.rb
CHANGED
@@ -6,12 +6,15 @@ require 'has_emails/extensions/action_mailer'
|
|
6
6
|
module HasEmails
|
7
7
|
module MacroMethods
|
8
8
|
# Creates the following email associations:
|
9
|
-
# * +emails+ - Emails that were composed and are visible to the owner.
|
10
|
-
#
|
9
|
+
# * +emails+ - Emails that were composed and are visible to the owner.
|
10
|
+
# Emails may have been sent or unsent.
|
11
|
+
# * +received_emails - Emails that have been received from others and are
|
12
|
+
# visible. Emails may have been read or unread.
|
11
13
|
#
|
12
14
|
# == Creating new emails
|
13
15
|
#
|
14
|
-
# To create a new email, the +emails+ association should be used
|
16
|
+
# To create a new email, the +emails+ association should be used. For
|
17
|
+
# example:
|
15
18
|
#
|
16
19
|
# address = EmailAddress.find(123)
|
17
20
|
# email = user.emails.build
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'config/boot'
|
2
|
-
require "#{File.dirname(__FILE__)}/../../../../plugins_plus/boot"
|
3
2
|
|
4
3
|
Rails::Initializer.run do |config|
|
5
4
|
config.plugin_paths << '..'
|
6
|
-
config.plugins = %w(
|
5
|
+
config.plugins = %w(plugin_tracker state_machine has_messages validates_as_email_address has_emails)
|
7
6
|
config.cache_classes = false
|
8
7
|
config.whiny_nils = true
|
9
8
|
config.action_mailer.delivery_method = :test
|
9
|
+
config.action_controller.session = {:key => 'rails_session', :secret => 'd229e4d22437432705ab3985d4d246'}
|
10
10
|
end
|
@@ -1,9 +1,18 @@
|
|
1
1
|
class MigrateHasMessagesToVersion2 < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
|
3
|
+
ActiveRecord::Migrator.new(:up, "#{directory}/db/migrate", 0).migrations.each do |migration|
|
4
|
+
migration.migrate(:up)
|
5
|
+
end
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.down
|
7
|
-
|
9
|
+
ActiveRecord::Migrator.new(:up, "#{directory}/db/migrate", 0).migrations.each do |migration|
|
10
|
+
migration.migrate(:down)
|
11
|
+
end
|
8
12
|
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def self.directory
|
16
|
+
Rails.plugins.find {|plugin| plugin.name == 'has_messages'}.directory
|
17
|
+
end
|
9
18
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
class MigrateHasEmailsToVersion1 < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
|
3
|
+
ActiveRecord::Migrator.new(:up, "#{Rails.root}/../../db/migrate", 0).migrations.each do |migration|
|
4
|
+
migration.migrate(:up)
|
5
|
+
end
|
4
6
|
end
|
5
7
|
|
6
8
|
def self.down
|
7
|
-
|
9
|
+
ActiveRecord::Migrator.new(:up, "#{Rails.root}/../../db/migrate", 0).migrations.each do |migration|
|
10
|
+
migration.migrate(:down)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class EmailAddressByDefaultFunctionalTest <
|
3
|
+
class EmailAddressByDefaultFunctionalTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
5
|
@email_address = create_email_address
|
6
6
|
end
|
@@ -22,7 +22,7 @@ class EmailAddressByDefaultFunctionalTest < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
class EmailAddressFunctionalTest <
|
25
|
+
class EmailAddressFunctionalTest < ActiveSupport::TestCase
|
26
26
|
def setup
|
27
27
|
@email_address = create_email_address
|
28
28
|
end
|
@@ -40,7 +40,7 @@ class EmailAddressFunctionalTest < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
class EmailAddressWithUnsentEmails <
|
43
|
+
class EmailAddressWithUnsentEmails < ActiveSupport::TestCase
|
44
44
|
def setup
|
45
45
|
@email_address = create_email_address
|
46
46
|
@sent_email = create_email(:sender => @email_address, :to => create_email_address(:spec => 'jane.smith@gmail.com'))
|
@@ -58,7 +58,7 @@ class EmailAddressWithUnsentEmails < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
class EmailAddressWithSentEmails <
|
61
|
+
class EmailAddressWithSentEmails < ActiveSupport::TestCase
|
62
62
|
def setup
|
63
63
|
@email_address = create_email_address
|
64
64
|
@to = create_email_address(:spec => 'jane.smith@gmail.com')
|
@@ -80,7 +80,7 @@ class EmailAddressWithSentEmails < Test::Unit::TestCase
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
class EmailAddressWithReceivedEmails <
|
83
|
+
class EmailAddressWithReceivedEmails < ActiveSupport::TestCase
|
84
84
|
def setup
|
85
85
|
@sender = create_email_address
|
86
86
|
@email_address = create_email_address(:spec => 'jane.smith@gmail.com')
|
@@ -99,7 +99,7 @@ class EmailAddressWithReceivedEmails < Test::Unit::TestCase
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
class EmailAddressWithHiddenEmailsTest <
|
102
|
+
class EmailAddressWithHiddenEmailsTest < ActiveSupport::TestCase
|
103
103
|
def setup
|
104
104
|
@email_address = create_email_address
|
105
105
|
@friend = create_email_address(:spec => 'jane.smith@gmail.com')
|
@@ -1,21 +1,17 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
body 'Congratulations!'
|
12
|
-
end
|
3
|
+
class TestMailer < ActionMailer::Base
|
4
|
+
def signed_up(recipient)
|
5
|
+
subject 'Thanks for signing up'
|
6
|
+
from 'MyWebApp <welcome@mywebapp.com>'
|
7
|
+
recipients recipient
|
8
|
+
cc 'Nobody <nobody@mywebapp.com>'
|
9
|
+
bcc 'root@mywebapp.com'
|
10
|
+
body 'Congratulations!'
|
13
11
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
class TestMailerTest < ActionMailer::TestCase
|
19
15
|
def test_should_use_camelized_application_name_for_default_subject_prefix
|
20
16
|
assert_equal '[AppRoot] ', ActionMailer::Base.default_subject_prefix
|
21
17
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
2
|
|
3
|
-
class EmailAddressByDefaultTest <
|
3
|
+
class EmailAddressByDefaultTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
5
|
@email_address = EmailAddress.new
|
6
6
|
end
|
@@ -14,7 +14,7 @@ class EmailAddressByDefaultTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
class EmailAddressTest <
|
17
|
+
class EmailAddressTest < ActiveSupport::TestCase
|
18
18
|
def test_should_be_valid_with_a_set_of_valid_attributes
|
19
19
|
email_address = new_email_address
|
20
20
|
assert email_address.valid?
|
@@ -79,7 +79,7 @@ class EmailAddressTest < Test::Unit::TestCase
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
class EmailAddressFromAddressTest <
|
82
|
+
class EmailAddressFromAddressTest < ActiveSupport::TestCase
|
83
83
|
def setup
|
84
84
|
@email_address = EmailAddress.new(:address => 'John Smith <john.smith@gmail.com>')
|
85
85
|
end
|
@@ -97,7 +97,7 @@ class EmailAddressFromAddressTest < Test::Unit::TestCase
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
class EmailAddressFromAddressWithoutNameTest <
|
100
|
+
class EmailAddressFromAddressWithoutNameTest < ActiveSupport::TestCase
|
101
101
|
def setup
|
102
102
|
@email_address = EmailAddress.new(:address => 'john.smith@gmail.com')
|
103
103
|
end
|
@@ -115,7 +115,7 @@ class EmailAddressFromAddressWithoutNameTest < Test::Unit::TestCase
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
class EmailAddressAfterBeingCreatedTest <
|
118
|
+
class EmailAddressAfterBeingCreatedTest < ActiveSupport::TestCase
|
119
119
|
def setup
|
120
120
|
@email_address = create_email_address(:name => 'John Smith', :spec => 'john.smith@gmail.com')
|
121
121
|
end
|
@@ -133,7 +133,7 @@ class EmailAddressAfterBeingCreatedTest < Test::Unit::TestCase
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
class EmailAddressAsAClassTest <
|
136
|
+
class EmailAddressAsAClassTest < ActiveSupport::TestCase
|
137
137
|
def test_should_be_able_to_split_address_containing_name
|
138
138
|
name, spec = EmailAddress.split_address('John Smith <john.smith@gmail.com>')
|
139
139
|
assert_equal 'John Smith', name
|
data/test/unit/email_test.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
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: 2009-
|
12
|
+
date: 2009-04-19 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.
|
23
|
+
version: 0.4.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: validates_as_email_address
|
@@ -65,9 +65,10 @@ files:
|
|
65
65
|
- test/app_root/db/migrate/001_migrate_has_messages_to_version_2.rb
|
66
66
|
- test/app_root/config
|
67
67
|
- test/app_root/config/environment.rb
|
68
|
-
- test/app_root/
|
69
|
-
- test/app_root/
|
70
|
-
- test/app_root/
|
68
|
+
- test/app_root/vendor
|
69
|
+
- test/app_root/vendor/plugins
|
70
|
+
- test/app_root/vendor/plugins/plugin_tracker
|
71
|
+
- test/app_root/vendor/plugins/plugin_tracker/init.rb
|
71
72
|
- CHANGELOG.rdoc
|
72
73
|
- init.rb
|
73
74
|
- LICENSE
|
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
requirements: []
|
96
97
|
|
97
98
|
rubyforge_project: pluginaweek
|
98
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.3.1
|
99
100
|
signing_key:
|
100
101
|
specification_version: 2
|
101
102
|
summary: Demonstrates a reference implementation for sending emails with logging and asynchronous support.
|
File without changes
|