mail_view 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -97,18 +97,9 @@ executables: []
97
97
  extensions: []
98
98
  extra_rdoc_files: []
99
99
  files:
100
- - /Users/jeremy/work/plugins/mail_view/Gemfile
101
- - /Users/jeremy/work/plugins/mail_view/Gemfile.lock
102
- - /Users/jeremy/work/plugins/mail_view/init.rb
103
- - /Users/jeremy/work/plugins/mail_view/lib/mail_view/email.html.erb
104
- - /Users/jeremy/work/plugins/mail_view/lib/mail_view/index.html.erb
105
- - /Users/jeremy/work/plugins/mail_view/lib/mail_view/mapper.rb
106
- - /Users/jeremy/work/plugins/mail_view/lib/mail_view.rb
107
- - /Users/jeremy/work/plugins/mail_view/LICENSE
108
- - /Users/jeremy/work/plugins/mail_view/mail_view.gemspec
109
- - /Users/jeremy/work/plugins/mail_view/Rakefile
110
- - /Users/jeremy/work/plugins/mail_view/README.md
111
- - /Users/jeremy/work/plugins/mail_view/test/test_mail_view.rb
100
+ - init.rb
101
+ - lib/mail_view/mapper.rb
102
+ - lib/mail_view.rb
112
103
  homepage: https://github.com/37signals/mail_view
113
104
  licenses: []
