jpmobile 0.1.6 → 1.0.0.pre
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/README +0 -0
- data/README.rdoc +58 -29
- data/Rakefile +1 -1
- data/VERSION.yml +4 -4
- data/lib/jpmobile.rb +3 -0
- data/lib/jpmobile/email.rb +17 -2
- data/lib/jpmobile/emoticon.rb +87 -23
- data/lib/jpmobile/emoticon/au.rb +644 -0
- data/lib/jpmobile/emoticon/softbank.rb +488 -0
- data/lib/jpmobile/emoticon/z_combine.rb +16 -13
- data/lib/jpmobile/hook_action_controller.rb +1 -13
- data/lib/jpmobile/hook_action_view.rb +3 -62
- data/lib/jpmobile/mail.rb +316 -0
- data/lib/jpmobile/mailer.rb +31 -0
- data/lib/jpmobile/mobile/abstract_mobile.rb +66 -0
- data/lib/jpmobile/mobile/au.rb +25 -2
- data/lib/jpmobile/mobile/docomo.rb +23 -1
- data/lib/jpmobile/mobile/emobile.rb +1 -1
- data/lib/jpmobile/mobile/softbank.rb +33 -1
- data/lib/jpmobile/mobile/vodafone.rb +1 -1
- data/lib/jpmobile/mobile/willcom.rb +1 -1
- data/lib/jpmobile/path_set.rb +40 -0
- data/lib/jpmobile/rails.rb +24 -0
- data/lib/jpmobile/resolver.rb +38 -0
- data/lib/jpmobile/util.rb +223 -14
- data/lib/tasks/jpmobile_tasks.rake +41 -48
- data/spec/rack/jpmobile/emoticon_spec.rb +3 -8
- data/spec/rack/jpmobile/filter_spec.rb +1 -1
- data/spec/rack/jpmobile/params_filter_spec.rb +4 -4
- data/spec/rack_helper.rb +5 -9
- data/spec/unit/detect_by_email_spec.rb +29 -0
- data/spec/unit/emoticon_spec.rb +90 -0
- data/spec/unit/encoding_spec.rb +102 -0
- data/spec/unit/mail_spec.rb +117 -0
- data/spec/unit/receive_mail_spec.rb +289 -0
- data/spec/unit/spec_helper.rb +8 -0
- data/spec/unit/util_spec.rb +5 -0
- data/test/rails/overrides/app/controllers/application_controller.rb +3 -2
- data/test/rails/overrides/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/overrides/app/models/mobile_mailer.rb +19 -0
- data/test/rails/overrides/app/models/normal_mailer.rb +9 -0
- data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +737 -0
- data/test/rails/overrides/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/overrides/spec/spec_helper.rb +6 -0
- data/test/rails/rails_root/app/controllers/application_controller.rb +3 -2
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/rails_root/app/models/mobile_mailer.rb +2 -1
- data/test/rails/rails_root/app/models/normal_mailer.rb +9 -0
- data/test/rails/rails_root/config/initializers/secret_token.rb +1 -1
- data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +73 -80
- data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/rails_root/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/rails_root/spec/spec_helper.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +2 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +7 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +1 -13
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +3 -62
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +162 -111
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +31 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +34 -3
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +2 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +4 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +7 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +40 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +24 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +38 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +33 -23
- metadata +43 -14
- data/test/legacy/emoticon_test.rb +0 -63
- data/test/legacy/helper.rb +0 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_mailer.rb +0 -22
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
|
4
|
+
describe NormalMailer do
|
5
|
+
include Jpmobile::Util
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
ActionMailer::Base.deliveries = []
|
9
|
+
|
10
|
+
@to = ["outer@jp.mobile", "outer1@jp.mobile"]
|
11
|
+
@subject = "日本語題名"
|
12
|
+
@text = "日本語テキスト"
|
13
|
+
end
|
14
|
+
|
15
|
+
context "PC宛メール" do
|
16
|
+
it "正常に送信できること" do
|
17
|
+
email = NormalMailer.msg(@to, "題名", "本文").deliver
|
18
|
+
|
19
|
+
ActionMailer::Base.deliveries.size.should == 1
|
20
|
+
(email.to - @to).should be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it "UTF-8のままであること" do
|
24
|
+
email = NormalMailer.msg(@to, @subject, @text).deliver
|
25
|
+
|
26
|
+
ActionMailer::Base.deliveries.size.should == 1
|
27
|
+
|
28
|
+
raw_mail = ascii_8bit(email.to_s)
|
29
|
+
raw_mail.should match(/UTF-8/i)
|
30
|
+
raw_mail.should match(Regexp.escape("=E6=97=A5=E6=9C=AC=E8=AA=9E=E9=A1=8C=E5=90=8D"))
|
31
|
+
raw_mail.should match(Regexp.escape([@text].pack("m").strip))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -13,7 +13,7 @@ describe TemplatePathController, "DoCoMo SH902i からのアクセス" do
|
|
13
13
|
it 'テンプレートの探索順が正しいこと' do
|
14
14
|
get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
|
15
15
|
|
16
|
-
controller.
|
16
|
+
controller.lookup_context.mobile.should == [ 'mobile_docomo', 'mobile' ]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -24,7 +24,7 @@ describe TemplatePathController, "au CA32 からのアクセス" do
|
|
24
24
|
it 'テンプレートの探索順が正しいこと' do
|
25
25
|
get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
|
26
26
|
|
27
|
-
controller.
|
27
|
+
controller.lookup_context.mobile.should == [ 'mobile_au', 'mobile' ]
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -35,7 +35,7 @@ describe TemplatePathController, "Vodafone V903T からのアクセス" do
|
|
35
35
|
it 'テンプレートの探索順が正しいこと' do
|
36
36
|
get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
|
37
37
|
|
38
|
-
controller.
|
38
|
+
controller.lookup_context.mobile.should == [ 'mobile_vodafone', 'mobile_softbank', 'mobile' ]
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -46,7 +46,7 @@ describe TemplatePathController, "SoftBank 910T からのアクセス" do
|
|
46
46
|
it 'テンプレートの探索順が正しいこと' do
|
47
47
|
get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
|
48
48
|
|
49
|
-
controller.
|
49
|
+
controller.lookup_context.mobile.should == [ 'mobile_softbank', 'mobile' ]
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -57,7 +57,7 @@ describe TemplatePathController, "iPhone からのアクセス" do
|
|
57
57
|
it 'テンプレートの探索順が正しいこと' do
|
58
58
|
get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
|
59
59
|
|
60
|
-
controller.
|
60
|
+
controller.lookup_context.mobile.should == [ 'smart_phone_iphone', 'smart_phone' ]
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -68,7 +68,7 @@ describe TemplatePathController, "Android からのアクセス" do
|
|
68
68
|
it 'テンプレートの探索順が正しいこと' do
|
69
69
|
get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
|
70
70
|
|
71
|
-
controller.
|
71
|
+
controller.lookup_context.mobile.should == [ 'smart_phone_android', 'smart_phone' ]
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -79,7 +79,7 @@ describe TemplatePathController, "Windows Phone からのアクセス" do
|
|
79
79
|
it 'テンプレートの探索順が正しいこと' do
|
80
80
|
get "/template_path/index", {}, { "HTTP_USER_AGENT" => @user_agent}
|
81
81
|
|
82
|
-
controller.
|
82
|
+
controller.lookup_context.mobile.should == [ 'smart_phone_windows_phone', 'smart_phone' ]
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -111,6 +111,12 @@ describe TemplatePathController, "integrated_views" do
|
|
111
111
|
|
112
112
|
response.should have_tag("h1", :content => "show_mobile_docomo.html.erb")
|
113
113
|
end
|
114
|
+
|
115
|
+
it 'disable_mobile_view! のときには index.html.erb が使用されること' do
|
116
|
+
get "/template_path/index", {:pc => true}, { "HTTP_USER_AGENT" => @user_agent}
|
117
|
+
|
118
|
+
response.should have_tag("h1", :content => "index.html.erb")
|
119
|
+
end
|
114
120
|
end
|
115
121
|
|
116
122
|
context "SoftBankからのアクセスの場合" do
|
@@ -27,6 +27,12 @@ RSpec.configure do |config|
|
|
27
27
|
config.include Webrat::HaveTagMatcher
|
28
28
|
config.include Jpmobile::Util
|
29
29
|
config.before(:each) { Webrat.configuration.mode = :rails }
|
30
|
+
|
31
|
+
config.filter_run :focus => true
|
32
|
+
config.run_all_when_everything_filtered = true
|
33
|
+
config.color_enabled = true
|
34
|
+
config.filter_run_excluding :broken => true
|
35
|
+
# config.full_backtrace = true
|
30
36
|
end
|
31
37
|
|
32
38
|
require 'pp'
|
@@ -4,4 +4,4 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
RailsRoot::Application.config.secret_token = '
|
7
|
+
RailsRoot::Application.config.secret_token = '23417af8bf908eea220f39faa992f7a25a753df87b6f0f4bfd9fec3ccf0dad629004cc608a9aaed4532f58231f16dfa9875cd21fbb4c58bde26bdc4aa9103979'
|
@@ -85,7 +85,7 @@ describe MobileMailer do
|
|
85
85
|
|
86
86
|
raw_mail = email.to_s
|
87
87
|
raw_mail.should match(/shift_jis/i)
|
88
|
-
# raw_mail.should match(/For docomo/)
|
88
|
+
# raw_mail.should match(/For docomo/)
|
89
89
|
raw_mail.should match(Regexp.escape("k/qWe4zqkeiWvA=="))
|
90
90
|
raw_mail.should match(Regexp.compile(utf8_to_sjis(@text)))
|
91
91
|
end
|
@@ -99,7 +99,7 @@ describe MobileMailer do
|
|
99
99
|
ActionMailer::Base.deliveries.size.should == 1
|
100
100
|
|
101
101
|
raw_mail = email.to_s
|
102
|
-
|
102
|
+
raw_mail.should match(/For docomo/)
|
103
103
|
raw_mail.should match(Regexp.escape("k/qWe4zqkeiWvPjX"))
|
104
104
|
raw_mail.should match(regexp_to_sjis("\xf8\xec"))
|
105
105
|
end
|
@@ -113,7 +113,7 @@ describe MobileMailer do
|
|
113
113
|
ActionMailer::Base.deliveries.size.should == 1
|
114
114
|
|
115
115
|
raw_mail = email.to_s
|
116
|
-
|
116
|
+
raw_mail.should match(/For docomo/)
|
117
117
|
raw_mail.should match(Regexp.escape("k/qWe4zqkeiWvLnesNE="))
|
118
118
|
raw_mail.should match(Regexp.compile(Regexp.escape(utf8_to_sjis(half_kana_text))))
|
119
119
|
end
|
@@ -154,7 +154,7 @@ describe MobileMailer do
|
|
154
154
|
ActionMailer::Base.deliveries.size.should == 1
|
155
155
|
|
156
156
|
raw_mail = ascii_8bit(email.to_s)
|
157
|
-
|
157
|
+
raw_mail.should match(/For au/)
|
158
158
|
raw_mail.should match(Regexp.escape("GyRCRnxLXDhsQmpMPhsoQhskQnZeGyhC"))
|
159
159
|
raw_mail.should match(Regexp.compile(ascii_8bit("\x76\x21")))
|
160
160
|
end
|
@@ -182,7 +182,7 @@ describe MobileMailer do
|
|
182
182
|
|
183
183
|
raw_mail = email.to_s
|
184
184
|
raw_mail.should match(/shift_jis/i)
|
185
|
-
|
185
|
+
raw_mail.should match(/For softbank/)
|
186
186
|
raw_mail.should match(Regexp.escape("k/qWe4zqkeiWvA=="))
|
187
187
|
raw_mail.should match(Regexp.compile(utf8_to_sjis(@text)))
|
188
188
|
end
|
@@ -196,7 +196,7 @@ describe MobileMailer do
|
|
196
196
|
ActionMailer::Base.deliveries.size.should == 1
|
197
197
|
|
198
198
|
raw_mail = email.to_s
|
199
|
-
|
199
|
+
raw_mail.should match(/For softbank/)
|
200
200
|
raw_mail.should match(Regexp.escape("k/qWe4zqkeiWvPl8"))
|
201
201
|
raw_mail.should match(regexp_to_sjis("\xf7\x6a"))
|
202
202
|
end
|
@@ -224,7 +224,7 @@ describe MobileMailer do
|
|
224
224
|
|
225
225
|
raw_mail = email.to_s
|
226
226
|
raw_mail.should match(/shift_jis/i)
|
227
|
-
|
227
|
+
raw_mail.should match(/For vodafone/)
|
228
228
|
raw_mail.should match(Regexp.escape("k/qWe4zqkeiWvA=="))
|
229
229
|
raw_mail.should match(Regexp.compile(utf8_to_sjis(@text)))
|
230
230
|
end
|
@@ -238,7 +238,7 @@ describe MobileMailer do
|
|
238
238
|
ActionMailer::Base.deliveries.size.should == 1
|
239
239
|
|
240
240
|
raw_mail = email.to_s
|
241
|
-
|
241
|
+
raw_mail.should match(/For vodafone/)
|
242
242
|
raw_mail.should match(Regexp.escape("k/qWe4zqkeiWvPl8"))
|
243
243
|
raw_mail.should match(regexp_to_sjis("\xf7\x6a"))
|
244
244
|
end
|
@@ -276,6 +276,7 @@ describe MobileMailer do
|
|
276
276
|
|
277
277
|
@subject = "題名"
|
278
278
|
@text = "本文"
|
279
|
+
@html = "万葉"
|
279
280
|
end
|
280
281
|
|
281
282
|
describe "PC の場合" do
|
@@ -283,8 +284,8 @@ describe MobileMailer do
|
|
283
284
|
@to = "gate@bill.com"
|
284
285
|
end
|
285
286
|
|
286
|
-
it "漢字コードが変換されること"
|
287
|
-
email = MobileMailer.multi_message(@to, @subject, @text).deliver
|
287
|
+
it "漢字コードが変換されること" do
|
288
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
288
289
|
|
289
290
|
ActionMailer::Base.deliveries.size.should == 1
|
290
291
|
|
@@ -292,7 +293,7 @@ describe MobileMailer do
|
|
292
293
|
|
293
294
|
raw_mail = ascii_8bit(email.to_s)
|
294
295
|
raw_mail.should match(Regexp.escape(ascii_8bit(utf8_to_jis(@text))))
|
295
|
-
raw_mail.should match(Regexp.escape(ascii_8bit(utf8_to_jis(
|
296
|
+
raw_mail.should match(Regexp.escape(ascii_8bit(utf8_to_jis(@html))))
|
296
297
|
end
|
297
298
|
end
|
298
299
|
|
@@ -302,31 +303,29 @@ describe MobileMailer do
|
|
302
303
|
end
|
303
304
|
|
304
305
|
it "漢字コードが変換されること" do
|
305
|
-
MobileMailer.multi_message(@to, @subject, @text).deliver
|
306
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
306
307
|
|
307
|
-
|
308
|
-
emails.size.should == 1
|
309
|
-
email = emails.first
|
308
|
+
ActionMailer::Base.deliveries.size.should == 1
|
310
309
|
|
311
310
|
email.parts.size.should == 2
|
312
311
|
|
313
|
-
email.
|
314
|
-
|
315
|
-
|
316
|
-
email.parts.last.body.should match(/#{Regexp.escape(NKF.nkf("-sWx", @plain))}/)
|
312
|
+
raw_mail = email.to_s
|
313
|
+
raw_mail.should match(sjis_regexp(utf8_to_sjis(@text)))
|
314
|
+
raw_mail.should match(sjis_regexp(utf8_to_sjis(@html)))
|
317
315
|
end
|
318
316
|
|
319
317
|
it "絵文字が変換されること" do
|
320
318
|
@text += ""
|
321
|
-
|
319
|
+
@html += ""
|
320
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
322
321
|
|
323
|
-
|
324
|
-
emails.size.should == 1
|
325
|
-
email = emails.first
|
322
|
+
ActionMailer::Base.deliveries.size.should == 1
|
326
323
|
|
327
324
|
email.parts.size.should == 2
|
328
|
-
|
329
|
-
email.
|
325
|
+
|
326
|
+
raw_mail = email.to_s
|
327
|
+
raw_mail.should match(sjis_regexp(sjis("\xf8\xec")))
|
328
|
+
raw_mail.should match(sjis_regexp(sjis("\xf8\xd7")))
|
330
329
|
end
|
331
330
|
end
|
332
331
|
|
@@ -336,32 +335,29 @@ describe MobileMailer do
|
|
336
335
|
end
|
337
336
|
|
338
337
|
it "漢字コードが変換されること" do
|
339
|
-
MobileMailer.multi_message(@to, @subject, @text).deliver
|
338
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
340
339
|
|
341
|
-
|
342
|
-
emails.size.should == 1
|
343
|
-
email = emails.first
|
340
|
+
ActionMailer::Base.deliveries.size.should == 1
|
344
341
|
|
345
342
|
email.parts.size.should == 2
|
346
343
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
email.parts.last.body.should match(/#{Regexp.escape(NKF.nkf("-jWx", @plain))}/)
|
344
|
+
raw_mail = ascii_8bit(email.to_s)
|
345
|
+
raw_mail.should match(Regexp.escape(ascii_8bit(utf8_to_jis(@text))))
|
346
|
+
raw_mail.should match(Regexp.escape(ascii_8bit(utf8_to_jis(@html))))
|
351
347
|
end
|
352
348
|
|
353
349
|
it "絵文字が変換されること" do
|
354
|
-
@text += "&#
|
355
|
-
|
350
|
+
@text += ""
|
351
|
+
@html += ""
|
352
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
356
353
|
|
357
|
-
|
358
|
-
emails.size.should == 1
|
359
|
-
email = emails.first
|
354
|
+
ActionMailer::Base.deliveries.size.should == 1
|
360
355
|
|
361
356
|
email.parts.size.should == 2
|
362
357
|
|
363
|
-
|
364
|
-
|
358
|
+
raw_mail = ascii_8bit(email.to_s)
|
359
|
+
raw_mail.should match(jis_regexp("\x76\x21"))
|
360
|
+
raw_mail.should match(jis_regexp("\x76\x5e"))
|
365
361
|
end
|
366
362
|
end
|
367
363
|
|
@@ -371,31 +367,29 @@ describe MobileMailer do
|
|
371
367
|
end
|
372
368
|
|
373
369
|
it "漢字コードが変換されること" do
|
374
|
-
MobileMailer.multi_message(@to, @subject, @text).deliver
|
370
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
375
371
|
|
376
|
-
|
377
|
-
emails.size.should == 1
|
378
|
-
email = emails.first
|
372
|
+
ActionMailer::Base.deliveries.size.should == 1
|
379
373
|
|
380
374
|
email.parts.size.should == 2
|
381
375
|
|
382
|
-
email.
|
383
|
-
|
384
|
-
|
385
|
-
email.parts.last.body.should match(/#{Regexp.escape(NKF.nkf("-sWx", @plain))}/)
|
376
|
+
raw_mail = email.to_s
|
377
|
+
raw_mail.should match(sjis_regexp(utf8_to_sjis(@text)))
|
378
|
+
raw_mail.should match(sjis_regexp(utf8_to_sjis(@html)))
|
386
379
|
end
|
387
380
|
|
388
381
|
it "絵文字が変換されること" do
|
389
382
|
@text += ""
|
390
|
-
|
383
|
+
@html += ""
|
384
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
391
385
|
|
392
|
-
|
393
|
-
emails.size.should == 1
|
394
|
-
email = emails.first
|
386
|
+
ActionMailer::Base.deliveries.size.should == 1
|
395
387
|
|
396
388
|
email.parts.size.should == 2
|
397
|
-
|
398
|
-
email.
|
389
|
+
|
390
|
+
raw_mail = email.to_s
|
391
|
+
raw_mail.should match(sjis_regexp(sjis("\xf7\x6a")))
|
392
|
+
raw_mail.should match(sjis_regexp(sjis("\xf9\x7c")))
|
399
393
|
end
|
400
394
|
end
|
401
395
|
|
@@ -405,31 +399,29 @@ describe MobileMailer do
|
|
405
399
|
end
|
406
400
|
|
407
401
|
it "漢字コードが変換されること" do
|
408
|
-
MobileMailer.multi_message(@to, @subject, @text).deliver
|
402
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
409
403
|
|
410
|
-
|
411
|
-
emails.size.should == 1
|
412
|
-
email = emails.first
|
404
|
+
ActionMailer::Base.deliveries.size.should == 1
|
413
405
|
|
414
406
|
email.parts.size.should == 2
|
415
407
|
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
email.parts.last.body.should match(/#{Regexp.escape(NKF.nkf("-jWx", @plain))}/)
|
408
|
+
raw_mail = email.to_s
|
409
|
+
raw_mail.should match(sjis_regexp(utf8_to_sjis(@text)))
|
410
|
+
raw_mail.should match(sjis_regexp(utf8_to_sjis(@html)))
|
420
411
|
end
|
421
412
|
|
422
413
|
it "絵文字が変換されること" do
|
423
414
|
@text += ""
|
424
|
-
|
415
|
+
@html += ""
|
416
|
+
email = MobileMailer.multi_message(@to, @subject, @text, @html).deliver
|
425
417
|
|
426
|
-
|
427
|
-
emails.size.should == 1
|
428
|
-
email = emails.first
|
418
|
+
ActionMailer::Base.deliveries.size.should == 1
|
429
419
|
|
430
420
|
email.parts.size.should == 2
|
431
|
-
|
432
|
-
|
421
|
+
|
422
|
+
raw_mail = email.to_s
|
423
|
+
raw_mail.should match(sjis_regexp(sjis("\xf7\x6a")))
|
424
|
+
raw_mail.should match(sjis_regexp(sjis("\xf9\x7c")))
|
433
425
|
end
|
434
426
|
end
|
435
427
|
end
|
@@ -604,7 +596,7 @@ describe MobileMailer, "receiving" do
|
|
604
596
|
email.body.should match(/本文/)
|
605
597
|
end
|
606
598
|
|
607
|
-
it "絵文字が数値参照に変わること"
|
599
|
+
it "絵文字が数値参照に変わること" do
|
608
600
|
email = MobileMailer.receive(@email)
|
609
601
|
|
610
602
|
email.subject.should match(//)
|
@@ -613,9 +605,9 @@ describe MobileMailer, "receiving" do
|
|
613
605
|
end
|
614
606
|
end
|
615
607
|
|
616
|
-
describe "multipart メールを受信するとき"
|
608
|
+
describe "multipart メールを受信するとき" do
|
617
609
|
describe "docomo の場合" do
|
618
|
-
# NOTE:
|
610
|
+
# NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
|
619
611
|
before(:each) do
|
620
612
|
@email = open(Rails.root + "spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml").read
|
621
613
|
end
|
@@ -635,8 +627,8 @@ describe MobileMailer, "receiving" do
|
|
635
627
|
email.parts.first.parts.size == 2
|
636
628
|
|
637
629
|
parts = email.parts.first.parts
|
638
|
-
parts.first.body.should match(
|
639
|
-
parts.last.body.should
|
630
|
+
parts.first.body.should match("テストです")
|
631
|
+
parts.last.body.raw_source.should match("テストです")
|
640
632
|
end
|
641
633
|
end
|
642
634
|
|
@@ -661,12 +653,12 @@ describe MobileMailer, "receiving" do
|
|
661
653
|
|
662
654
|
parts = email.parts.first.parts
|
663
655
|
parts.first.body.should match(/テストです/)
|
664
|
-
parts.last.body.should match(/テストです/)
|
656
|
+
parts.last.body.raw_source.should match(/テストです/)
|
665
657
|
end
|
666
658
|
end
|
667
659
|
|
668
660
|
describe "softbank(sjis) の場合" do
|
669
|
-
# NOTE:
|
661
|
+
# NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
|
670
662
|
before(:each) do
|
671
663
|
@email = open(Rails.root + "spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml").read
|
672
664
|
end
|
@@ -685,12 +677,12 @@ describe MobileMailer, "receiving" do
|
|
685
677
|
email.parts.size.should == 2
|
686
678
|
|
687
679
|
email.parts.first.body.should match(/テストです/)
|
688
|
-
email.parts.last.body.should match(/テストです/)
|
680
|
+
email.parts.last.body.raw_source.should match(/テストです/)
|
689
681
|
end
|
690
682
|
end
|
691
683
|
|
692
684
|
describe "softbank(utf8) の場合" do
|
693
|
-
# NOTE:
|
685
|
+
# NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
|
694
686
|
before(:each) do
|
695
687
|
@email = open(Rails.root + "spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml").read
|
696
688
|
end
|
@@ -709,7 +701,7 @@ describe MobileMailer, "receiving" do
|
|
709
701
|
email.parts.size.should == 2
|
710
702
|
|
711
703
|
email.parts.first.body.should match(/テストです/)
|
712
|
-
email.parts.last.body.should match(/テストです/)
|
704
|
+
email.parts.last.body.raw_source.should match(/テストです/)
|
713
705
|
end
|
714
706
|
end
|
715
707
|
|
@@ -736,8 +728,9 @@ describe MobileMailer, "receiving" do
|
|
736
728
|
|
737
729
|
email.has_attachments?.should be_true
|
738
730
|
email.attachments.size.should == 1
|
739
|
-
email.attachments.
|
740
|
-
email.attachments.
|
731
|
+
email.attachments['20098calendar01.jpg'].content_type.should match("image/jpeg")
|
732
|
+
email.attachments['20098calendar01.jpg'].body.to_s[2..6] == "JFIF"
|
733
|
+
email.attachments['20098calendar01.jpg'].body.to_s.size == 86412
|
741
734
|
end
|
742
735
|
end
|
743
736
|
end
|