@@ -107,6 +107,34 @@ def nested_multipart_message
107107 mail . add_part container
108108 mail
109109 end
110+
111+ def message_with_params
112+ greeting = params [ 'greeting' ]
113+ email = params [ 'email' ]
114+ Mail . new do
115+ to "User <#{ email } >"
116+ from 'Test Peek <[email protected] >' 117+ body "#{ greeting } "
118+ end
119+ end
120+
121+ def multipart_alternative_with_params
122+ greeting = params [ 'greeting' ]
123+ Mail . new do
124+ 125+
126+ yield self if block_given?
127+
128+ text_part do
129+ body "Plain greeting #{ greeting } "
130+ end
131+
132+ html_part do
133+ content_type 'text/html; charset=UTF-8'
134+ body "<h1>Html greeting #{ greeting } </h1>"
135+ end
136+ end
137+ end
110138 end
111139
112140 class ISayHelloAndYouSayGoodbyeInterceptor
@@ -131,8 +159,9 @@ def app
131159 Preview
132160 end
133161
134- def iframe_src_match ( content_type )
135- /<iframe[^>]* src="\? part=#{ Regexp . escape ( Rack ::Utils . escape ( content_type ) ) } "[^>]*><\/ iframe>/
162+ def iframe_src_match ( content_type , params = '' )
163+ params = '&' + Rack ::Utils . build_query ( Rack ::Utils . parse_query ( params ) ) if params != ''
164+ /<iframe[^>]* src="\? part=#{ Regexp . escape ( Rack ::Utils . escape ( content_type ) ) + params } "[^>]*><\/ iframe>/
136165 end
137166
138167 def unescaped_body
@@ -306,6 +335,31 @@ def test_interceptors
306335 assert_equal 'Goodbye' , last_response . body
307336 end
308337
338+ def test_message_with_params
339+ get '/message_with_params?greeting=Bonjour&[email protected] ' 340+ assert last_response . ok?
341+ assert_match '[email protected] ' , unescaped_body , "Email should be in body" 342+ assert_match 'Bonjour' , unescaped_body , "Greeting should be in body"
343+ end
344+
345+ def test_message_with_params_no_part_url
346+ get '/message_with_params?greeting=Bonjour&[email protected] ' 347+ assert last_response . ok?
348+ assert_match iframe_src_match ( '' , '&greeting=Bonjour&[email protected] ' ) , last_response . body , "Iframe src should include params" 349+ end
350+
351+ def test_message_multipart_alternative_plain_with_params
352+ get '/multipart_alternative_with_params?part=text%2Fplain&greeting=Bonjour'
353+ assert last_response . ok?
354+ assert_match 'Plain greeting Bonjour' , unescaped_body , "Email should be in body"
355+ end
356+
357+ def test_message_multipart_alternative_html_with_params
358+ get '/multipart_alternative_with_params?part=text%2Fhtml&greeting=Bonjour'
359+ assert last_response . ok?
360+ assert_match 'Html greeting Bonjour' , unescaped_body , "Email should be in body"
361+ end
362+
309363 unless RUBY_VERSION >= '1.9'
310364 def test_tmail_html_message
311365 get '/tmail_html_message'
0 commit comments