has_emails 0.1.1 → 0.1.2

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.
@@ -1,35 +1,28 @@
1
- *SVN*
1
+ == master
2
2
 
3
- *0.1.1* (June 22nd, 2008)
3
+ == 0.1.2 / 2008-06-29
4
+
5
+ * Add compatibility with has_messages 0.1.2
6
+
7
+ == 0.1.1 / 2008-06-22
4
8
 
5
9
  * Remove log files from gems
6
10
 
7
- *0.1.0* (May 5th, 2008)
11
+ == 0.1.0 / 2008-05-05
8
12
 
9
13
  * Update to latest has_messages api
10
-
11
14
  * Simplify by removing support for models other than EmailAddresses in Emails
12
-
13
15
  * Updated documentation
14
16
 
15
- *0.0.1* (September 26th, 2007)
17
+ == 0.0.1 / 2007-09-26
16
18
 
17
19
  * Refactor has_email_address/has_email_addresses so that new associations for unsent/sent emails isn't created for has_email_address
18
-
19
20
  * Add state changes fixtures for tests
20
-
21
21
  * Add tests for ApplicationMailer
22
-
23
22
  * Add support for tracking the original email address for senders/recipients even if the email address changes on the associated model (i.e. EmailAddress/User/etc.)
24
-
25
23
  * Support converting models with an email_address/email_addresses association
26
-
27
24
  * Allow the sender of emails to be an arbitrary string email address
28
-
29
25
  * Add documentation
30
-
31
26
  * Move test fixtures out of the test application root directory
32
-
33
27
  * Convert dos newlines to unix newlines
34
-
35
28
  * Update against latest changes to has_messages
@@ -5,21 +5,21 @@ logging and asynchronous support.
5
5
 
6
6
  == Resources
7
7
 
8
- Wiki
9
-
10
- * http://wiki.pluginaweek.org/Has_emails
11
-
12
8
  API
13
9
 
14
10
  * http://api.pluginaweek.org/has_emails
15
11
 
12
+ Bugs
13
+
14
+ * http://pluginaweek.lighthouseapp.com/projects/13272-has_emails
15
+
16
16
  Development
17
17
 
18
- * http://dev.pluginaweek.org/browser/trunk/has_emails
18
+ * http://github.com/pluginaweek/has_emails
19
19
 
20
20
  Source
21
21
 
22
- * http://svn.pluginaweek.org/trunk/has_emails
22
+ * git://github.com/pluginaweek/has_emails.git
23
23
 
24
24
  == Description
25
25
 
@@ -51,19 +51,19 @@ In addition to queueing emails, you can build them directly like so:
51
51
  email.to EmailAddress.find(456)
52
52
  email.subject = 'Hey!'
53
53
  email.body = 'Does anyone want to go out tonight?'
54
- email.deliver!
54
+ email.deliver
55
55
 
56
56
  === Replying to emails
57
57
 
58
58
  reply = email.reply_to_all
59
59
  reply.body = "I'd love to go out!"
60
- reply.deliver!
60
+ reply.deliver
61
61
 
62
62
  === Forwarding emails
63
63
 
64
64
  forward = email.forward
65
65
  forward.body = 'Interested?'
66
- forward.deliver!
66
+ forward.deliver
67
67
 
68
68
  === Processing email asynchronously
69
69
 
@@ -76,13 +76,13 @@ To process queued emails, you need an external cron job that checks and sends
76
76
  them like so:
77
77
 
78
78
  Email.with_state('queued').each do |email|
79
- email.deliver!
79
+ email.deliver
80
80
  end
81
81
 
82
82
  == Testing
83
83
 
84
84
  Before you can run any tests, the following gem must be installed:
