bmabey-email_spec 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Rakefile +7 -6
- data/examples/rails_root/Rakefile +6 -0
- data/examples/rails_root/app/controllers/welcome_controller.rb +3 -0
- data/examples/rails_root/app/models/user_mailer.rb +7 -0
- data/examples/rails_root/app/views/user_mailer/newsletter.erb +8 -0
- data/examples/rails_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails_root/config/environment.rb +1 -1
- data/examples/rails_root/config/environments/test.rb +6 -5
- data/examples/rails_root/config/routes.rb +2 -1
- data/examples/rails_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
- data/examples/rails_root/db/schema.rb +14 -1
- data/examples/rails_root/features/delayed_job.feature +13 -0
- data/examples/rails_root/features/support/paths.rb +3 -0
- data/examples/rails_root/script/delayed_job +5 -0
- data/lib/email_spec/background_processes.rb +31 -0
- data/lib/email_spec/deliveries.rb +1 -0
- data/lib/email_spec.rb +1 -0
- metadata +8 -2
data/History.txt
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
=== New features
|
4
4
|
=== Bufixes
|
5
5
|
|
6
|
+
== 0.3.2 2009-09-10
|
7
|
+
|
8
|
+
=== New features
|
9
|
+
* Support for delayed_job. (Kieran Pilkington)
|
10
|
+
|
6
11
|
== 0.3.1 2009-08-19
|
7
12
|
This release is a general refactoring of the steps and helpers.
|
8
13
|
The example rails app was also updated to use the lateset rails and webrat. It also takes advantages
|
data/Rakefile
CHANGED
@@ -25,12 +25,13 @@ rescue LoadError
|
|
25
25
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
begin
|
30
|
-
|
31
|
-
rescue Gem::LoadError
|
32
|
-
|
33
|
-
|
28
|
+
%w[collectiveidea-delayed_job fixjour].each do |gem_name|
|
29
|
+
begin
|
30
|
+
gem gem_name
|
31
|
+
rescue Gem::LoadError
|
32
|
+
puts "Installing #{gem_name} for the example rails app..."
|
33
|
+
puts `gem install #{gem_name} --no-rdoc --no-ri`
|
34
|
+
end
|
34
35
|
end
|
35
36
|
|
36
37
|
begin
|
File without changes
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# ENV['RAILS_ENV'] ||= 'production'
|
6
6
|
|
7
7
|
# Specifies gem version of Rails to use when vendor/rails is not present
|
8
|
-
RAILS_GEM_VERSION = '2.3.
|
8
|
+
RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
|
9
9
|
|
10
10
|
# Bootstrap the Rails environment, frameworks, and default configuration
|
11
11
|
require File.join(File.dirname(__FILE__), 'boot')
|
@@ -22,8 +22,9 @@ config.action_controller.allow_forgery_protection = false
|
|
22
22
|
config.action_mailer.delivery_method = :test
|
23
23
|
config.action_mailer.default_url_options = { :host => "example.com" }
|
24
24
|
|
25
|
-
config.gem 'cucumber',
|
26
|
-
config.gem 'webrat',
|
27
|
-
config.gem 'rspec',
|
28
|
-
config.gem 'rspec-rails',
|
29
|
-
config.gem 'fixjour',
|
25
|
+
config.gem 'cucumber', :lib => false
|
26
|
+
config.gem 'webrat', :lib => false
|
27
|
+
config.gem 'rspec', :lib => false
|
28
|
+
config.gem 'rspec-rails', :lib => 'spec/rails'
|
29
|
+
config.gem 'fixjour', :lib => 'fixjour'
|
30
|
+
config.gem 'collectiveidea-delayed_job', :lib => 'delayed_job', :source => 'http://gems.github.com'
|
@@ -17,7 +17,7 @@ ActionController::Routing::Routes.draw do |map|
|
|
17
17
|
|
18
18
|
# Sample resource route with sub-resources:
|
19
19
|
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
20
|
-
|
20
|
+
|
21
21
|
# Sample resource route with more complex sub-resources
|
22
22
|
# map.resources :products do |products|
|
23
23
|
# products.resources :comments
|
@@ -33,6 +33,7 @@ ActionController::Routing::Routes.draw do |map|
|
|
33
33
|
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
34
34
|
map.root :controller => "welcome", :action => "index"
|
35
35
|
map.confirm_account "/confirm", :controller => "welcome", :action => "confirm"
|
36
|
+
map.request_newsletter "/newsletter", :controller => "welcome", :action => "newsletter"
|
36
37
|
# See how all your routes lay out with "rake routes"
|
37
38
|
|
38
39
|
# Install the default routes as the lowest priority.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateDelayedJobs < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :delayed_jobs, :force => true do |table|
|
4
|
+
table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
|
5
|
+
table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
|
6
|
+
table.text :handler # YAML-encoded string of the object that will do work
|
7
|
+
table.text :last_error # reason for last failure (See Note below)
|
8
|
+
table.datetime :run_at # When to run. Could be Time.now for immediately, or sometime in the future.
|
9
|
+
table.datetime :locked_at # Set when a client is working on this object
|
10
|
+
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
|
11
|
+
table.string :locked_by # Who is working on this object (if locked)
|
12
|
+
table.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :delayed_jobs
|
19
|
+
end
|
20
|
+
end
|
@@ -9,7 +9,20 @@
|
|
9
9
|
#
|
10
10
|
# It's strongly recommended to check this file into your version control system.
|
11
11
|
|
12
|
-
ActiveRecord::Schema.define(:version =>
|
12
|
+
ActiveRecord::Schema.define(:version => 20090908054656) do
|
13
|
+
|
14
|
+
create_table "delayed_jobs", :force => true do |t|
|
15
|
+
t.integer "priority", :default => 0
|
16
|
+
t.integer "attempts", :default => 0
|
17
|
+
t.text "handler"
|
18
|
+
t.text "last_error"
|
19
|
+
t.datetime "run_at"
|
20
|
+
t.datetime "locked_at"
|
21
|
+
t.datetime "failed_at"
|
22
|
+
t.string "locked_by"
|
23
|
+
t.datetime "created_at"
|
24
|
+
t.datetime "updated_at"
|
25
|
+
end
|
13
26
|
|
14
27
|
create_table "users", :force => true do |t|
|
15
28
|
t.string "email"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Delayed Job support
|
2
|
+
In order for developers using delayed_job to test emails
|
3
|
+
I want to be able to provide a compatibility layer, which
|
4
|
+
should run all delayed jobs before checking email boxes
|
5
|
+
In order to populate deliveries done via send_later
|
6
|
+
|
7
|
+
Scenario: Newsletter
|
8
|
+
Given no emails have been sent
|
9
|
+
And I go to request a newsletter
|
10
|
+
Then I should receive an email
|
11
|
+
And I should have 1 email
|
12
|
+
When I open the email
|
13
|
+
Then I should see "Newsletter sent" in the email subject
|
@@ -11,6 +11,9 @@ module NavigationHelpers
|
|
11
11
|
when /the homepage/
|
12
12
|
'/'
|
13
13
|
|
14
|
+
when /request a newsletter/
|
15
|
+
request_newsletter_url('Name' => 'Joe Someone', 'Email' => 'example@example.com')
|
16
|
+
|
14
17
|
else
|
15
18
|
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
16
19
|
"Now, go and add a mapping in #{__FILE__}"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module EmailSpec
|
2
|
+
module BackgroundProcesses
|
3
|
+
module DelayedJob
|
4
|
+
def all_emails
|
5
|
+
Delayed::Job.work_off
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def last_email_sent
|
10
|
+
Delayed::Job.work_off
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset_mailer
|
15
|
+
Delayed::Job.work_off
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def mailbox_for(address)
|
20
|
+
Delayed::Job.work_off
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Compatibility
|
26
|
+
if defined?(Delayed)
|
27
|
+
include EmailSpec::BackgroundProcesses::DelayedJob
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/email_spec.rb
CHANGED
@@ -5,6 +5,7 @@ end
|
|
5
5
|
|
6
6
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
7
7
|
|
8
|
+
require 'email_spec/background_processes'
|
8
9
|
require 'email_spec/deliveries'
|
9
10
|
require 'email_spec/address_converter'
|
10
11
|
require 'email_spec/email_viewer'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmabey-email_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Mabey
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-
|
14
|
+
date: 2009-09-10 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- lib/email-spec.rb
|
34
34
|
- lib/email_spec.rb
|
35
35
|
- lib/email_spec/address_converter.rb
|
36
|
+
- lib/email_spec/background_processes.rb
|
36
37
|
- lib/email_spec/cucumber.rb
|
37
38
|
- lib/email_spec/deliveries.rb
|
38
39
|
- lib/email_spec/email_viewer.rb
|
@@ -85,10 +86,12 @@ test_files:
|
|
85
86
|
- examples/rails_root/app/models/user_mailer.rb
|
86
87
|
- examples/rails_root/app/views
|
87
88
|
- examples/rails_root/app/views/user_mailer
|
89
|
+
- examples/rails_root/app/views/user_mailer/newsletter.erb
|
88
90
|
- examples/rails_root/app/views/user_mailer/signup.erb
|
89
91
|
- examples/rails_root/app/views/welcome
|
90
92
|
- examples/rails_root/app/views/welcome/confirm.html.erb
|
91
93
|
- examples/rails_root/app/views/welcome/index.html.erb
|
94
|
+
- examples/rails_root/app/views/welcome/newsletter.html.erb
|
92
95
|
- examples/rails_root/app/views/welcome/signup.html.erb
|
93
96
|
- examples/rails_root/config
|
94
97
|
- examples/rails_root/config/boot.rb
|
@@ -106,10 +109,12 @@ test_files:
|
|
106
109
|
- examples/rails_root/db
|
107
110
|
- examples/rails_root/db/migrate
|
108
111
|
- examples/rails_root/db/migrate/20090125013728_create_users.rb
|
112
|
+
- examples/rails_root/db/migrate/20090908054656_create_delayed_jobs.rb
|
109
113
|
- examples/rails_root/db/schema.rb
|
110
114
|
- examples/rails_root/doc
|
111
115
|
- examples/rails_root/doc/README_FOR_APP
|
112
116
|
- examples/rails_root/features
|
117
|
+
- examples/rails_root/features/delayed_job.feature
|
113
118
|
- examples/rails_root/features/errors.feature
|
114
119
|
- examples/rails_root/features/example.feature
|
115
120
|
- examples/rails_root/features/step_definitions
|
@@ -140,6 +145,7 @@ test_files:
|
|
140
145
|
- examples/rails_root/script/console
|
141
146
|
- examples/rails_root/script/cucumber
|
142
147
|
- examples/rails_root/script/dbconsole
|
148
|
+
- examples/rails_root/script/delayed_job
|
143
149
|
- examples/rails_root/script/destroy
|
144
150
|
- examples/rails_root/script/generate
|
145
151
|
- examples/rails_root/script/performance
|