glennr-email_spec 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +135 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.rdoc +125 -0
- data/Rakefile +75 -0
- data/examples/rails_root/Rakefile +13 -0
- data/examples/rails_root/app/controllers/application_controller.rb +15 -0
- data/examples/rails_root/app/controllers/welcome_controller.rb +12 -0
- data/examples/rails_root/app/helpers/application_helper.rb +3 -0
- data/examples/rails_root/app/helpers/welcome_helper.rb +2 -0
- data/examples/rails_root/app/models/user.rb +2 -0
- data/examples/rails_root/app/models/user_mailer.rb +18 -0
- data/examples/rails_root/app/views/user_mailer/newsletter.erb +8 -0
- data/examples/rails_root/app/views/user_mailer/signup.erb +3 -0
- data/examples/rails_root/app/views/welcome/confirm.html.erb +1 -0
- data/examples/rails_root/app/views/welcome/index.html.erb +8 -0
- data/examples/rails_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails_root/app/views/welcome/signup.html.erb +1 -0
- data/examples/rails_root/config/boot.rb +110 -0
- data/examples/rails_root/config/database.yml +22 -0
- data/examples/rails_root/config/environment.rb +22 -0
- data/examples/rails_root/config/environments/development.rb +17 -0
- data/examples/rails_root/config/environments/production.rb +24 -0
- data/examples/rails_root/config/environments/test.rb +30 -0
- data/examples/rails_root/config/initializers/inflections.rb +10 -0
- data/examples/rails_root/config/initializers/mime_types.rb +5 -0
- data/examples/rails_root/config/initializers/new_rails_defaults.rb +17 -0
- data/examples/rails_root/config/routes.rb +44 -0
- data/examples/rails_root/db/migrate/20090125013728_create_users.rb +11 -0
- data/examples/rails_root/db/migrate/20090908054656_create_delayed_jobs.rb +20 -0
- data/examples/rails_root/db/schema.rb +32 -0
- data/examples/rails_root/doc/README_FOR_APP +5 -0
- data/examples/rails_root/features/delayed_job.feature +13 -0
- data/examples/rails_root/features/errors.feature +32 -0
- data/examples/rails_root/features/example.feature +62 -0
- data/examples/rails_root/features/step_definitions/user_steps.rb +26 -0
- data/examples/rails_root/features/step_definitions/webrat_steps.rb +137 -0
- data/examples/rails_root/features/support/env.rb +32 -0
- data/examples/rails_root/features/support/paths.rb +24 -0
- data/examples/rails_root/public/404.html +30 -0
- data/examples/rails_root/public/422.html +30 -0
- data/examples/rails_root/public/500.html +33 -0
- data/examples/rails_root/public/dispatch.rb +10 -0
- data/examples/rails_root/public/favicon.ico +0 -0
- data/examples/rails_root/public/images/rails.png +0 -0
- data/examples/rails_root/public/javascripts/application.js +2 -0
- data/examples/rails_root/public/javascripts/controls.js +963 -0
- data/examples/rails_root/public/javascripts/dragdrop.js +973 -0
- data/examples/rails_root/public/javascripts/effects.js +1128 -0
- data/examples/rails_root/public/javascripts/prototype.js +4320 -0
- data/examples/rails_root/public/robots.txt +5 -0
- data/examples/rails_root/script/about +4 -0
- data/examples/rails_root/script/autospec +5 -0
- data/examples/rails_root/script/console +3 -0
- data/examples/rails_root/script/cucumber +9 -0
- data/examples/rails_root/script/dbconsole +3 -0
- data/examples/rails_root/script/delayed_job +5 -0
- data/examples/rails_root/script/destroy +3 -0
- data/examples/rails_root/script/generate +3 -0
- data/examples/rails_root/script/performance/benchmarker +3 -0
- data/examples/rails_root/script/performance/profiler +3 -0
- data/examples/rails_root/script/performance/request +3 -0
- data/examples/rails_root/script/plugin +3 -0
- data/examples/rails_root/script/process/inspector +3 -0
- data/examples/rails_root/script/process/reaper +3 -0
- data/examples/rails_root/script/process/spawner +3 -0
- data/examples/rails_root/script/runner +3 -0
- data/examples/rails_root/script/server +3 -0
- data/examples/rails_root/script/spec +5 -0
- data/examples/rails_root/script/spec_server +125 -0
- data/examples/rails_root/spec/controllers/welcome_controller_spec.rb +15 -0
- data/examples/rails_root/spec/model_factory.rb +6 -0
- data/examples/rails_root/spec/models/user_mailer_spec.rb +58 -0
- data/examples/rails_root/spec/models/user_spec.rb +5 -0
- data/examples/rails_root/spec/rcov.opts +2 -0
- data/examples/rails_root/spec/spec.opts +4 -0
- data/examples/rails_root/spec/spec_helper.rb +51 -0
- data/examples/sinatra/app.rb +33 -0
- data/examples/sinatra/features/errors.feature +32 -0
- data/examples/sinatra/features/example.feature +62 -0
- data/examples/sinatra/features/step_definitions/user_steps.rb +26 -0
- data/examples/sinatra/features/step_definitions/webrat_steps.rb +137 -0
- data/examples/sinatra/features/support/env.rb +33 -0
- data/examples/sinatra/features/support/paths.rb +24 -0
- data/install.rb +0 -0
- data/lib/email-spec.rb +1 -0
- data/lib/email_spec.rb +15 -0
- data/lib/email_spec/address_converter.rb +29 -0
- data/lib/email_spec/background_processes.rb +31 -0
- data/lib/email_spec/cucumber.rb +21 -0
- data/lib/email_spec/deliveries.rb +71 -0
- data/lib/email_spec/email_viewer.rb +70 -0
- data/lib/email_spec/helpers.rb +149 -0
- data/lib/email_spec/matchers.rb +186 -0
- data/rails_generators/email_spec/email_spec_generator.rb +17 -0
- data/rails_generators/email_spec/templates/email_steps.rb +122 -0
- data/spec/email_spec/matchers_spec.rb +213 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +4 -0
- metadata +154 -0
data/History.txt
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
(In Git)
|
2
|
+
|
3
|
+
=== New features
|
4
|
+
=== Bufixes
|
5
|
+
|
6
|
+
== 0.3.5 2009-09-30 The Pony Release!
|
7
|
+
|
8
|
+
=== New features
|
9
|
+
* Support for Pony mailer library. (Rob Holland)
|
10
|
+
|
11
|
+
== 0.3.4 2009-09-26
|
12
|
+
|
13
|
+
=== Bugfixes
|
14
|
+
* Typo and logic fixes for DeliverFrom matcher. (Yury Kotlyarov)
|
15
|
+
|
16
|
+
== 0.3.3 2009-09-18
|
17
|
+
|
18
|
+
=== New features
|
19
|
+
* DeliverFrom matcher. i.e. email.should deliver_from(blah) or email.should be_delivered_from(blah) (Diego Carrion)
|
20
|
+
|
21
|
+
== 0.3.2 2009-09-10
|
22
|
+
|
23
|
+
=== New features
|
24
|
+
* Support for delayed_job. (Kieran Pilkington)
|
25
|
+
|
26
|
+
== 0.3.1 2009-08-19
|
27
|
+
This release is a general refactoring of the steps and helpers.
|
28
|
+
The example rails app was also updated to use the lateset rails and webrat. It also takes advantages
|
29
|
+
and the newer step definistions including the new third-person forms.
|
30
|
+
|
31
|
+
Some of the generated steps are being removed in favor of some of the newer ones. The older ones
|
32
|
+
will remain until 0.4.0 but will issue deprecation warnings.
|
33
|
+
|
34
|
+
Big shoutout to Kieran Pilkington who did the majority of work for this release.
|
35
|
+
|
36
|
+
== 0.3.0 2009-08-13
|
37
|
+
|
38
|
+
=== New features
|
39
|
+
* New helper #last_email_address which returns the last address used by email-spec for that scenario. (Ben Mabey)
|
40
|
+
* Steps now support third person language. (Kieran P)
|
41
|
+
* "[email] should receive ... " now supports "an" instead of just an integer. (Kieran Pilkington)
|
42
|
+
With these changes, the following is now possible:
|
43
|
+
|
44
|
+
Then "jack@example.com" should receive an email
|
45
|
+
When they open the email
|
46
|
+
Then they should see "Account has been created" in the subject
|
47
|
+
|
48
|
+
* Additional default steps (Balint Erdi)
|
49
|
+
* Then /^I should not receive any emails?$/
|
50
|
+
* When %r{^"([^"]*?)" opens? the email$} do |address|
|
51
|
+
|
52
|
+
=== Bufixes
|
53
|
+
|
54
|
+
== 0.2.1 2009-5-29
|
55
|
+
|
56
|
+
=== New Features
|
57
|
+
* BCC RSpec matcher. (Josh Nichols)
|
58
|
+
|
59
|
+
=== Bugfixes
|
60
|
+
* Include BCCed and CCed messsages in the mailbox. (Jakub Kosiński)
|
61
|
+
|
62
|
+
== 0.2.0 2009-6-08
|
63
|
+
No changes. Bumping version for RubyForge release.
|
64
|
+
|
65
|
+
|
66
|
+
== 0.1.4 2009-5-29
|
67
|
+
|
68
|
+
=== Bufixes
|
69
|
+
* Require deliveries in the helpers so it doesn't blow up with RSpec. (Craig Webster)
|
70
|
+
|
71
|
+
== 0.1.3 2009-4-15
|
72
|
+
|
73
|
+
=== Bufixes
|
74
|
+
* Fixed regular expressions in genertaed steps. (Ben Mabey)
|
75
|
+
* World semantics changed in cucumber (0.2.3.2), email_spec now uses the new API. (Hector Morales)
|
76
|
+
|
77
|
+
== 0.1.2 2009-4-05
|
78
|
+
|
79
|
+
=== New features
|
80
|
+
=== Bufixes
|
81
|
+
* Actually added the renamed generators to the gem so people could use it! D'oh! (Ben Mabey)
|
82
|
+
* You can either use "./script generate email_spec" or "rubigen rails email_spec"
|
83
|
+
* Removed Rake tasks from example application to prevent conflicts when used as a plugin. (Ben Mabey)
|
84
|
+
|
85
|
+
== 0.1.1 2009-3-26
|
86
|
+
=== New features
|
87
|
+
* Switched dir structure over to support rubigen. (Dr. Nic)
|
88
|
+
|
89
|
+
=== Bufixes
|
90
|
+
|
91
|
+
== 0.1.0 2009-3-25
|
92
|
+
=== New features
|
93
|
+
* Change Rakefile to run all specs and features, as well as prepare the db (Mischa Fierer)
|
94
|
+
* Allow for array to be passed into deliver_to matcher. (Diego Carrion)
|
95
|
+
* Added matcher for checking if a collection of emails includes an email with a particular subject (Luke Melia, Noah Davis)
|
96
|
+
* Introduced hook to convert objects to email addresses (Luke Melia and Lee Bankewitz)
|
97
|
+
|
98
|
+
This allows you, in your step matcher, to say something like:
|
99
|
+
maillbox_for(some_user)
|
100
|
+
|
101
|
+
Use it in your cucumber env.rb like so:
|
102
|
+
|
103
|
+
EmailSpec::AddressConverter.instance.conversion do |input|
|
104
|
+
if input.is_a?(User)
|
105
|
+
input.email
|
106
|
+
else
|
107
|
+
input
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
=== Bufixes
|
112
|
+
* Revert parse_email_for_link helper method to allow for text links as well as explicit link finding. (Mischa Fierer)
|
113
|
+
* Isolated variances between using email-spec with an ARMailer project. (Luke Melia)
|
114
|
+
|
115
|
+
|
116
|
+
== 0.0.9 2009-2-15
|
117
|
+
=== New features
|
118
|
+
* have_body_text, have_header matchers (Luke Melia)
|
119
|
+
* EmailViewer - opens all sent emails in a given scenario when the environment variables are set. (Luke Melia)
|
120
|
+
* Added compatibility with using ARMailer in test mode. (Luke Melia)
|
121
|
+
=== Bugfixes
|
122
|
+
* set_current_email now works with multiple addresses in To field. (Brian McManus, Ben Mabey)
|
123
|
+
|
124
|
+
== 0.0.7 2009-1-20
|
125
|
+
=== New features
|
126
|
+
* have_subject matcher (Ben Mabey)
|
127
|
+
|
128
|
+
== 0.0.6 2008-12-23
|
129
|
+
=== New features
|
130
|
+
* Improved RSpec documentation and refactorings. (Ben Mabey)
|
131
|
+
=== Bugfixes
|
132
|
+
* Removed sample app Rake Tasks to have it play nice with environments that use Cucumber as plugin- not gem. (Ben Mabey, Ivor- on github)
|
133
|
+
|
134
|
+
== 0.0.5 2008-12-18
|
135
|
+
* Initial release - see this post for full history and contributors: http://www.benmabey.com/2008/12/18/github-rocks/
|
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008-2009 Ben Mabey
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
= Email Spec
|
2
|
+
|
3
|
+
A collection of RSpec matchers and Cucumber steps to make testing emails go smoothly.
|
4
|
+
|
5
|
+
|
6
|
+
== Setup
|
7
|
+
|
8
|
+
script/plugin install git://github.com/bmabey/email-spec.git
|
9
|
+
|
10
|
+
=== Gem Setup
|
11
|
+
|
12
|
+
gem install email_spec
|
13
|
+
|
14
|
+
# config/environments/test.rb
|
15
|
+
config.gem 'email_spec', :lib => 'email_spec'
|
16
|
+
|
17
|
+
=== Cucumber
|
18
|
+
|
19
|
+
To use the steps in features put the following in your env.rb:
|
20
|
+
|
21
|
+
# Make sure this require is after you require cucumber/rails/world.
|
22
|
+
require 'email_spec/cucumber'
|
23
|
+
|
24
|
+
This will load all the helpers that the steps rely on.
|
25
|
+
It will also add a Before hook for Cucumber so that emails are cleared at the start of each scenario.
|
26
|
+
|
27
|
+
Then:
|
28
|
+
|
29
|
+
script/generate email_spec
|
30
|
+
|
31
|
+
This will give you a bunch of steps to get started with in step_definitions/email_steps.rb
|
32
|
+
|
33
|
+
=== RSpec
|
34
|
+
|
35
|
+
First you need to require the helpers and matchers in your spec_helper.rb like so:
|
36
|
+
|
37
|
+
require "email_spec/helpers"
|
38
|
+
require "email_spec/matchers"
|
39
|
+
|
40
|
+
You will then need to include EmailSpec::Helpers and EmailSpec::Matchers in your example groups.
|
41
|
+
If you want to have access to the helpers and matchers in all of your examples you can do the following in your spec_helper.rb:
|
42
|
+
|
43
|
+
Spec::Runner.configure do |config|
|
44
|
+
config.include(EmailSpec::Helpers)
|
45
|
+
config.include(EmailSpec::Matchers)
|
46
|
+
end
|
47
|
+
|
48
|
+
Otherwise, you will need to include them in the example groups you wish to use them:
|
49
|
+
|
50
|
+
describe "Signup Email" do
|
51
|
+
include EmailSpec::Helpers
|
52
|
+
include EmailSpec::Matchers
|
53
|
+
...
|
54
|
+
end
|
55
|
+
|
56
|
+
== Usage
|
57
|
+
|
58
|
+
=== Cucumber
|
59
|
+
|
60
|
+
Scenario: A new person signs up
|
61
|
+
Given I am at "/"
|
62
|
+
When I fill in "Email" with "quentin@example.com"
|
63
|
+
And I press "Sign up"
|
64
|
+
And I should receive an email
|
65
|
+
When I open the email
|
66
|
+
Then I should see "confirm" in the email
|
67
|
+
When I follow "confirm" in the email
|
68
|
+
Then I should see "Confirm your new account"
|
69
|
+
|
70
|
+
For more examples, check out examples/rails_root in the source for a small example app that implements these steps.
|
71
|
+
|
72
|
+
=== RSpec
|
73
|
+
|
74
|
+
==== Testing In Isolation ====
|
75
|
+
It is often useful to test your mailers in isolation. You can accomplish this by using mocks to verify that the mailer is being called in the correct place and then write focued examples for the actual mailer. This is a simple example from the sample app found in the gem:
|
76
|
+
|
77
|
+
Verify that the mailer is used correctly in the controller (this would apply to a model as well):
|
78
|
+
|
79
|
+
describe "POST /signup (#signup)" do
|
80
|
+
it "should deliver the signup email" do
|
81
|
+
# expect
|
82
|
+
UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean")
|
83
|
+
# when
|
84
|
+
post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
Examples for the #signup method in UserMailer:
|
89
|
+
|
90
|
+
describe "Signup Email" do
|
91
|
+
include EmailSpec::Helpers
|
92
|
+
include EmailSpec::Matchers
|
93
|
+
include ActionController::UrlWriter
|
94
|
+
|
95
|
+
before(:all) do
|
96
|
+
@email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should be set to be delivered to the email passed in" do
|
100
|
+
@email.should deliver_to("jojo@yahoo.com")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should contain the user's message in the mail body" do
|
104
|
+
@email.should have_text(/Jojo Binks/)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should contain a link to the confirmation link" do
|
108
|
+
@email.should have_text(/#{confirm_account_url}/)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should have the correct subject" do
|
112
|
+
@email.should have_subject(/Account confirmation/)
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
==== Using the helpers when not testing in isolation ====
|
118
|
+
|
119
|
+
Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish.
|
120
|
+
|
121
|
+
== Original Authors
|
122
|
+
|
123
|
+
Ben Mabey, Aaron Gibralter, Mischa Fierer
|
124
|
+
|
125
|
+
Please see History.txt for upcoming changsets and other contributors.
|
data/Rakefile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |s|
|
8
|
+
s.name = "email_spec"
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ['Ben Mabey', 'Aaron Gibralter', 'Mischa Fierer']
|
11
|
+
s.email = "ben@benmabey.com"
|
12
|
+
s.homepage = "http://github.com/bmabey/email-spec/"
|
13
|
+
s.summary = "Easily test email in rspec and cucumber"
|
14
|
+
s.bindir = "bin"
|
15
|
+
s.description = s.summary
|
16
|
+
s.require_path = "lib"
|
17
|
+
s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["rails_generators/**/*"]
|
18
|
+
s.test_files = Dir["spec/**/*"] + Dir["examples/**/*"]
|
19
|
+
# rdoc
|
20
|
+
s.has_rdoc = true
|
21
|
+
s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
|
22
|
+
s.rubyforge_project = 'email-spec'
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
26
|
+
end
|
27
|
+
|
28
|
+
# TODO: Maybe use geminstaller instead?
|
29
|
+
%w[collectiveidea-delayed_job fixjour pony sinatra rack-test].each do |gem_name|
|
30
|
+
begin
|
31
|
+
gem gem_name
|
32
|
+
rescue Gem::LoadError
|
33
|
+
puts "Installing #{gem_name} for the example rails app..."
|
34
|
+
puts `gem install #{gem_name} --no-rdoc --no-ri`
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'cucumber/rake/task'
|
40
|
+
Cucumber::Rake::Task.new(:features)
|
41
|
+
rescue LoadError
|
42
|
+
task :features do
|
43
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
require 'spec/rake/spectask'
|
48
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
49
|
+
spec.libs << 'lib' << 'spec'
|
50
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
51
|
+
end
|
52
|
+
|
53
|
+
namespace :example_app do
|
54
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
55
|
+
desc "Specs for Example app"
|
56
|
+
spec.libs << 'lib' << 'spec'
|
57
|
+
spec.spec_files = FileList['examples/rails_root/spec/**/*_spec.rb']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
task :default => [:features, :spec, 'example_app:spec']
|
62
|
+
|
63
|
+
desc "Cleans the project of any tmp file that should not be included in the gemspec."
|
64
|
+
task :clean do
|
65
|
+
FileUtils.rm_f('examples/rails_root/features/step_definitions/email_steps.rb')
|
66
|
+
FileUtils.rm_rf('examples/rails_root/log')
|
67
|
+
FileUtils.rm_rf('examples/rails_root/vendor')
|
68
|
+
%w[*.sqlite3 *.log].each do |pattern|
|
69
|
+
`find . -name "#{pattern}" -delete`
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Cleans the dir and builds the gem"
|
74
|
+
task :prep => [:clean, :gemspec, :build]
|
75
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
|
7
|
+
require 'tasks/rails'
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'delayed/tasks'
|
11
|
+
rescue LoadError
|
12
|
+
STDERR.puts "Run `rake gems:install` to install delayed_job"
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
|
7
|
+
# See ActionController::RequestForgeryProtection for details
|
8
|
+
# Uncomment the :secret if you're not using the cookie session store
|
9
|
+
protect_from_forgery # :secret => 'a74714b35b202f269f7a297709d555ce'
|
10
|
+
|
11
|
+
# See ActionController::Base for details
|
12
|
+
# Uncomment this to filter the contents of submitted sensitive data parameters
|
13
|
+
# from your application log (in this case, all fields with names like "password").
|
14
|
+
# filter_parameter_logging :password
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class WelcomeController < ApplicationController
|
2
|
+
def signup
|
3
|
+
UserMailer.deliver_signup(params['Email'], params['Name'])
|
4
|
+
end
|
5
|
+
|
6
|
+
def confirm
|
7
|
+
end
|
8
|
+
|
9
|
+
def newsletter
|
10
|
+
UserMailer.send_later(:deliver_newsletter, params['Email'], params['Name'])
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class UserMailer < ActionMailer::Base
|
2
|
+
default_url_options = {:host => 'example.com'}
|
3
|
+
def signup(email, name)
|
4
|
+
@recipients = email
|
5
|
+
@from = "admin@example.com"
|
6
|
+
@subject = "Account confirmation"
|
7
|
+
@sent_on = Time.now
|
8
|
+
@body[:name] = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def newsletter(email, name)
|
12
|
+
@recipients = email
|
13
|
+
@from = "admin@example.com"
|
14
|
+
@subject = "Newsletter sent"
|
15
|
+
@sent_on = Time.now
|
16
|
+
@body[:name] = name
|
17
|
+
end
|
18
|
+
end
|