85
- * plugin_test_helper[http://wiki.pluginaweek.org/Plugin_test_helper]
85
+ * plugin_test_helper[http://github.com/pluginaweek/plugin_test_helper]
86
86
 
87
87
  To run against a specific version of Rails:
88
88
 
@@ -91,6 +91,6 @@ To run against a specific version of Rails:
91
91
  == Dependencies
92
92
 
93
93
  * Rails 2.1 or later
94
- * plugins_plus[http://wiki.pluginaweek.org/Plugins_plus]
95
- * has_messages[http://wiki.pluginaweek.org/Has_messages]
96
- * state_machine[http://wiki.pluginaweek.org/State_machine]
94
+ * plugins_plus[http://github.com/pluginaweek/plugins_plus]
95
+ * has_messages[http://github.com/pluginaweek/has_messages]
96
+ * state_machine[http://github.com/pluginaweek/state_machine]
data/Rakefile CHANGED
@@ -3,48 +3,56 @@ require 'rake/rdoctask'
3
3
  require 'rake/gempackagetask'
4
4
  require 'rake/contrib/sshpublisher'
5
5
 
6
- PKG_NAME = 'has_emails'
7
- PKG_VERSION = '0.1.1'
8
- PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
9
- RUBY_FORGE_PROJECT = 'pluginaweek'
10
-
11
- desc 'Default: run unit tests.'
6
+ spec = Gem::Specification.new do |s|
7
+ s.name = 'has_emails'
8
+ s.version = '0.1.2'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'Demonstrates a reference implementation for sending emails with logging and asynchronous support.'
11
+
12
+ s.files = FileList['{app,db,lib,test}/**/*'].to_a - FileList['test/app_root/log/*'].to_a + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc)
13
+ s.require_path = 'lib'
14
+ s.has_rdoc = true
15
+ s.test_files = Dir['test/**/*_test.rb']
16
+ s.add_dependency 'has_messages', '>= 0.1.2'
17
+ s.add_dependency 'validates_as_email_address', '>= 0.0.2'
18
+
19
+ s.author = 'Aaron Pfeifer'
20
+ s.email = 'aaron@pluginaweek.org'
21
+ s.homepage = 'http://www.pluginaweek.org'
22
+ s.rubyforge_project = 'pluginaweek'
23
+ end
24
+
25
+ desc 'Default: run all tests.'
12
26
  task :default => :test
13
27
 
14
- desc 'Test the has_emails plugin.'
28
+ desc "Test the #{spec.name} plugin."
15
29
  Rake::TestTask.new(:test) do |t|
16
30
  t.libs << 'lib'
17
- t.pattern = 'test/**/*_test.rb'
31
+ t.test_files = spec.test_files
18
32
  t.verbose = true
19
33
  end
20
34
 
21
- desc 'Generate documentation for the has_emails plugin.'
35
+ begin
36
+ require 'rcov/rcovtask'
37
+ namespace :test do
38
+ desc "Test the #{spec.name} plugin with Rcov."
39
+ Rcov::RcovTask.new(:rcov) do |t|
40
+ t.libs << 'lib'
41
+ t.test_files = spec.test_files
42
+ t.rcov_opts << '--exclude="^(?!lib/|app/)"'
43
+ t.verbose = true
44
+ end
45
+ end
46
+ rescue LoadError
47
+ end
48
+
49
+ desc "Generate documentation for the #{spec.name} plugin."
22
50
  Rake::RDocTask.new(:rdoc) do |rdoc|
23
51
  rdoc.rdoc_dir = 'rdoc'
24
- rdoc.title = 'HasEmails'
52
+ rdoc.title = spec.name
25
53
  rdoc.template = '../rdoc_template.rb'
26
54
  rdoc.options << '--line-numbers' << '--inline-source'
27
- rdoc.rdoc_files.include('README')
28
- rdoc.rdoc_files.include('lib/**/*.rb')
29
- end
30
-
31
- spec = Gem::Specification.new do |s|
32
- s.name = PKG_NAME
33
- s.version = PKG_VERSION
34
- s.platform = Gem::Platform::RUBY
35
- s.summary = 'Demonstrates a reference implementation for sending emails with logging and asynchronous support.'
36
-
37
- s.files = FileList['{app,db,lib,test}/**/*'].to_a - FileList['test/app_root/log/*'].to_a + %w(CHANGELOG init.rb MIT-LICENSE Rakefile README)
38
- s.require_path = 'lib'
39
- s.autorequire = 'has_emails'
40
- s.has_rdoc = true
41
- s.test_files = Dir['test/**/*_test.rb']
42
- s.add_dependency 'has_messages', '>= 0.1.0'
43
- s.add_dependency 'validates_as_email_address', '>= 0.0.2'
44
-
45
- s.author = 'Aaron Pfeifer'
46
- s.email = 'aaron@pluginaweek.org'
47
- s.homepage = 'http://www.pluginaweek.org'
55
+ rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb', 'app/**/*.rb')
48
56
  end
49
57
 
50
58
  Rake::GemPackageTask.new(spec) do |p|
@@ -53,14 +61,14 @@ Rake::GemPackageTask.new(spec) do |p|
53
61
  p.need_zip = true
54
62
  end
55
63
 
56
- desc 'Publish the beta gem'
64
+ desc 'Publish the beta gem.'
57
65
  task :pgem => [:package] do
58
- Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{PKG_FILE_NAME}.gem").upload
66
+ Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{spec.name}-#{spec.version}.gem").upload
59
67
  end
60
68
 
61
- desc 'Publish the API documentation'
69
+ desc 'Publish the API documentation.'
62
70
  task :pdoc => [:rdoc] do
63
- Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{PKG_NAME}", 'rdoc').upload
71
+ Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{spec.name}", 'rdoc').upload
64
72
  end
65
73
 
66
74
  desc 'Publish the API docs and gem'
@@ -73,10 +81,10 @@ task :release => [:gem, :package] do
73
81
  ruby_forge = RubyForge.new.configure
74
82
  ruby_forge.login
75
83
 
76
- %w( gem tgz zip ).each do |ext|
77
- file = "pkg/#{PKG_FILE_NAME}.#{ext}"
84
+ %w(gem tgz zip).each do |ext|
85
+ file = "pkg/#{spec.name}-#{spec.version}.#{ext}"
78
86
  puts "Releasing #{File.basename(file)}..."
79
87
 
80
- ruby_forge.add_release(RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, file)
88
+ ruby_forge.add_release(spec.rubyforge_project, spec.name, spec.version, file)
81
89
  end
82
90
  end
data/test/factory.rb CHANGED
@@ -1,26 +1,32 @@
1
1
  module Factory
2
- # Build actions for the class
3
- def self.build(klass, &block)
4
- name = klass.to_s.underscore
5
- define_method("#{name}_attributes", block)
2
+ # Build actions for the model
3
+ def self.build(model, &block)
4
+ name = model.to_s.underscore
6
5
 
7
- module_eval <<-end_eval
8
- def valid_#{name}_attributes(attributes = {})
9
- #{name}_attributes(attributes)
10
- attributes
11
- end
12
-
13
- def new_#{name}(attributes = {})
14
- #{klass}.new(valid_#{name}_attributes(attributes))
15
- end
16
-
17
- def create_#{name}(*args)
18
- record = new_#{name}(*args)
19
- record.save!
20
- record.reload
21
- record
22
- end
23
- end_eval
6
+ define_method("#{name}_attributes", block)
7
+ define_method("valid_#{name}_attributes") {|*args| valid_attributes_for(model, *args)}
8
+ define_method("new_#{name}") {|*args| new_record(model, *args)}
9
+ define_method("create_#{name}") {|*args| create_record(model, *args)}
10
+ end
11
+
12
+ # Get valid attributes for the model
13
+ def valid_attributes_for(model, attributes = {})
14
+ name = model.to_s.underscore
15
+ send("#{name}_attributes", attributes)
16
+ attributes
17
+ end
18
+
19
+ # Build an unsaved record
20
+ def new_record(model, *args)
21
+ model.new(valid_attributes_for(model, *args))
22
+ end
23
+
24
+ # Build and save/reload a record
25
+ def create_record(model, *args)
26
+ record = new_record(model, *args)
27
+ record.save!
28
+ record.reload
29
+ record
24
30
  end
25
31
 
26
32
  build Email do |attributes|
@@ -36,7 +36,7 @@ class EmailAddresFunctionalsTest < Test::Unit::TestCase
36
36
  def test_should_be_able_to_send_new_emails
37
37
  email = @email_address.emails.build
38
38
  email.to create_email_address(:spec => 'jane.smith@gmail.com')
39
- assert email.deliver!
39
+ assert email.deliver
40
40
  end
41
41
  end
42
42
 
@@ -44,7 +44,7 @@ class EmailAddressWithUnsentEmails < Test::Unit::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'))
47
- @sent_email.deliver!
47
+ @sent_email.deliver
48
48
  @first_draft = create_email(:sender => @email_address)
49
49
  @second_draft = create_email(:sender => @email_address)
50
50
  end
@@ -65,10 +65,10 @@ class EmailAddressWithSentEmails < Test::Unit::TestCase
65
65
  @draft = create_email(:sender => @email_address)
66
66
 
67
67
  @first_sent_email = create_email(:sender => @email_address, :to => @to)
68
- @first_sent_email.deliver!
68
+ @first_sent_email.deliver
69
69
 
70
70
  @second_sent_email = create_email(:sender => @email_address, :to => @to)
71
- @second_sent_email.deliver!
71
+ @second_sent_email.deliver
72
72
  end
73
73
 
74
74
  def test_should_have_sent_emails
@@ -88,10 +88,10 @@ class EmailAddressWithReceivedEmails < Test::Unit::TestCase
88
88
  @unsent_email = create_email(:sender => @sender, :to => @email_address)
89
89
 
90
90
  @first_sent_email = create_email(:sender => @sender, :to => @email_address)
91
- @first_sent_email.deliver!
91
+ @first_sent_email.deliver
92
92
 
93
93
  @second_sent_email = create_email(:sender => @sender, :to => @email_address)
94
- @second_sent_email.deliver!
94
+ @second_sent_email.deliver
95
95
  end
96
96
 
97
97
  def test_should_have_received_emails
@@ -109,16 +109,16 @@ class EmailAddressWithHiddenEmailsTest < Test::Unit::TestCase
109
109
  @unsent_email = create_email(:sender => @email_address)
110
110
 
111
111
  hidden_sent_email = create_email(:sender => @email_address, :to => @friend)
112
- hidden_sent_email.deliver!
112
+ hidden_sent_email.deliver
113
113
  hidden_sent_email.hide!
114
114
  @sent_email = create_email(:sender => @email_address, :to => @friend)
115
- @sent_email.deliver!
115
+ @sent_email.deliver
116
116
 
117
117
  hidden_received_email = create_email(:sender => @friend, :to => @email_address)
118
- hidden_received_email.deliver!
118
+ hidden_received_email.deliver
119
119
  hidden_received_email.recipients.first.hide!
120
120
  @received_email = create_email(:sender => @friend, :to => @email_address)
121
- @received_email.deliver!
121
+ @received_email.deliver
122
122
  end
123
123
 
124
124
  def test_should_not_include_hidden_emails_in_emails
@@ -12,7 +12,7 @@ class EmailAfterBeingDeliveredTest < Test::Unit::TestCase
12
12
  :cc => create_email_address(:spec => 'support@localhost'),
13
13
  :bcc => create_email_address(:spec => 'feedback@localhost')
14
14
  )
15
- assert @email.deliver!
15
+ assert @email.deliver
16
16
  end
17
17
 
18
18
  def test_should_send_mail
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_emails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
8
- autorequire: has_emails
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-22 00:00:00 -04:00
12
+ date: 2008-06-29 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.1.0
22
+ version: 0.1.2
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: validates_as_email_address
@@ -67,11 +67,11 @@ files:
67
67
  - test/unit/email_address_test.rb
68
68
  - test/unit/action_mailer_test.rb
69
69
  - test/unit/email_test.rb
70
- - CHANGELOG
70
+ - CHANGELOG.rdoc
71
71
  - init.rb
72
- - MIT-LICENSE
72
+ - LICENSE
73
73
  - Rakefile
74
- - README
74
+ - README.rdoc
75
75
  has_rdoc: true
76
76
  homepage: http://www.pluginaweek.org
77
77
  post_install_message:
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version:
94
94
  requirements: []
95
95
 
96
- rubyforge_project:
96
+ rubyforge_project: pluginaweek
97
97
  rubygems_version: 1.1.1
98
98
  signing_key:
99
99
  specification_version: 2
File without changes