jpmobile 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -3
- data/.rubocop.yml +123 -0
- data/CONTRIBUTING.md +16 -14
- data/Gemfile +6 -0
- data/Gemfile.lock +198 -0
- data/README.md +409 -0
- data/Rakefile +9 -9
- data/circle.yml +14 -0
- data/jpmobile.gemspec +9 -10
- data/lib/jpmobile.rb +6 -5
- data/lib/jpmobile/datum_conv.rb +35 -35
- data/lib/jpmobile/docomo_guid.rb +7 -8
- data/lib/jpmobile/email.rb +12 -12
- data/lib/jpmobile/emoticon.rb +85 -76
- data/lib/jpmobile/emoticon/au.rb +1284 -1284
- data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
- data/lib/jpmobile/emoticon/docomo.rb +252 -252
- data/lib/jpmobile/emoticon/google.rb +9 -9
- data/lib/jpmobile/emoticon/softbank.rb +471 -471
- data/lib/jpmobile/emoticon/unicode.rb +9 -9
- data/lib/jpmobile/emoticon/z_combine.rb +20 -23
- data/lib/jpmobile/encoding.rb +1 -1
- data/lib/jpmobile/fallback_view_selector.rb +2 -3
- data/lib/jpmobile/filter.rb +44 -47
- data/lib/jpmobile/helpers.rb +38 -38
- data/lib/jpmobile/hook_action_view.rb +7 -7
- data/lib/jpmobile/hook_test_request.rb +0 -1
- data/lib/jpmobile/lookup_context.rb +1 -2
- data/lib/jpmobile/mail.rb +156 -134
- data/lib/jpmobile/mailer.rb +4 -4
- data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
- data/lib/jpmobile/mobile/android.rb +0 -1
- data/lib/jpmobile/mobile/android_tablet.rb +0 -1
- data/lib/jpmobile/mobile/au.rb +40 -28
- data/lib/jpmobile/mobile/black_berry.rb +0 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -2
- data/lib/jpmobile/mobile/docomo.rb +47 -36
- data/lib/jpmobile/mobile/emobile.rb +1 -2
- data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
- data/lib/jpmobile/mobile/ipad.rb +0 -1
- data/lib/jpmobile/mobile/iphone.rb +0 -1
- data/lib/jpmobile/mobile/smart_phone.rb +0 -1
- data/lib/jpmobile/mobile/softbank.rb +24 -20
- data/lib/jpmobile/mobile/tablet.rb +0 -1
- data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
- data/lib/jpmobile/mobile/vodafone.rb +0 -1
- data/lib/jpmobile/mobile/willcom.rb +7 -7
- data/lib/jpmobile/mobile/windows_phone.rb +0 -1
- data/lib/jpmobile/path_set.rb +1 -1
- data/lib/jpmobile/position.rb +30 -14
- data/lib/jpmobile/rack/filter.rb +4 -4
- data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
- data/lib/jpmobile/rack/params_filter.rb +7 -6
- data/lib/jpmobile/rails.rb +3 -4
- data/lib/jpmobile/request_with_mobile.rb +9 -6
- data/lib/jpmobile/resolver.rb +23 -17
- data/lib/jpmobile/session/active_record_store.rb +7 -9
- data/lib/jpmobile/session/mem_cache_store.rb +7 -9
- data/lib/jpmobile/sinatra.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +15 -20
- data/lib/jpmobile/util.rb +61 -77
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +35 -28
- data/spec/rack/jpmobile/android_spec.rb +5 -5
- data/spec/rack/jpmobile/au_spec.rb +74 -59
- data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
- data/spec/rack/jpmobile/docomo_spec.rb +77 -64
- data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
- data/spec/rack/jpmobile/filter_spec.rb +149 -128
- data/spec/rack/jpmobile/iphone_spec.rb +9 -8
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
- data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
- data/spec/rack/jpmobile/softbank_spec.rb +49 -42
- data/spec/rack/jpmobile/willcom_spec.rb +22 -18
- data/spec/rack/jpmobile/windows_phone.rb +5 -5
- data/spec/rack_helper.rb +9 -8
- data/spec/spec_helper.rb +5 -6
- data/spec/unit/decorated_mail_spec.rb +8 -9
- data/spec/unit/email_spec.rb +44 -44
- data/spec/unit/emoticon_spec.rb +57 -58
- data/spec/unit/encoding_spec.rb +35 -36
- data/spec/unit/is_carrier_spec.rb +49 -49
- data/spec/unit/mail_spec.rb +153 -143
- data/spec/unit/mobile/iphone_spec.rb +6 -7
- data/spec/unit/receive_mail_spec.rb +172 -173
- data/spec/unit/spec_helper.rb +6 -6
- data/spec/unit/util_spec.rb +125 -46
- data/spec/unit/valid_ip_spec.rb +35 -35
- data/spec/unit/variants_spec.rb +18 -19
- data/test/rails/overrides/Gemfile +54 -0
- data/test/rails/overrides/Gemfile.jpmobile +1 -2
- data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
- data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
- data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
- data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
- data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
- data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
- data/test/rails/overrides/autotest/discover.rb +2 -2
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
- data/test/rails/overrides/config/routes.rb +95 -2
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
- data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
- data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
- data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
- data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
- data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
- data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
- data/test/rails/overrides/spec/rails_helper.rb +1 -1
- data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
- data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
- data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
- data/test/sinatra/test/filter_test.rb +10 -11
- data/tools/e4u_conv.rb +0 -1
- metadata +18 -14
- data/README +0 -0
- data/README.rdoc +0 -308
@@ -1,11 +1,10 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
|
3
2
|
|
4
3
|
describe Jpmobile::Mobile::Iphone do
|
5
4
|
describe 'iOS 4.0' do
|
6
|
-
it
|
5
|
+
it 'unicode_emoticon? should be false' do
|
7
6
|
request = double('request')
|
8
|
-
allow(request).to receive(:user_agent) {'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_4 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8K2 Safari/6533.18.5'}
|
7
|
+
allow(request).to receive(:user_agent) { 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_4 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8K2 Safari/6533.18.5' }
|
9
8
|
|
10
9
|
mobile = Jpmobile::Mobile::Iphone.new({}, request)
|
11
10
|
expect(mobile.unicode_emoticon?).to be_falsey
|
@@ -13,9 +12,9 @@ describe Jpmobile::Mobile::Iphone do
|
|
13
12
|
end
|
14
13
|
|
15
14
|
describe 'iOS 5.0' do
|
16
|
-
it
|
15
|
+
it 'unicode_emoticon? should be true' do
|
17
16
|
request = double('request')
|
18
|
-
allow(request).to receive(:user_agent) {'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3'}
|
17
|
+
allow(request).to receive(:user_agent) { 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3' }
|
19
18
|
|
20
19
|
mobile = Jpmobile::Mobile::Iphone.new({}, request)
|
21
20
|
expect(mobile.unicode_emoticon?).to be_truthy
|
@@ -23,9 +22,9 @@ describe Jpmobile::Mobile::Iphone do
|
|
23
22
|
end
|
24
23
|
|
25
24
|
describe 'iOS 6.0' do
|
26
|
-
it
|
25
|
+
it 'unicode_emoticon? should be true' do
|
27
26
|
request = double('request')
|
28
|
-
allow(request).to receive(:user_agent) {'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25'}
|
27
|
+
allow(request).to receive(:user_agent) { 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25' }
|
29
28
|
|
30
29
|
mobile = Jpmobile::Mobile::Iphone.new({}, request)
|
31
30
|
expect(mobile.unicode_emoticon?).to be_truthy
|
@@ -1,322 +1,321 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
3
2
|
require 'mail'
|
4
3
|
require 'jpmobile/mail'
|
5
4
|
|
6
|
-
describe
|
5
|
+
describe 'Jpmobile::Mail#receive' do
|
7
6
|
include Jpmobile::Util
|
8
7
|
|
9
8
|
before(:each) do
|
10
|
-
@to =
|
9
|
+
@to = 'info@jpmobile-rails.org'
|
11
10
|
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z\.\-]/)
|
12
11
|
end
|
13
12
|
|
14
|
-
describe
|
13
|
+
describe 'PC mail' do
|
15
14
|
before(:each) do
|
16
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
15
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/pc-mail-single.eml')).read)
|
17
16
|
end
|
18
17
|
|
19
|
-
it
|
20
|
-
expect(@mail.subject).to eq(
|
18
|
+
it 'subject should be parsed correctly' do
|
19
|
+
expect(@mail.subject).to eq('タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分')
|
21
20
|
end
|
22
21
|
|
23
|
-
it
|
22
|
+
it 'body should be parsed correctly' do
|
24
23
|
expect(@mail.body.to_s).to eq("本文です\n\n")
|
25
24
|
end
|
26
25
|
|
27
|
-
context
|
28
|
-
it
|
29
|
-
expect(ascii_8bit(@mail.to_s)).to match(
|
26
|
+
context 'to_s' do
|
27
|
+
it 'should have subject which is same as original' do
|
28
|
+
expect(ascii_8bit(@mail.to_s)).to match('GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s')
|
30
29
|
end
|
31
30
|
|
32
|
-
it
|
33
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis(
|
31
|
+
it 'should have body which is same as original' do
|
32
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis('本文です')))))
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
|
-
context
|
38
|
-
it
|
39
|
-
@mail.subject =
|
40
|
-
expect(ascii_8bit(@mail.to_s)).to match(
|
36
|
+
context 'modify and to_s' do
|
37
|
+
it 'should encode subject correctly' do
|
38
|
+
@mail.subject = '大江戸'
|
39
|
+
expect(ascii_8bit(@mail.to_s)).to match('GyRCQmc5PjhNGyhC')
|
41
40
|
end
|
42
41
|
|
43
|
-
it
|
44
|
-
@mail.body =
|
45
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis(
|
42
|
+
it 'should encode body correctly' do
|
43
|
+
@mail.body = '会議が開催'
|
44
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit(utf8_to_jis('会議が開催')))))
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
describe
|
51
|
-
describe
|
49
|
+
describe 'multipart' do
|
50
|
+
describe 'PC mail' do
|
52
51
|
before(:each) do
|
53
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
52
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/pc-mail-multi.eml')).read)
|
54
53
|
end
|
55
54
|
|
56
|
-
it
|
57
|
-
expect(@mail.subject).to eq(
|
55
|
+
it 'subject should be parsed correctly' do
|
56
|
+
expect(@mail.subject).to eq('タイトルの長いメールの場合の対処を実装するためのテストケースとしてのメールに含まれている件名であるサブジェクト部分')
|
58
57
|
end
|
59
58
|
|
60
|
-
it
|
59
|
+
it 'body should be parsed correctly' do
|
61
60
|
expect(@mail.body.parts.size).to eq(2)
|
62
61
|
expect(@mail.body.parts.first.body.to_s).to eq("本文です\n\n")
|
63
62
|
end
|
64
63
|
|
65
|
-
it
|
64
|
+
it 'should encode correctly' do
|
66
65
|
expect(ascii_8bit(@mail.to_s)).to match(/GyRCJT8lJCVIJWskTkQ5JCQlYSE8JWskTj5s/)
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
|
-
describe
|
69
|
+
describe 'PC mail without subject' do
|
71
70
|
before(:each) do
|
72
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
71
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/pc-mail-attached-without-subject.eml')).read)
|
73
72
|
end
|
74
73
|
|
75
|
-
it
|
74
|
+
it 'body should be parsed correctly' do
|
76
75
|
expect(@mail.body.parts.size).to eq(2)
|
77
76
|
expect(@mail.body.parts.first.body.to_s).to eq("本文です\n\n")
|
78
77
|
end
|
79
78
|
|
80
|
-
it
|
79
|
+
it 'should encode correctly' do
|
81
80
|
expect(ascii_8bit(@mail.to_s)).to match(/GODlhAQABAIAAAAAAAP/)
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
85
|
-
describe
|
86
|
-
context
|
84
|
+
describe 'Docomo' do
|
85
|
+
context 'with sjis decomail' do
|
87
86
|
before(:each) do
|
88
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
87
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml')).read)
|
89
88
|
end
|
90
89
|
|
91
|
-
it
|
92
|
-
expect(@mail.subject).to eq(
|
90
|
+
it 'subject should be parsed correctly' do
|
91
|
+
expect(@mail.subject).to eq('テスト')
|
93
92
|
end
|
94
93
|
|
95
|
-
it
|
94
|
+
it 'body should be parsed correctly' do
|
96
95
|
expect(@mail.body.parts.size).to eq(1)
|
97
|
-
@mail.body.parts.first.parts.size
|
98
|
-
expect(@mail.body.parts.first.parts.first.body).to match(
|
99
|
-
expect(@mail.body.parts.first.parts.last.body.raw_source).to match(
|
96
|
+
expect(@mail.body.parts.first.parts.size).to eq(2)
|
97
|
+
expect(@mail.body.parts.first.parts.first.body).to match('テストです')
|
98
|
+
expect(@mail.body.parts.first.parts.last.body.raw_source).to match('テストです')
|
100
99
|
end
|
101
100
|
|
102
|
-
it
|
103
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
101
|
+
it 'should encode correctly' do
|
102
|
+
expect(@mail.to_s).to match(Regexp.escape('g2WDWINn+ZE'))
|
104
103
|
end
|
105
104
|
|
106
|
-
it
|
105
|
+
it 'does not cause double-conversion on reparsing' do
|
107
106
|
@reparsed = Mail.new(@mail.to_s)
|
108
|
-
expect(@reparsed.to_s).to match(Regexp.escape(
|
109
|
-
expect(@reparsed.body.parts.first.parts.first.body).to match(
|
107
|
+
expect(@reparsed.to_s).to match(Regexp.escape('g2WDWINn+ZE'))
|
108
|
+
expect(@reparsed.body.parts.first.parts.first.body).to match('テストです')
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
|
-
context
|
112
|
+
context 'with jis decomail' do
|
114
113
|
before(:each) do
|
115
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
114
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/docomo-decomail.eml')).read)
|
116
115
|
end
|
117
116
|
|
118
|
-
it
|
117
|
+
it 'does not contain charset within multipart Content-Type' do
|
119
118
|
expect(@mail.to_s.scan(/Content-Type:\s+multipart(?:.+;\r\n)*.+[^;]\r\n/)).
|
120
|
-
to satisfy{|matches| matches.all?{|type| !type.include?('charset')}}
|
119
|
+
to satisfy { |matches| matches.all? { |type| !type.include?('charset') } }
|
121
120
|
end
|
122
121
|
|
123
|
-
it
|
122
|
+
it 'does not cause double-conversion on reparsing' do
|
124
123
|
@reparsed = Mail.new(@mail.to_s)
|
125
|
-
expect(@reparsed.to_s).to match(Regexp.escape(
|
126
|
-
expect(@reparsed.parts.first.parts.first.parts.first.body.decoded).to match(
|
124
|
+
expect(@reparsed.to_s).to match(Regexp.escape('g2WDWINn'))
|
125
|
+
expect(@reparsed.parts.first.parts.first.parts.first.body.decoded).to match('テストです')
|
127
126
|
end
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
131
|
-
describe
|
130
|
+
describe 'Au' do
|
132
131
|
before(:each) do
|
133
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
132
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml')).read)
|
134
133
|
end
|
135
134
|
|
136
|
-
it
|
137
|
-
expect(@mail.subject).to eq(
|
135
|
+
it 'subject should be parsed correctly' do
|
136
|
+
expect(@mail.subject).to eq('テスト')
|
138
137
|
end
|
139
138
|
|
140
|
-
it
|
139
|
+
it 'body should be parsed correctly' do
|
141
140
|
expect(@mail.body.parts.size).to eq(1)
|
142
|
-
@mail.body.parts.first.parts.size
|
143
|
-
expect(@mail.body.parts.first.parts.first.body.to_s).to match(
|
144
|
-
expect(@mail.body.parts.first.parts.last.body.raw_source).to match(
|
141
|
+
expect(@mail.body.parts.first.parts.size).to eq(2)
|
142
|
+
expect(@mail.body.parts.first.parts.first.body.to_s).to match('テストです')
|
143
|
+
expect(@mail.body.parts.first.parts.last.body.raw_source).to match('テストです')
|
145
144
|
end
|
146
145
|
|
147
|
-
it
|
148
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape(
|
146
|
+
it 'should encode correctly' do
|
147
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape('GyRCJUYlOSVIdk8bKEI='))
|
149
148
|
end
|
150
149
|
end
|
151
150
|
|
152
|
-
describe
|
153
|
-
context
|
151
|
+
describe 'Softbank' do
|
152
|
+
context 'Shift_JIS' do
|
154
153
|
before(:each) do
|
155
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
154
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml')).read)
|
156
155
|
end
|
157
156
|
|
158
|
-
it
|
159
|
-
expect(@mail.subject).to eq(
|
157
|
+
it 'subject should be parsed correctly' do
|
158
|
+
expect(@mail.subject).to eq('テスト')
|
160
159
|
end
|
161
160
|
|
162
|
-
it
|
161
|
+
it 'body should be parsed correctly' do
|
163
162
|
expect(@mail.body.parts.size).to eq(2)
|
164
|
-
expect(@mail.body.parts.first.body.to_s).to eq(
|
163
|
+
expect(@mail.body.parts.first.body.to_s).to eq('テストです')
|
165
164
|
end
|
166
165
|
|
167
|
-
it
|
168
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
166
|
+
it 'should encode correctly' do
|
167
|
+
expect(@mail.to_s).to match(Regexp.escape('g2WDWINn98H3w/fB'))
|
169
168
|
end
|
170
169
|
end
|
171
170
|
|
172
|
-
context
|
171
|
+
context 'UTF-8' do
|
173
172
|
before(:each) do
|
174
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
173
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml')).read)
|
175
174
|
end
|
176
175
|
|
177
|
-
it
|
178
|
-
expect(@mail.subject).to eq(
|
176
|
+
it 'subject should be parsed correctly' do
|
177
|
+
expect(@mail.subject).to eq('テストです')
|
179
178
|
end
|
180
179
|
|
181
|
-
it
|
180
|
+
it 'body should be parsed correctly' do
|
182
181
|
expect(@mail.body.parts.size).to eq(2)
|
183
|
-
expect(@mail.body.parts.first.body.raw_source).to eq(
|
182
|
+
expect(@mail.body.parts.first.body.raw_source).to eq('テストです')
|
184
183
|
end
|
185
184
|
|
186
|
-
it
|
187
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
185
|
+
it 'should encode correctly to Shift_JIS' do
|
186
|
+
expect(@mail.to_s).to match(Regexp.escape('g2WDWINngsWCt/fB'))
|
188
187
|
end
|
189
188
|
end
|
190
189
|
end
|
191
190
|
|
192
191
|
context 'bounced mail' do
|
193
192
|
it 'should parse sub-part charset correctly' do
|
194
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
193
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/bounce_with_utf8_part.eml')).read)
|
195
194
|
expect(@mail.parts.first.charset).to match(/iso-2022-jp/i)
|
196
195
|
expect(@mail.parts.last.charset).to match(/utf-8/i)
|
197
196
|
end
|
198
197
|
end
|
199
198
|
end
|
200
199
|
|
201
|
-
describe
|
200
|
+
describe 'Docomo' do
|
202
201
|
before(:each) do
|
203
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
202
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/docomo-emoji.eml')).read)
|
204
203
|
end
|
205
204
|
|
206
|
-
it
|
207
|
-
expect(@mail.subject).to eq(
|
205
|
+
it 'subject should be parsed correctly' do
|
206
|
+
expect(@mail.subject).to eq('題名')
|
208
207
|
end
|
209
208
|
|
210
|
-
it
|
211
|
-
expect(@mail.body.to_s).to eq("本文\nFor docomo\n\n")
|
209
|
+
it 'body should be parsed correctly' do
|
210
|
+
expect(@mail.body.to_s).to eq("本文\r\nFor docomo\r\n\r\n")
|
212
211
|
end
|
213
212
|
|
214
|
-
context
|
215
|
-
it
|
216
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
213
|
+
context 'to_s' do
|
214
|
+
it 'should have subject which is same as original' do
|
215
|
+
expect(@mail.to_s).to match(Regexp.escape('keiWvPjX'))
|
217
216
|
end
|
218
217
|
|
219
|
-
it
|
220
|
-
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis(
|
218
|
+
it 'should have body which is same as original' do
|
219
|
+
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis('本文')))
|
221
220
|
end
|
222
221
|
end
|
223
222
|
|
224
|
-
context
|
225
|
-
it
|
226
|
-
@mail.subject =
|
227
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
223
|
+
context 'modify and to_s' do
|
224
|
+
it 'should encode subject correctly' do
|
225
|
+
@mail.subject = '大江戸'
|
226
|
+
expect(@mail.to_s).to match(Regexp.escape('keWNXYzL+J8='))
|
228
227
|
end
|
229
228
|
|
230
|
-
it
|
231
|
-
@mail.body =
|
229
|
+
it 'should encode body correctly' do
|
230
|
+
@mail.body = '会議が開催'
|
232
231
|
expect(@mail.to_s).to match(sjis_regexp(sjis("\x89\xEF\x8Bc\x82\xAA\x8AJ\x8D\xC3\xF8\xA7")))
|
233
232
|
end
|
234
233
|
end
|
235
234
|
|
236
|
-
context
|
235
|
+
context 'JIS mail' do
|
237
236
|
before(:each) do
|
238
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
237
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/docomo-jis.eml')).read)
|
239
238
|
end
|
240
239
|
|
241
|
-
it
|
242
|
-
expect(@mail.subject).to eq(
|
240
|
+
it 'subject should be parsed correctly' do
|
241
|
+
expect(@mail.subject).to eq('テスト')
|
243
242
|
end
|
244
243
|
|
245
|
-
it
|
244
|
+
it 'body should be parsed correctly' do
|
246
245
|
expect(@mail.body.to_s).to eq("テスト本文\n\n")
|
247
246
|
end
|
248
247
|
end
|
249
248
|
end
|
250
249
|
|
251
|
-
describe
|
250
|
+
describe 'Au' do
|
252
251
|
context 'au-emoji.eml' do
|
253
252
|
before(:each) do
|
254
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
253
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-emoji.eml')).read)
|
255
254
|
end
|
256
255
|
|
257
|
-
it
|
258
|
-
expect(@mail.subject).to eq(
|
256
|
+
it 'subject should be parsed correctly' do
|
257
|
+
expect(@mail.subject).to eq('題名')
|
259
258
|
end
|
260
259
|
|
261
|
-
it
|
260
|
+
it 'body should be parsed correctly' do
|
262
261
|
expect(@mail.body.to_s).to eq("本文\nFor au\n\n")
|
263
262
|
end
|
264
263
|
|
265
|
-
context
|
266
|
-
it
|
267
|
-
expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape(
|
264
|
+
context 'to_s' do
|
265
|
+
it 'should have subject which is same as original' do
|
266
|
+
expect(ascii_8bit(@mail.to_s)).to match(Regexp.escape('GyRCQmpMPnZeGyhC'))
|
268
267
|
end
|
269
268
|
|
270
|
-
it
|
269
|
+
it 'should have body which is same as original' do
|
271
270
|
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\e\x24\x42\x4B\x5C\x4A\x38\x76\x7D\e\x28\x42"))))
|
272
271
|
end
|
273
272
|
end
|
274
273
|
|
275
|
-
context
|
276
|
-
it
|
277
|
-
@mail.subject =
|
274
|
+
context 'modify and to_s' do
|
275
|
+
it 'should encode subject correctly' do
|
276
|
+
@mail.subject = '大江戸'
|
278
277
|
expect(ascii_8bit(@mail.to_s)).to match(/\?GyRCQmc5PjhNdUEbKEI=/)
|
279
278
|
end
|
280
279
|
|
281
|
-
it
|
282
|
-
@mail.body =
|
280
|
+
it 'should encode body correctly' do
|
281
|
+
@mail.body = '会議が開催'
|
283
282
|
expect(ascii_8bit(@mail.to_s)).to match(Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42\x32\x71\x35\x44\x24\x2C\x33\x2B\x3A\x45\x75\x48\x1b\x28\x42"))))
|
284
283
|
end
|
285
284
|
end
|
286
285
|
end
|
287
286
|
|
288
|
-
it
|
287
|
+
it 'should not be raised when parsing incoming email #41' do
|
289
288
|
expect {
|
290
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
289
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-email.eml')).read)
|
291
290
|
}.not_to raise_error
|
292
291
|
end
|
293
292
|
|
294
|
-
it
|
293
|
+
it 'should not be raised when parsing incoming email #45' do
|
295
294
|
expect {
|
296
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
295
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-decomail2.eml')).read)
|
297
296
|
}.not_to raise_error
|
298
297
|
end
|
299
298
|
|
300
|
-
it
|
299
|
+
it 'should not be raised when parsing incoming email - include kigou' do
|
301
300
|
expect {
|
302
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
301
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-kigou.eml')).read)
|
303
302
|
}.not_to raise_error
|
304
303
|
end
|
305
304
|
|
306
305
|
context 'From au iPhone' do
|
307
306
|
it 'charset should be UTF-8' do
|
308
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
307
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-message.eml')).read)
|
309
308
|
expect(@mail.mobile).to be_a(Jpmobile::Mobile::Au)
|
310
309
|
expect(@mail.charset).to match(/utf-8/i)
|
311
310
|
end
|
312
311
|
|
313
312
|
it 'should be encoded correctly' do
|
314
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
313
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-message.eml')).read)
|
315
314
|
expect(@mail.encoded).to match(Regexp.escape("%[\e$B1`;yL>\e(B]%\e$B$N\e(B%[\e$BJ]8n<TL>\e(B]%"))
|
316
315
|
end
|
317
316
|
|
318
317
|
it 'should decode cp932-encoded mail correctly' do
|
319
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
318
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-cp932.eml')).read)
|
320
319
|
expect(@mail.subject).to eq 'Re: 【NKSC】test'
|
321
320
|
expect(@mail.body.to_s).to eq 'テストです。㈱'
|
322
321
|
end
|
@@ -324,145 +323,145 @@ describe "Jpmobile::Mail#receive" do
|
|
324
323
|
|
325
324
|
context 'From iPad' do
|
326
325
|
it 'charset should be UTF-8' do
|
327
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
326
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-mail3.eml')).read)
|
328
327
|
expect(@mail.mobile).to be_a(Jpmobile::Mobile::AbstractMobile)
|
329
328
|
expect(@mail.charset).to match(/utf-8/i)
|
330
329
|
end
|
331
330
|
|
332
331
|
it 'should be encoded correctly' do
|
333
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
332
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-mail3.eml')).read)
|
334
333
|
expect(@mail.encoded).to match(/BK\\J82~9T\$J\$7!2#5#1#2J8;z!2/)
|
335
334
|
end
|
336
335
|
end
|
337
336
|
|
338
337
|
it 'should not raise when parsing attached email' do
|
339
338
|
expect {
|
340
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
339
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/au-attached.eml')).read)
|
341
340
|
expect(@mail.encoded).to match('/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPQAA')
|
342
341
|
}.not_to raise_error
|
343
342
|
end
|
344
343
|
end
|
345
344
|
|
346
|
-
describe
|
345
|
+
describe 'Softbank' do
|
347
346
|
before(:each) do
|
348
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
347
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/softbank-emoji.eml')).read)
|
349
348
|
end
|
350
349
|
|
351
|
-
it
|
352
|
-
expect(@mail.subject).to eq(
|
350
|
+
it 'subject should be parsed correctly' do
|
351
|
+
expect(@mail.subject).to eq('題名')
|
353
352
|
end
|
354
353
|
|
355
|
-
it
|
356
|
-
expect(@mail.body.to_s).to eq("本文\nFor softbank\n\n")
|
354
|
+
it 'body should be parsed correctly' do
|
355
|
+
expect(@mail.body.to_s).to eq("本文\r\nFor softbank\r\n\r\n")
|
357
356
|
end
|
358
357
|
|
359
|
-
context
|
360
|
-
it
|
361
|
-
expect(@mail.to_s).to match(sjis_regexp(
|
358
|
+
context 'to_s' do
|
359
|
+
it 'should have subject which is same as original' do
|
360
|
+
expect(@mail.to_s).to match(sjis_regexp('keiWvPl8'))
|
362
361
|
end
|
363
362
|
|
364
|
-
it
|
365
|
-
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis(
|
363
|
+
it 'should have body which is same as original' do
|
364
|
+
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis('本文')))
|
366
365
|
end
|
367
366
|
end
|
368
367
|
|
369
|
-
context
|
370
|
-
it
|
371
|
-
@mail.subject =
|
372
|
-
expect(@mail.to_s).to match(Regexp.escape(
|
368
|
+
context 'modify and to_s' do
|
369
|
+
it 'should encode subject correctly' do
|
370
|
+
@mail.subject = '大江戸'
|
371
|
+
expect(@mail.to_s).to match(Regexp.escape('keWNXYzL+Ys='))
|
373
372
|
end
|
374
373
|
|
375
|
-
it
|
376
|
-
@mail.body =
|
377
|
-
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis(
|
374
|
+
it 'should encode body correctly' do
|
375
|
+
@mail.body = '会議が開催'
|
376
|
+
expect(@mail.to_s).to match(sjis_regexp(utf8_to_sjis('会議が開催') + sjis("\xf7\xdf")))
|
378
377
|
end
|
379
378
|
end
|
380
379
|
|
381
|
-
describe
|
380
|
+
describe 'blank-mail' do
|
382
381
|
before(:each) do
|
383
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
382
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/softbank-blank.eml')).read)
|
384
383
|
end
|
385
384
|
|
386
|
-
it
|
385
|
+
it 'subject should be parsed correctly' do
|
387
386
|
expect(@mail.subject).to be_nil
|
388
387
|
end
|
389
388
|
|
390
|
-
it
|
389
|
+
it 'body should be parsed correctly' do
|
391
390
|
expect(@mail.body.to_s).to be_empty
|
392
391
|
end
|
393
392
|
end
|
394
393
|
end
|
395
394
|
|
396
|
-
describe
|
397
|
-
context
|
395
|
+
describe 'iPhone' do
|
396
|
+
context 'JIS mail' do
|
398
397
|
before(:each) do
|
399
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
398
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-jis.eml')).read)
|
400
399
|
end
|
401
400
|
|
402
|
-
it
|
401
|
+
it 'body should be parsed correctly' do
|
403
402
|
expect(@mail.body.to_s).to eq("(=゚ω゚)ノ\n\n\n")
|
404
403
|
end
|
405
404
|
end
|
406
405
|
|
407
|
-
context
|
406
|
+
context 'when the mail contains UTF-8 emojis' do
|
408
407
|
before(:each) do
|
409
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
408
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-unicode-emoji.eml')).read)
|
410
409
|
end
|
411
410
|
|
412
|
-
it
|
411
|
+
it 'subject should be parsed correctly' do
|
413
412
|
expect(@mail.subject).to eq("絵文字\u{1F385}")
|
414
413
|
end
|
415
414
|
|
416
|
-
it
|
415
|
+
it 'body should be parsed correctly' do
|
417
416
|
expect(@mail.body.to_s).to eq("\u{1F384}\u2763")
|
418
417
|
end
|
419
418
|
end
|
420
419
|
|
421
|
-
context
|
420
|
+
context 'when the mail contains circled-numbers' do
|
422
421
|
before(:each) do
|
423
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
422
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/iphone-circled-numbers-in-jis.eml')).read)
|
424
423
|
end
|
425
424
|
|
426
|
-
it
|
427
|
-
expect(@mail.subject).to eq(
|
425
|
+
it 'subject should be parsed correctly' do
|
426
|
+
expect(@mail.subject).to eq('テスト①')
|
428
427
|
end
|
429
428
|
|
430
|
-
it
|
429
|
+
it 'body should be parsed correctly' do
|
431
430
|
expect(@mail.body.to_s).to eq("丸数字のテストです②ⅱ\n\n")
|
432
431
|
end
|
433
432
|
end
|
434
433
|
end
|
435
434
|
|
436
435
|
describe 'bounced mail' do
|
437
|
-
context
|
436
|
+
context 'has jp address' do
|
438
437
|
before(:each) do
|
439
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
438
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/bounced-jp.eml')).read)
|
440
439
|
end
|
441
440
|
|
442
|
-
it
|
441
|
+
it 'mobile should abstract mobile' do
|
443
442
|
expect(@mail.mobile).to be_a Jpmobile::Mobile::AbstractMobile
|
444
443
|
end
|
445
444
|
end
|
446
445
|
end
|
447
446
|
|
448
|
-
describe
|
449
|
-
context
|
447
|
+
describe 'non-Japanese mail' do
|
448
|
+
context 'us-ascii' do
|
450
449
|
before(:each) do
|
451
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
450
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/non-jp.eml')).read)
|
452
451
|
end
|
453
452
|
|
454
|
-
it
|
453
|
+
it 'mobile should be nil' do
|
455
454
|
expect(@mail.mobile).to be_nil
|
456
455
|
expect(@mail.parts.first.charset).to eq('us-ascii')
|
457
456
|
end
|
458
457
|
end
|
459
458
|
|
460
|
-
context
|
459
|
+
context 'no From header' do
|
461
460
|
before(:each) do
|
462
|
-
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)),
|
461
|
+
@mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), '../../test/rails/overrides/spec/fixtures/mobile_mailer/no-from.eml')).read)
|
463
462
|
end
|
464
463
|
|
465
|
-
it
|
464
|
+
it 'mobile should be nil' do
|
466
465
|
expect(@mail.mobile).to be_nil
|
467
466
|
expect(@mail.parts.first.charset).to eq('iso-8859-1')
|
468
467
|
end
|