114
105
  post_install_message:
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
@@ -1,33 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mail_view (2.0.1)
5
- tilt
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- mail (2.5.4)
11
- mime-types (~> 1.16)
12
- treetop (~> 1.4.8)
13
- mime-types (1.23)
14
- polyglot (0.3.3)
15
- rack (1.5.2)
16
- rack-test (0.6.2)
17
- rack (>= 1.0)
18
- rake (10.1.0)
19
- tilt (1.4.1)
20
- tmail (1.2.7.1)
21
- treetop (1.4.14)
22
- polyglot
23
- polyglot (>= 0.3.1)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- mail (~> 2.2)
30
- mail_view!
31
- rack-test (~> 0.6)
32
- rake
33
- tmail (~> 1.2)
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 37signals, LLC
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
@@ -1,81 +0,0 @@
1
- MailView -- Visual email testing
2
- ================================
3
-
4
- Preview plain text and html mail templates in your browser without redelivering it every time you make a change.
5
-
6
- Install
7
- -------
8
-
9
- Add the gem to your `Gemfile`:
10
-
11
- ```ruby
12
- gem 'mail_view', :git => 'https://github.com/37signals/mail_view.git'
13
- # or
14
- gem "mail_view", "~> 1.0.3"
15
- ```
16
-
17
- And run `bundle install`.
18
-
19
- Usage
20
- -----
21
-
22
- Since most emails do something interesting with database data, you'll need to write some scenarios to load messages with fake data. Its similar to writing mailer unit tests but you see a visual representation of the output instead.
23
-
24
- ```ruby
25
- # app/mailers/mail_preview.rb or lib/mail_preview.rb
26
- class MailPreview < MailView
27
- # Pull data from existing fixtures
28
- def invitation
29
- account = Account.first
30
- inviter, invitee = account.users[0, 2]
31
- Notifier.invitation(inviter, invitee)
32
- end
33
-
34
- # Factory-like pattern
35
- def welcome
36
- user = User.create!
37
- mail = Notifier.welcome(user)
38
- user.destroy
39
- mail
40
- end
41
-
42
- # Stub-like
43
- def forgot_password
44
- user = Struct.new(:email, :name).new('name@example.com', 'Jill Smith')
45
- mail = UserMailer.forgot_password(user)
46
- end
47
- end
48
- ```
49
-
50
- Methods must return a [Mail][1] or [TMail][2] object. Using ActionMailer, call `Notifier.create_action_name(args)` to return a compatible TMail object. Now on ActionMailer 3.x, `Notifier.action_name(args)` will return a Mail object.
51
-
52
- Routing
53
- -------
54
-
55
- A mini router middleware is bundled for Rails 2.x support.
56
-
57
- ```ruby
58
- # config/environments/development.rb
59
- config.middleware.use MailView::Mapper, [MailPreview]
60
- ```
61
-
62
- For Rails³ you can map the app inline in your routes config.
63
-
64
- ```ruby
65
- # config/routes.rb
66
- if Rails.env.development?
67
- mount MailPreview => 'mail_view'
68
- end
69
- ```
70
-
71
- Now just load up `http://localhost:3000/mail_view`.
72
-
73
- Interface
74
- ---------
75
-
76
- ![Plain text view](http://img18.imageshack.us/img18/1066/plaintext.png)
77
- ![HTML view](http://img269.imageshack.us/img269/2944/htmlz.png)
78
-
79
-
80
- [1]: http://github.com/mikel/mail
81
- [2]: http://github.com/mikel/tmail
@@ -1,11 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'rake'
4
- require 'rake/testtask'
5
-
6
- task :default => :test
7
-
8
- Rake::TestTask.new do |t|
9
- t.libs << 'test/lib'
10
- t.pattern = 'test/*.rb'
11
- end
@@ -1,98 +0,0 @@
1
- <!DOCTYPE html>
2
- <html><head>
3
- <meta name="viewport" content="width=device-width" />
4
- <style type="text/css">
5
- header {
6
- width: 100%;
7
- padding: 10px 0 0 0;
8
- margin: 0;
9
- background: white;
10
- font: 12px "Lucida Grande", sans-serif;
11
- border-bottom: 1px solid #dedede;
12
- overflow: hidden;
13
- }
14
-
15
- dl {
16
- margin: 0 0 10px 0;
17
- padding: 0;
18
- }
19
-
20
- dt {
21
- width: 80px;
22
- padding: 1px;
23
- float: left;
24
- clear: left;
25
- text-align: right;
26
- color: #7f7f7f;
27
- }
28
-
29
- dd {
30
- margin-left: 90px; /* 80px + 10px */
31
- padding: 1px;
32
- }
33
-
34
- iframe {
35
- border: 0;
36
- width: 100%;
37
- height: 800px;
38
- }
39
- </style>
40
- </head>
41
-
42
- <body>
43
- <header>
44
- <dl>
45
- <% if mail.respond_to?(:smtp_envelope_from) && Array(mail.from) != Array(mail.smtp_envelope_from) %>
46
- <dt>SMTP-From:</dt>
47
- <dd><%= mail.smtp_envelope_from %></dd>
48
- <% end %>
49
-
50
- <% if mail.respond_to?(:smtp_envelope_to) && mail.to != mail.smtp_envelope_to %>
51
- <dt>SMTP-To:</dt>
52
- <dd><%= mail.smtp_envelope_to %></dd>
53
- <% end %>
54
-
55
- <dt>From:</dt>
56
- <dd><%= Rack::Utils.escape_html(mail.header['from'].to_s) %></dd>
57
-
58
- <% if mail.reply_to %>
59
- <dt>Reply-To:</dt>
60
- <dd><%= Rack::Utils.escape_html(mail.header['reply-to'].to_s) %></dd>
61
- <% end %>
62
-
63
- <dt>To:</dt>
64
- <dd><%= Rack::Utils.escape_html(mail.header['to'].to_s) %></dd>
65
-
66
- <% if mail.cc %>
67
- <dt>CC:</dt>
68
- <dd><%= Rack::Utils.escape_html(mail.header['cc'].to_s) %></dd>
69
- <% end %>
70
-
71
- <dt>Date:</dt>
72
- <dd><%= Time.now.strftime("%b %e, %Y %I:%M:%S %p %Z") %></dd>
73
-
74
- <dt>Subject:</dt>
75
- <dd><strong><%= mail.subject %></strong></dd>
76
-
77
- <% unless mail.attachments.nil? || mail.attachments.empty? %>
78
- <dt>Attachments:</dt>
79
- <dd>
80
- <%= Rack::Utils.escape_html mail.attachments.map { |a| a.respond_to?(:original_filename) ? a.original_filename : a.filename }.inspect %>
81
- </dd>
82
- <% end %>
83
-
84
- <% if mail.multipart? %>
85
- <dd>
86
- <select onchange="document.getElementsByName('messageBody')[0].src=this.options[this.selectedIndex].value;">
87
- <option value="?part=text%2Fhtml">View as HTML email</option>
88
- <option value="?part=text%2Fplain">View as plain-text email</option>
89
- </select>
90
- </dd>
91
- <% end %>
92
- </dl>
93
- </header>
94
-
95
- <iframe seamless name="messageBody" src="<%= part_url %>"></iframe>
96
-
97
- </body>
98
- </html>
@@ -1,5 +0,0 @@
1
- <ul>
2
- <% links.each do |name, link| %>
3
- <li><a href="<%= link %>"><%= name %></a></li>
4
- <% end %>
5
- </ul>
@@ -1,17 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'mail_view'
3
- s.version = '2.0.2'
4
- s.author = 'Josh Peek'
5
- s.email = 'josh@joshpeek.com'
6
- s.summary = 'Visual email testing'
7
- s.homepage = 'https://github.com/37signals/mail_view'
8
-
9
- s.add_dependency 'tilt'
10
-
11
- s.add_development_dependency 'rack-test', '~> 0.6'
12
- s.add_development_dependency 'mail', '~> 2.2'
13
- s.add_development_dependency 'tmail', '~> 1.2'
14
- s.add_development_dependency 'rake'
15
-
16
- s.files = Dir[File.expand_path('../**/*', __FILE__)]
17
- end
@@ -1,339 +0,0 @@
1
- require 'test/unit'
2
- require 'rack/test'
3
-
4
- require 'mail_view'
5
- require 'mail'
6
- require 'tmail'
7
- require 'cgi' # For CGI.unescapeHTML
8
-
9
- class TestMailView < Test::Unit::TestCase
10
- include Rack::Test::Methods
11
-
12
- class Preview < MailView
13
- def plain_text_message
14
- Mail.new do
15
- to 'josh@37signals.com'
16
- body 'Hello'
17
- yield self if block_given?
18
- end
19
- end
20
-
21
- def plain_text_message_with_display_names
22
- Mail.new do
23
- to 'Josh Peek <josh@37signals.com>'
24
- from 'Test Peek <test@foo.com>'
25
- reply_to 'Another Peek <another@foo.com>'
26
- body 'Hello'
27
- end
28
- end
29
-
30
- def tmail_plain_text_message_with_display_names
31
- TMail::Mail.parse(plain_text_message_with_display_names.to_s)
32
- end
33
-
34
- def html_message
35
- Mail.new do
36
- to 'josh@37signals.com'
37
-
38
- content_type 'text/html; charset=UTF-8'
39
- body '<h1>Hello</h1>'
40
- end
41
- end
42
-
43
- def tmail_html_message
44
- TMail::Mail.parse(html_message.to_s)
45
- end
46
-
47
- def multipart_alternative
48
- Mail.new do
49
- to 'josh@37signals.com'
50
-
51
- yield self if block_given?
52
-
53
- text_part do
54
- body 'This is plain text'
55
- end
56
-
57
- html_part do
58
- content_type 'text/html; charset=UTF-8'
59
- body '<h1>This is HTML</h1>'
60
- end
61
- end
62
- end
63
-
64
- def multipart_alternative_text_default
65
- Mail.new do
66
- to 'josh@37signals.com'
67
-
68
- html_part do
69
- content_type 'text/html; charset=UTF-8'
70
- body '<h1>This is HTML</h1>'
71
- end
72
-
73
- text_part do
74
- body 'This is plain text'
75
- end
76
- end
77
- end
78
-
79
- def multipart_mixed_with_text_and_attachment
80
- plain_text_message { |mail| add_attachments_to mail }
81
- end
82
-
83
- def multipart_mixed_with_multipart_alternative_and_attachment
84
- multipart_alternative { |mail| add_attachments_to mail }
85
- end
86
-
87
- def add_attachments_to(mail)
88
- mail.add_file :filename => 'checkbox.png', :content => 'stub'
89
- mail.add_file :filename => 'foo.vcf', :content => 'stub'
90
- mail
91
- end
92
-
93
- def tmail_multipart_alternative
94
- TMail::Mail.parse(multipart_alternative.to_s)
95
- end
96
-
97
- def nested_multipart_message
98
- container = Mail::Part.new
99
- container.content_type = 'multipart/alternative'
100
- container.text_part { body 'omg' }
101
- container.html_part do
102
- content_type 'text/html; charset=UTF-8'
103
- body '<h1>Hello</h1>'
104
- end
105
-
106
- mail = Mail.new
107
- mail.add_part container
108
- mail
109
- end
110
- end
111
-
112
- class ISayHelloAndYouSayGoodbyeInterceptor
113
- Mail.register_interceptor self
114
- @@intercept = false
115
-
116
- def self.intercept
117
- @@intercept = true
118
- yield
119
- ensure
120
- @@intercept = false
121
- end
122
-
123
- def self.delivering_email(message)
124
- if @@intercept
125
- message.body = message.body.to_s.gsub('Hello', 'Goodbye')
126
- end
127
- end
128
- end
129
-
130
- def app
131
- Preview
132
- end
133
-
134
- def iframe_src_match(content_type)
135
- /<iframe[^>]* src="\?part=#{Regexp.escape(Rack::Utils.escape(content_type))}"[^>]*><\/iframe>/
136
- end
137
-
138
- def unescaped_body
139
- CGI.unescapeHTML last_response.body
140
- end
141
-
142
- def test_index
143
- get '/'
144
- assert_match '/plain_text_message', last_response.body
145
- assert_match '/html_message', last_response.body
146
- assert_match '/multipart_alternative', last_response.body
147
- end
148
-
149
- def test_mounted_index
150
- get '/', {}, 'SCRIPT_NAME' => '/boom'
151
- assert_match '/boom/plain_text_message', last_response.body
152
- assert_match '/boom/html_message', last_response.body
153
- assert_match '/boom/multipart_alternative', last_response.body
154
- end
155
-
156
- def test_mailer_not_found
157
- get '/missing'
158
- assert last_response.not_found?
159
- end
160
-
161
- def test_format_not_found
162
- get '/plain_text_message.huzzah'
163
- assert last_response.not_found?
164
- end
165
-
166
- def test_mime_part_not_found
167
- get '/plain_text_message?part=text%2Fhtml'
168
- assert last_response.not_found?
169
- end
170
-
171
- def test_plain_text_message
172
- get '/plain_text_message'
173
- assert last_response.ok?
174
- assert_match iframe_src_match(''), last_response.body
175
- assert_no_match %r(View as), last_response.body
176
-
177
- get '/plain_text_message?part='
178
- assert last_response.ok?
179
- assert_match 'Hello', last_response.body
180
- end
181
-
182
- def test_mounted_plain_text_message
183
- get '/plain_text_message', {}, 'SCRIPT_NAME' => '/boom'
184
- assert last_response.ok?
185
- assert_match iframe_src_match(''), last_response.body
186
- assert_no_match %r(View as), last_response.body
187
-
188
- get '/boom/plain_text_message?part='
189
- assert last_response.ok?
190
- assert_equal 'Hello', last_response.body
191
- end
192
-
193
- def test_message_header_uses_full_display_names
194
- get '/plain_text_message_with_display_names'
195
- assert_match 'Josh Peek <josh@37signals.com>', unescaped_body
196
- assert_match 'Test Peek <test@foo.com>', unescaped_body
197
- assert_match 'Another Peek <another@foo.com>', unescaped_body
198
- end
199
-
200
- def test_html_message
201
- get '/html_message'
202
- assert last_response.ok?
203
- assert_match iframe_src_match('text/html'), last_response.body
204
- assert_no_match %r(View as), last_response.body
205
-
206
- get '/html_message?part=text%2Fhtml'
207
- assert last_response.ok?
208
- assert_equal '<h1>Hello</h1>', last_response.body
209
- end
210
-
211
- def test_nested_multipart_message
212
- get '/nested_multipart_message'
213
- assert last_response.ok?
214
- assert_match iframe_src_match('text/html'), last_response.body
215
- assert_match %r(View as), last_response.body
216
-
217
- get '/nested_multipart_message?part=text%2Fhtml'
218
- assert last_response.ok?
219
- assert_equal '<h1>Hello</h1>', last_response.body
220
- end
221
-
222
- def test_multipart_alternative
223
- get '/multipart_alternative'
224
- assert last_response.ok?
225
- assert_match iframe_src_match('text/html'), last_response.body
226
- assert_match 'View as', last_response.body
227
-
228
- get '/multipart_alternative?part=text%2Fhtml'
229
- assert last_response.ok?
230
- assert_equal '<h1>This is HTML</h1>', last_response.body
231
- end
232
-
233
- def test_multipart_alternative_as_html
234
- get '/multipart_alternative.html'
235
- assert last_response.ok?
236
- assert_match iframe_src_match('text/html'), last_response.body
237
- assert_match 'View as', last_response.body
238
-
239
- get '/multipart_alternative.html?part=text%2Fhtml'
240
- assert last_response.ok?
241
- assert_equal '<h1>This is HTML</h1>', last_response.body
242
- end
243
-
244
- def test_multipart_alternative_as_text
245
- get '/multipart_alternative.txt'
246
- assert last_response.ok?
247
- assert_match iframe_src_match('text/plain'), last_response.body
248
- assert_match 'View as', last_response.body
249
-
250
- get '/multipart_alternative.txt?part=text%2Fplain'
251
- assert last_response.ok?
252
- assert_equal 'This is plain text', last_response.body
253
- end
254
-
255
- def test_multipart_alternative_text_as_default
256
- get '/multipart_alternative_text_default'
257
- assert last_response.ok?
258
- assert_match iframe_src_match('text/plain'), last_response.body
259
- assert_match 'View as', last_response.body
260
-
261
- get '/multipart_alternative_text_default?part=text%2Fplain'
262
- assert last_response.ok?
263
- assert_equal 'This is plain text', last_response.body
264
- end
265
-
266
- def test_multipart_mixed_with_text_and_attachment
267
- get '/multipart_mixed_with_text_and_attachment'
268
- assert last_response.ok?
269
- assert_match iframe_src_match('text/plain'), last_response.body
270
- #assert_no_match %r(View as), last_response.body
271
- assert_match 'checkbox.png', last_response.body
272
-
273
- get '/multipart_mixed_with_text_and_attachment?part=text%2Fplain'
274
- assert last_response.ok?
275
- assert_equal 'Hello', last_response.body
276
- end
277
-
278
- def test_multipart_mixed_with_multipart_alternative_and_attachment
279
- get '/multipart_mixed_with_multipart_alternative_and_attachment'
280
- assert last_response.ok?
281
- assert_match iframe_src_match('text/html'), last_response.body
282
- assert_match 'View as', last_response.body
283
- assert_match 'checkbox.png', last_response.body
284
-
285
- get '/multipart_mixed_with_multipart_alternative_and_attachment?part=text%2Fhtml'
286
- assert last_response.ok?
287
- assert_equal '<h1>This is HTML</h1>', last_response.body
288
- end
289
-
290
- def test_multipart_mixed_with_multipart_alternative_and_attachment_preferring_plain_text
291
- get '/multipart_mixed_with_multipart_alternative_and_attachment.txt'
292
- assert last_response.ok?
293
- assert_match iframe_src_match('text/plain'), last_response.body
294
- assert_match 'View as', last_response.body
295
- assert_match 'checkbox.png', last_response.body
296
-
297
- get '/multipart_mixed_with_multipart_alternative_and_attachment.txt?part=text%2Fplain'
298
- assert last_response.ok?
299
- assert_equal 'This is plain text', last_response.body
300
- end
301
-
302
- def test_interceptors
303
- ISayHelloAndYouSayGoodbyeInterceptor.intercept do
304
- get '/plain_text_message?part='
305
- end
306
- assert_equal 'Goodbye', last_response.body
307
- end
308
-
309
- unless RUBY_VERSION >= '1.9'
310
- def test_tmail_html_message
311
- get '/tmail_html_message'
312
- assert last_response.ok?
313
- assert_match iframe_src_match('text/html'), last_response.body
314
-
315
- get '/tmail_html_message?part=text%2Fhtml'
316
- assert last_response.ok?
317
- assert_equal '<h1>Hello</h1>', last_response.body
318
- end
319
-
320
- def test_tmail_multipart_alternative
321
- get '/tmail_multipart_alternative'
322
- assert last_response.ok?
323
- body_path = '/tmail_multipart_alternative?part=text%2Fhtml'
324
- assert_match iframe_src_match('text/html'), last_response.body
325
- assert_match 'View as', last_response.body
326
-
327
- get body_path
328
- assert last_response.ok?
329
- assert_equal "<h1>This is HTML</h1>\r\n", last_response.body
330
- end
331
-
332
- def test_tmail_message_header_uses_full_display_names
333
- get '/tmail_plain_text_message_with_display_names'
334
- assert_match 'Josh Peek <josh@37signals.com>', unescaped_body
335
- assert_match 'Test Peek <test@foo.com>', unescaped_body
336
- assert_match 'Another Peek <another@foo.com>', unescaped_body
337
- end
338
- end
339
- end