email_spec 1.2.1 → 1.4.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/History.txt +17 -1
- data/README.md +340 -0
- data/Rakefile +3 -50
- data/lib/email_spec.rb +3 -2
- data/lib/email_spec/email_viewer.rb +10 -6
- data/lib/email_spec/errors.rb +7 -0
- data/lib/email_spec/helpers.rb +5 -3
- data/lib/email_spec/matchers.rb +166 -66
- data/rails_generators/email_spec/templates/email_steps.rb +1 -1
- metadata +290 -236
- data/README.rdoc +0 -148
- data/examples/rails3_root/Gemfile +0 -17
- data/examples/rails3_root/Gemfile.lock +0 -135
- data/examples/rails3_root/README +0 -5
- data/examples/rails3_root/Rakefile +0 -11
- data/examples/rails3_root/app/controllers/application_controller.rb +0 -3
- data/examples/rails3_root/app/controllers/welcome_controller.rb +0 -16
- data/examples/rails3_root/app/helpers/application_helper.rb +0 -2
- data/examples/rails3_root/app/mailers/user_mailer.rb +0 -39
- data/examples/rails3_root/app/models/user.rb +0 -2
- data/examples/rails3_root/app/views/user_mailer/attachments.html.erb +0 -6
- data/examples/rails3_root/app/views/user_mailer/newsletter.html.erb +0 -8
- data/examples/rails3_root/app/views/user_mailer/signup.html.erb +0 -4
- data/examples/rails3_root/app/views/user_mailer/signup.text.erb +0 -4
- data/examples/rails3_root/app/views/welcome/attachments.html.erb +0 -0
- data/examples/rails3_root/app/views/welcome/confirm.html.erb +0 -1
- data/examples/rails3_root/app/views/welcome/index.html.erb +0 -8
- data/examples/rails3_root/app/views/welcome/newsletter.html.erb +0 -0
- data/examples/rails3_root/app/views/welcome/signup.html.erb +0 -1
- data/examples/rails3_root/attachments/document.pdf +0 -0
- data/examples/rails3_root/attachments/image.png +0 -0
- data/examples/rails3_root/config.ru +0 -4
- data/examples/rails3_root/config/application.rb +0 -43
- data/examples/rails3_root/config/boot.rb +0 -14
- data/examples/rails3_root/config/cucumber.yml +0 -8
- data/examples/rails3_root/config/database.yml +0 -25
- data/examples/rails3_root/config/environment.rb +0 -6
- data/examples/rails3_root/config/environments/development.rb +0 -20
- data/examples/rails3_root/config/environments/production.rb +0 -42
- data/examples/rails3_root/config/environments/test.rb +0 -30
- data/examples/rails3_root/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/rails3_root/config/initializers/cookie_verification_secret.rb +0 -7
- data/examples/rails3_root/config/initializers/delayed_job.rb +0 -1
- data/examples/rails3_root/config/initializers/inflections.rb +0 -10
- data/examples/rails3_root/config/initializers/mime_types.rb +0 -5
- data/examples/rails3_root/config/initializers/notifier_job.rb +0 -1
- data/examples/rails3_root/config/initializers/rspec_generator.rb +0 -6
- data/examples/rails3_root/config/initializers/session_store.rb +0 -10
- data/examples/rails3_root/config/locales/en.yml +0 -5
- data/examples/rails3_root/config/routes.rb +0 -7
- data/examples/rails3_root/db/migrate/20090125013728_create_users.rb +0 -11
- data/examples/rails3_root/db/migrate/20090908054656_create_delayed_jobs.rb +0 -20
- data/examples/rails3_root/db/schema.rb +0 -33
- data/examples/rails3_root/db/seeds.rb +0 -7
- data/examples/rails3_root/doc/README_FOR_APP +0 -2
- data/examples/rails3_root/features/attachments.feature +0 -27
- data/examples/rails3_root/features/delayed_job.feature +0 -13
- data/examples/rails3_root/features/errors.feature +0 -40
- data/examples/rails3_root/features/example.feature +0 -93
- data/examples/rails3_root/features/step_definitions/user_steps.rb +0 -26
- data/examples/rails3_root/features/step_definitions/web_steps.rb +0 -219
- data/examples/rails3_root/features/support/env.rb +0 -58
- data/examples/rails3_root/features/support/env_ext.rb +0 -2
- data/examples/rails3_root/features/support/paths.rb +0 -33
- data/examples/rails3_root/lib/notifier_job.rb +0 -5
- data/examples/rails3_root/lib/tasks/cucumber.rake +0 -53
- data/examples/rails3_root/lib/tasks/rspec.rake +0 -69
- data/examples/rails3_root/public/404.html +0 -26
- data/examples/rails3_root/public/422.html +0 -26
- data/examples/rails3_root/public/500.html +0 -26
- data/examples/rails3_root/public/favicon.ico +0 -0
- data/examples/rails3_root/public/images/rails.png +0 -0
- data/examples/rails3_root/public/javascripts/application.js +0 -2
- data/examples/rails3_root/public/javascripts/controls.js +0 -965
- data/examples/rails3_root/public/javascripts/dragdrop.js +0 -974
- data/examples/rails3_root/public/javascripts/effects.js +0 -1123
- data/examples/rails3_root/public/javascripts/prototype.js +0 -4874
- data/examples/rails3_root/public/javascripts/rails.js +0 -109
- data/examples/rails3_root/public/robots.txt +0 -5
- data/examples/rails3_root/script/cucumber +0 -10
- data/examples/rails3_root/script/rails +0 -9
- data/examples/rails3_root/spec/controllers/welcome_controller_spec.rb +0 -20
- data/examples/rails3_root/spec/models/user_mailer_spec.rb +0 -47
- data/examples/rails3_root/spec/spec_helper.rb +0 -19
- data/examples/sinatra_root/config.ru +0 -4
- data/examples/sinatra_root/features/errors.feature +0 -40
- data/examples/sinatra_root/features/example.feature +0 -93
- data/examples/sinatra_root/features/step_definitions/user_steps.rb +0 -26
- data/examples/sinatra_root/features/step_definitions/web_steps.rb +0 -219
- data/examples/sinatra_root/features/support/env.rb +0 -21
- data/examples/sinatra_root/features/support/paths.rb +0 -29
- data/examples/sinatra_root/lib/example_sinatra_app.rb +0 -45
- data/install.rb +0 -0
- data/spec/email_spec/helpers_spec.rb +0 -220
- data/spec/email_spec/mail_ext_spec.rb +0 -34
- data/spec/email_spec/matchers_spec.rb +0 -486
- data/spec/spec_helper.rb +0 -16
data/README.rdoc
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
= Email Spec
|
|
2
|
-
|
|
3
|
-
A collection of RSpec matchers and Cucumber steps to make testing emails go smoothly.
|
|
4
|
-
|
|
5
|
-
This library works with ActionMailer and Pony. When using it with ActionMailer it works with
|
|
6
|
-
DelayedJob, ActiveRecord Mailer, and action_mailer_cache_delivery.
|
|
7
|
-
|
|
8
|
-
When using the action_mailer_cache_delivery library you must use this fork:
|
|
9
|
-
http://github.com/liangzan/action_mailer_cache_delivery
|
|
10
|
-
|
|
11
|
-
If you are testing emails in conjunction with an automated browser solution, like Selenium,
|
|
12
|
-
you will want to use action_mailer_cache_delivery in your test environment. (This is
|
|
13
|
-
because your test process and server processes are distinct and therefore need an
|
|
14
|
-
intermediate store for the emails.) DelayedJob and ActiveRecord Mailer will also work but
|
|
15
|
-
you generally don't want to include those projects unless you need them in production.
|
|
16
|
-
|
|
17
|
-
== Setup
|
|
18
|
-
|
|
19
|
-
script/plugin install git://github.com/bmabey/email-spec.git
|
|
20
|
-
|
|
21
|
-
=== Gem Setup
|
|
22
|
-
|
|
23
|
-
gem install email_spec
|
|
24
|
-
|
|
25
|
-
# Gemfile
|
|
26
|
-
group :test do
|
|
27
|
-
gem 'email_spec'
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
=== Cucumber
|
|
31
|
-
|
|
32
|
-
To use the steps in features put the following in your env.rb:
|
|
33
|
-
|
|
34
|
-
# Make sure this require is after you require cucumber/rails/world.
|
|
35
|
-
require 'email_spec' # add this line if you use spork
|
|
36
|
-
require 'email_spec/cucumber'
|
|
37
|
-
|
|
38
|
-
This will load all the helpers that the steps rely on.
|
|
39
|
-
It will also add a Before hook for Cucumber so that emails are cleared at the start of each scenario.
|
|
40
|
-
|
|
41
|
-
Then:
|
|
42
|
-
|
|
43
|
-
rails generate email_spec:steps
|
|
44
|
-
|
|
45
|
-
This will give you a bunch of steps to get started with in step_definitions/email_steps.rb
|
|
46
|
-
|
|
47
|
-
By default, the generated file will look for email to example@example.com. You can either change this
|
|
48
|
-
by editing the current_email_address method in email_steps.rb, or by simply specifying the target
|
|
49
|
-
email in your features:
|
|
50
|
-
|
|
51
|
-
Scenario: A new person signs up
|
|
52
|
-
Given I am at "/"
|
|
53
|
-
When I fill in "Email" with "quentin@example.com"
|
|
54
|
-
And I press "Sign up"
|
|
55
|
-
And "quentin@example.com" should receive an email # Specify who should receive the email
|
|
56
|
-
|
|
57
|
-
=== RSpec
|
|
58
|
-
|
|
59
|
-
First you need to require email_spec in your spec_helper.rb:
|
|
60
|
-
|
|
61
|
-
require "email_spec"
|
|
62
|
-
|
|
63
|
-
You will then need to include EmailSpec::Helpers and EmailSpec::Matchers in your example groups.
|
|
64
|
-
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:
|
|
65
|
-
|
|
66
|
-
Spec::Runner.configure do |config|
|
|
67
|
-
config.include(EmailSpec::Helpers)
|
|
68
|
-
config.include(EmailSpec::Matchers)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
Otherwise, you will need to include them in the example groups you wish to use them:
|
|
72
|
-
|
|
73
|
-
describe "Signup Email" do
|
|
74
|
-
include EmailSpec::Helpers
|
|
75
|
-
include EmailSpec::Matchers
|
|
76
|
-
...
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
== Usage
|
|
80
|
-
|
|
81
|
-
=== Cucumber
|
|
82
|
-
|
|
83
|
-
Scenario: A new person signs up
|
|
84
|
-
Given I am at "/"
|
|
85
|
-
When I fill in "Email" with "quentin@example.com"
|
|
86
|
-
And I press "Sign up"
|
|
87
|
-
And I should receive an email
|
|
88
|
-
When I open the email
|
|
89
|
-
Then I should see "confirm" in the email body
|
|
90
|
-
When I follow "confirm" in the email
|
|
91
|
-
Then I should see "Confirm your new account"
|
|
92
|
-
|
|
93
|
-
For more examples, check out examples/rails_root in the source for a small example app that implements these steps.
|
|
94
|
-
|
|
95
|
-
=== RSpec
|
|
96
|
-
|
|
97
|
-
==== Testing In Isolation
|
|
98
|
-
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 focused examples for the actual mailer. This is a simple example from the sample app found in the gem:
|
|
99
|
-
|
|
100
|
-
Verify that the mailer is used correctly in the controller (this would apply to a model as well):
|
|
101
|
-
|
|
102
|
-
describe "POST /signup (#signup)" do
|
|
103
|
-
it "should deliver the signup email" do
|
|
104
|
-
# expect
|
|
105
|
-
UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean")
|
|
106
|
-
# when
|
|
107
|
-
post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean"
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
Examples for the #signup method in UserMailer:
|
|
112
|
-
|
|
113
|
-
describe "Signup Email" do
|
|
114
|
-
include EmailSpec::Helpers
|
|
115
|
-
include EmailSpec::Matchers
|
|
116
|
-
include ActionController::UrlWriter
|
|
117
|
-
|
|
118
|
-
before(:all) do
|
|
119
|
-
@email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it "should be set to be delivered to the email passed in" do
|
|
123
|
-
@email.should deliver_to("jojo@yahoo.com")
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "should contain the user's message in the mail body" do
|
|
127
|
-
@email.should have_body_text(/Jojo Binks/)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "should contain a link to the confirmation link" do
|
|
131
|
-
@email.should have_body_text(/#{confirm_account_url}/)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it "should have the correct subject" do
|
|
135
|
-
@email.should have_subject(/Account confirmation/)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
==== Using the helpers when not testing in isolation
|
|
141
|
-
|
|
142
|
-
Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish.
|
|
143
|
-
|
|
144
|
-
== Original Authors
|
|
145
|
-
|
|
146
|
-
Ben Mabey, Aaron Gibralter, Mischa Fierer
|
|
147
|
-
|
|
148
|
-
Please see History.txt for upcoming changsets and other contributors.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
source 'http://gemcutter.org'
|
|
2
|
-
|
|
3
|
-
gem 'rails', '3.0.0.rc'
|
|
4
|
-
gem 'sqlite3-ruby', :require => 'sqlite3'
|
|
5
|
-
|
|
6
|
-
gem 'delayed_job', '>=2.0.3'
|
|
7
|
-
gem 'mimetype-fu', :require => 'mimetype_fu'
|
|
8
|
-
|
|
9
|
-
group :test do
|
|
10
|
-
gem "test-unit"
|
|
11
|
-
gem "cucumber-rails"
|
|
12
|
-
gem "database_cleaner"
|
|
13
|
-
gem 'capybara'
|
|
14
|
-
gem "rspec", ">= 2.0.1"
|
|
15
|
-
gem "rspec-rails", ">= 2.0.1"
|
|
16
|
-
gem "email_spec", :path => "../../"
|
|
17
|
-
end
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ../../
|
|
3
|
-
specs:
|
|
4
|
-
email_spec (1.2.0)
|
|
5
|
-
mail (~> 2.2)
|
|
6
|
-
rspec (~> 2.0)
|
|
7
|
-
|
|
8
|
-
GEM
|
|
9
|
-
remote: http://gemcutter.org/
|
|
10
|
-
specs:
|
|
11
|
-
abstract (1.0.0)
|
|
12
|
-
actionmailer (3.0.0.rc)
|
|
13
|
-
actionpack (= 3.0.0.rc)
|
|
14
|
-
mail (~> 2.2.5)
|
|
15
|
-
actionpack (3.0.0.rc)
|
|
16
|
-
activemodel (= 3.0.0.rc)
|
|
17
|
-
activesupport (= 3.0.0.rc)
|
|
18
|
-
builder (~> 2.1.2)
|
|
19
|
-
erubis (~> 2.6.6)
|
|
20
|
-
i18n (~> 0.4.1)
|
|
21
|
-
rack (~> 1.2.1)
|
|
22
|
-
rack-mount (~> 0.6.9)
|
|
23
|
-
rack-test (~> 0.5.4)
|
|
24
|
-
tzinfo (~> 0.3.22)
|
|
25
|
-
activemodel (3.0.0.rc)
|
|
26
|
-
activesupport (= 3.0.0.rc)
|
|
27
|
-
builder (~> 2.1.2)
|
|
28
|
-
i18n (~> 0.4.1)
|
|
29
|
-
activerecord (3.0.0.rc)
|
|
30
|
-
activemodel (= 3.0.0.rc)
|
|
31
|
-
activesupport (= 3.0.0.rc)
|
|
32
|
-
arel (~> 0.4.0)
|
|
33
|
-
tzinfo (~> 0.3.22)
|
|
34
|
-
activeresource (3.0.0.rc)
|
|
35
|
-
activemodel (= 3.0.0.rc)
|
|
36
|
-
activesupport (= 3.0.0.rc)
|
|
37
|
-
activesupport (3.0.0.rc)
|
|
38
|
-
arel (0.4.0)
|
|
39
|
-
activesupport (>= 3.0.0.beta)
|
|
40
|
-
builder (2.1.2)
|
|
41
|
-
capybara (0.3.9)
|
|
42
|
-
culerity (>= 0.2.4)
|
|
43
|
-
mime-types (>= 1.16)
|
|
44
|
-
nokogiri (>= 1.3.3)
|
|
45
|
-
rack (>= 1.0.0)
|
|
46
|
-
rack-test (>= 0.5.4)
|
|
47
|
-
selenium-webdriver (>= 0.0.3)
|
|
48
|
-
cucumber (0.8.5)
|
|
49
|
-
builder (~> 2.1.2)
|
|
50
|
-
diff-lcs (~> 1.1.2)
|
|
51
|
-
gherkin (~> 2.1.4)
|
|
52
|
-
json_pure (~> 1.4.3)
|
|
53
|
-
term-ansicolor (~> 1.0.4)
|
|
54
|
-
cucumber-rails (0.3.2)
|
|
55
|
-
cucumber (>= 0.8.0)
|
|
56
|
-
culerity (0.2.10)
|
|
57
|
-
daemons (1.1.0)
|
|
58
|
-
database_cleaner (0.5.2)
|
|
59
|
-
delayed_job (2.0.3)
|
|
60
|
-
daemons
|
|
61
|
-
diff-lcs (1.1.2)
|
|
62
|
-
erubis (2.6.6)
|
|
63
|
-
abstract (>= 1.0.0)
|
|
64
|
-
ffi (0.6.3)
|
|
65
|
-
rake (>= 0.8.7)
|
|
66
|
-
gherkin (2.1.5)
|
|
67
|
-
trollop (~> 1.16.2)
|
|
68
|
-
i18n (0.4.1)
|
|
69
|
-
json_pure (1.4.3)
|
|
70
|
-
mail (2.2.5)
|
|
71
|
-
activesupport (>= 2.3.6)
|
|
72
|
-
mime-types
|
|
73
|
-
treetop (>= 1.4.5)
|
|
74
|
-
mime-types (1.16)
|
|
75
|
-
mimetype-fu (0.1.2)
|
|
76
|
-
nokogiri (1.4.2)
|
|
77
|
-
polyglot (0.3.1)
|
|
78
|
-
rack (1.2.1)
|
|
79
|
-
rack-mount (0.6.9)
|
|
80
|
-
rack (>= 1.0.0)
|
|
81
|
-
rack-test (0.5.4)
|
|
82
|
-
rack (>= 1.0)
|
|
83
|
-
rails (3.0.0.rc)
|
|
84
|
-
actionmailer (= 3.0.0.rc)
|
|
85
|
-
actionpack (= 3.0.0.rc)
|
|
86
|
-
activerecord (= 3.0.0.rc)
|
|
87
|
-
activeresource (= 3.0.0.rc)
|
|
88
|
-
activesupport (= 3.0.0.rc)
|
|
89
|
-
bundler (>= 1.0.0.rc.1)
|
|
90
|
-
railties (= 3.0.0.rc)
|
|
91
|
-
railties (3.0.0.rc)
|
|
92
|
-
actionpack (= 3.0.0.rc)
|
|
93
|
-
activesupport (= 3.0.0.rc)
|
|
94
|
-
rake (>= 0.8.3)
|
|
95
|
-
thor (~> 0.14.0)
|
|
96
|
-
rake (0.8.7)
|
|
97
|
-
rspec (2.1.0)
|
|
98
|
-
rspec-core (~> 2.1.0)
|
|
99
|
-
rspec-expectations (~> 2.1.0)
|
|
100
|
-
rspec-mocks (~> 2.1.0)
|
|
101
|
-
rspec-core (2.1.0)
|
|
102
|
-
rspec-expectations (2.1.0)
|
|
103
|
-
diff-lcs (~> 1.1.2)
|
|
104
|
-
rspec-mocks (2.1.0)
|
|
105
|
-
rspec-rails (2.1.0)
|
|
106
|
-
rspec (~> 2.1.0)
|
|
107
|
-
rubyzip (0.9.4)
|
|
108
|
-
selenium-webdriver (0.0.27)
|
|
109
|
-
ffi (>= 0.6.1)
|
|
110
|
-
json_pure
|
|
111
|
-
rubyzip
|
|
112
|
-
sqlite3-ruby (1.3.1)
|
|
113
|
-
term-ansicolor (1.0.5)
|
|
114
|
-
test-unit (2.1.0)
|
|
115
|
-
thor (0.14.0)
|
|
116
|
-
treetop (1.4.8)
|
|
117
|
-
polyglot (>= 0.3.1)
|
|
118
|
-
trollop (1.16.2)
|
|
119
|
-
tzinfo (0.3.22)
|
|
120
|
-
|
|
121
|
-
PLATFORMS
|
|
122
|
-
ruby
|
|
123
|
-
|
|
124
|
-
DEPENDENCIES
|
|
125
|
-
capybara
|
|
126
|
-
cucumber-rails
|
|
127
|
-
database_cleaner
|
|
128
|
-
delayed_job (>= 2.0.3)
|
|
129
|
-
email_spec!
|
|
130
|
-
mimetype-fu
|
|
131
|
-
rails (= 3.0.0.rc)
|
|
132
|
-
rspec (>= 2.0.1)
|
|
133
|
-
rspec-rails (>= 2.0.1)
|
|
134
|
-
sqlite3-ruby
|
|
135
|
-
test-unit
|
data/examples/rails3_root/README
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../config/application', __FILE__)
|
|
5
|
-
|
|
6
|
-
require 'rake'
|
|
7
|
-
require 'rake/testtask'
|
|
8
|
-
require 'rake/rdoctask'
|
|
9
|
-
require 'delayed/tasks'
|
|
10
|
-
|
|
11
|
-
Rails3Root::Application.load_tasks
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class WelcomeController < ApplicationController
|
|
2
|
-
def signup
|
|
3
|
-
UserMailer.signup(params['Email'], params['Name']).deliver
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
def confirm
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def newsletter
|
|
10
|
-
Delayed::Job.enqueue(NotifierJob.new(:newsletter,params['Email'], params['Name']))
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def attachments
|
|
14
|
-
UserMailer.attachments_mail(params['Email'], params['Name']).deliver
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
class UserMailer < ActionMailer::Base
|
|
2
|
-
default :from => "admin@example.com",
|
|
3
|
-
:sent_on => Time.now.to_s
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def signup(email, name)
|
|
7
|
-
@name = name
|
|
8
|
-
|
|
9
|
-
mail :to => email,
|
|
10
|
-
:subject => "Account confirmation"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def newsletter(email, name)
|
|
14
|
-
@name = name
|
|
15
|
-
|
|
16
|
-
mail :to => email,
|
|
17
|
-
:subject => "Newsletter sent"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def attachments_mail(email, name)
|
|
21
|
-
@name = name
|
|
22
|
-
|
|
23
|
-
add_attachment 'image.png'
|
|
24
|
-
add_attachment 'document.pdf'
|
|
25
|
-
|
|
26
|
-
mail :to => email,
|
|
27
|
-
:subject => "Attachments test"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
def add_attachment(attachment_name)
|
|
33
|
-
attachment_path = "#{Rails.root}/attachments/#{attachment_name}"
|
|
34
|
-
File.open(attachment_path) do |file|
|
|
35
|
-
filename = File.basename(file.path)
|
|
36
|
-
attachments[filename] = {:content_type => File.mime_type?(file), :content => file.read}
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Confirm your new account!
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Thanks! Go check your email!
|
|
Binary file
|
|
Binary file
|