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,149 +1,158 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
|
3
2
|
|
4
3
|
describe Jpmobile::Filter do
|
5
4
|
include Rack::Test::Methods
|
6
5
|
include Jpmobile::RackHelper
|
7
6
|
|
8
|
-
context
|
7
|
+
context '漢字コード変換' do
|
9
8
|
before(:each) do
|
10
9
|
@utf8 = "ゆーてぃーえふえいとの\n日本語〜ですが何か"
|
11
10
|
@sjis = utf8_to_sjis(@utf8)
|
12
11
|
end
|
13
12
|
|
14
|
-
context
|
15
|
-
it
|
13
|
+
context 'docomo のとき' do
|
14
|
+
it 'Shift_JIS に変換されること' do
|
16
15
|
res = Rack::MockRequest.env_for(
|
17
|
-
|
18
|
-
|
16
|
+
'/',
|
17
|
+
'REQUEST_METHOD' => 'GET',
|
19
18
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
20
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
19
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
20
|
+
)
|
21
21
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
22
|
-
expect(res[1]['Content-Type']).to eq(
|
22
|
+
expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
|
23
23
|
expect(response_body(res)).to eq(@sjis)
|
24
24
|
end
|
25
25
|
|
26
|
-
context
|
27
|
-
it
|
26
|
+
context 'Content-Type' do
|
27
|
+
it 'が application/xhtml+xml のときに変換されること' do
|
28
28
|
res = Rack::MockRequest.env_for(
|
29
|
-
|
30
|
-
|
29
|
+
'/',
|
30
|
+
'REQUEST_METHOD' => 'GET',
|
31
31
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
32
|
-
'Content-Type' => 'application/xhtml+xml; charset=utf-8'
|
32
|
+
'Content-Type' => 'application/xhtml+xml; charset=utf-8'
|
33
|
+
)
|
33
34
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
34
|
-
expect(res[1]['Content-Type']).to eq(
|
35
|
+
expect(res[1]['Content-Type']).to eq('application/xhtml+xml; charset=Shift_JIS')
|
35
36
|
expect(response_body(res)).to eq(@sjis)
|
36
37
|
end
|
37
38
|
|
38
|
-
it
|
39
|
+
it 'が application/xml のときに変換されないこと' do
|
39
40
|
res = Rack::MockRequest.env_for(
|
40
|
-
|
41
|
-
|
41
|
+
'/',
|
42
|
+
'REQUEST_METHOD' => 'GET',
|
42
43
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
43
|
-
'Content-Type' => 'application/xml; charset=utf-8'
|
44
|
+
'Content-Type' => 'application/xml; charset=utf-8'
|
45
|
+
)
|
44
46
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
45
|
-
expect(res[1]['Content-Type']).to eq(
|
47
|
+
expect(res[1]['Content-Type']).to eq('application/xml; charset=utf-8')
|
46
48
|
expect(response_body(res)).to eq(@utf8)
|
47
49
|
end
|
48
50
|
|
49
|
-
it
|
51
|
+
it 'が image/jpeg のときに変換されないこと' do
|
50
52
|
res = Rack::MockRequest.env_for(
|
51
|
-
|
52
|
-
|
53
|
+
'/',
|
54
|
+
'REQUEST_METHOD' => 'GET',
|
53
55
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
54
|
-
'Content-Type' => 'image/jpeg'
|
56
|
+
'Content-Type' => 'image/jpeg'
|
57
|
+
)
|
55
58
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
56
|
-
expect(res[1]['Content-Type']).to eq(
|
59
|
+
expect(res[1]['Content-Type']).to eq('image/jpeg')
|
57
60
|
expect(response_body(res)).to eq(@utf8)
|
58
61
|
end
|
59
62
|
|
60
|
-
it
|
63
|
+
it 'が application/octet-stream のときに変換されないこと' do
|
61
64
|
res = Rack::MockRequest.env_for(
|
62
|
-
|
63
|
-
|
65
|
+
'/',
|
66
|
+
'REQUEST_METHOD' => 'GET',
|
64
67
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
65
|
-
'Content-Type' => 'application/octet-stream'
|
68
|
+
'Content-Type' => 'application/octet-stream'
|
69
|
+
)
|
66
70
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
67
|
-
expect(res[1]['Content-Type']).to eq(
|
71
|
+
expect(res[1]['Content-Type']).to eq('application/octet-stream')
|
68
72
|
expect(response_body(res)).to eq(@utf8)
|
69
73
|
end
|
70
74
|
|
71
|
-
it
|
75
|
+
it 'が video/mpeg のときに変換されないこと' do
|
72
76
|
res = Rack::MockRequest.env_for(
|
73
|
-
|
74
|
-
|
77
|
+
'/',
|
78
|
+
'REQUEST_METHOD' => 'GET',
|
75
79
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
76
|
-
'Content-Type' => 'video/mpeg'
|
80
|
+
'Content-Type' => 'video/mpeg'
|
81
|
+
)
|
77
82
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
78
|
-
expect(res[1]['Content-Type']).to eq(
|
83
|
+
expect(res[1]['Content-Type']).to eq('video/mpeg')
|
79
84
|
expect(response_body(res)).to eq(@utf8)
|
80
85
|
end
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
84
|
-
context
|
85
|
-
it
|
89
|
+
context 'au のとき' do
|
90
|
+
it 'Shift_JIS に変換されること' do
|
86
91
|
res = Rack::MockRequest.env_for(
|
87
|
-
|
88
|
-
|
89
|
-
'HTTP_USER_AGENT' =>
|
90
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
92
|
+
'/',
|
93
|
+
'REQUEST_METHOD' => 'GET',
|
94
|
+
'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
|
95
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
96
|
+
)
|
91
97
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
92
|
-
expect(res[1]['Content-Type']).to eq(
|
98
|
+
expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
|
93
99
|
expect(response_body(res)).to eq(@sjis)
|
94
100
|
end
|
95
101
|
end
|
96
102
|
|
97
|
-
context
|
98
|
-
it
|
103
|
+
context 'softbank のとき' do
|
104
|
+
it '変換されないこと' do
|
99
105
|
res = Rack::MockRequest.env_for(
|
100
|
-
|
101
|
-
|
102
|
-
'HTTP_USER_AGENT' =>
|
103
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
106
|
+
'/',
|
107
|
+
'REQUEST_METHOD' => 'GET',
|
108
|
+
'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
|
109
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
110
|
+
)
|
104
111
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8))).call(res)
|
105
|
-
expect(res[1]['Content-Type']).to eq(
|
112
|
+
expect(res[1]['Content-Type']).to eq('text/html; charset=utf-8')
|
106
113
|
expect(response_body(res)).to eq(@utf8)
|
107
114
|
end
|
108
115
|
end
|
109
116
|
|
110
|
-
it
|
117
|
+
it '_snowman が出力されないこと' do
|
111
118
|
req = Rack::MockRequest.env_for(
|
112
|
-
|
113
|
-
|
119
|
+
'/',
|
120
|
+
'REQUEST_METHOD' => 'GET',
|
114
121
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
115
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
122
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
123
|
+
)
|
116
124
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="✓" />'))).call(req)
|
117
|
-
expect(res[1]['Content-Type']).to eq(
|
118
|
-
expect(response_body(res)).to eq(
|
125
|
+
expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
|
126
|
+
expect(response_body(res)).to eq(' ')
|
119
127
|
|
120
128
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="✓">'))).call(req)
|
121
|
-
expect(res[1]['Content-Type']).to eq(
|
122
|
-
expect(response_body(res)).to eq(
|
129
|
+
expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
|
130
|
+
expect(response_body(res)).to eq(' ')
|
123
131
|
end
|
124
132
|
|
125
|
-
it
|
133
|
+
it 'Nokogiri 経由の _snowman が出力されないこと' do
|
126
134
|
req = Rack::MockRequest.env_for(
|
127
|
-
|
128
|
-
|
135
|
+
'/',
|
136
|
+
'REQUEST_METHOD' => 'GET',
|
129
137
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
130
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
138
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
139
|
+
)
|
131
140
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new("<input name=\"utf8\" type=\"hidden\" value=\"#{[10003].pack("U")}\" />"))).call(req)
|
132
|
-
expect(res[1]['Content-Type']).to eq(
|
133
|
-
expect(response_body(res)).to eq(
|
141
|
+
expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
|
142
|
+
expect(response_body(res)).to eq(' ')
|
134
143
|
|
135
144
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new("<input name=\"utf8\" type=\"hidden\" value=\"#{[10003].pack("U")}\">"))).call(req)
|
136
|
-
expect(res[1]['Content-Type']).to eq(
|
137
|
-
expect(response_body(res)).to eq(
|
145
|
+
expect(res[1]['Content-Type']).to eq('text/html; charset=Shift_JIS')
|
146
|
+
expect(response_body(res)).to eq(' ')
|
138
147
|
end
|
139
148
|
end
|
140
149
|
|
141
|
-
context
|
150
|
+
context '絵文字変換' do
|
142
151
|
before(:each) do
|
143
|
-
@utf8 =
|
144
|
-
@emoji_docomo_cr =
|
145
|
-
@emoji_au_cr =
|
146
|
-
@emoji_softbank_cr =
|
152
|
+
@utf8 = 'ゆーてぃーえふえいとの日本語ですが何か'
|
153
|
+
@emoji_docomo_cr = ''
|
154
|
+
@emoji_au_cr = ''
|
155
|
+
@emoji_softbank_cr = ''
|
147
156
|
@emoji_docomo_utf8 = utf8([0xe64b].pack('U'))
|
148
157
|
@emoji_au_utf8 = utf8([0xe494].pack('U'))
|
149
158
|
@emoji_softbank_utf8 = utf8([0xf244].pack('U'))
|
@@ -154,127 +163,139 @@ describe Jpmobile::Filter do
|
|
154
163
|
@softbank_emoji = utf8("\356\211\204")
|
155
164
|
end
|
156
165
|
|
157
|
-
context
|
158
|
-
it
|
166
|
+
context 'docomo のとき' do
|
167
|
+
it '数値参照絵文字が変換されること' do
|
159
168
|
res = Rack::MockRequest.env_for(
|
160
|
-
|
161
|
-
|
169
|
+
'/',
|
170
|
+
'REQUEST_METHOD' => 'GET',
|
162
171
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
163
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
172
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
173
|
+
)
|
164
174
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_cr))).call(res)
|
165
175
|
expect(response_body(res)).to eq(@sjis + @docomo_emoji)
|
166
176
|
end
|
167
177
|
|
168
|
-
it
|
178
|
+
it 'docomo のUTF-8絵文字が変換されること' do
|
169
179
|
res = Rack::MockRequest.env_for(
|
170
|
-
|
171
|
-
|
180
|
+
'/',
|
181
|
+
'REQUEST_METHOD' => 'GET',
|
172
182
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
173
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
183
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
184
|
+
)
|
174
185
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_utf8))).call(res)
|
175
186
|
expect(response_body(res)).to eq(@sjis + @docomo_emoji)
|
176
187
|
end
|
177
188
|
|
178
|
-
it
|
189
|
+
it 'au のUTF-8絵文字が変換されること' do
|
179
190
|
res = Rack::MockRequest.env_for(
|
180
|
-
|
181
|
-
|
191
|
+
'/',
|
192
|
+
'REQUEST_METHOD' => 'GET',
|
182
193
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
183
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
194
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
195
|
+
)
|
184
196
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_utf8))).call(res)
|
185
197
|
expect(response_body(res)).to eq(@sjis + @docomo_emoji)
|
186
198
|
end
|
187
199
|
|
188
|
-
it
|
200
|
+
it 'softbank のUTF-8絵文字が変換されること' do
|
189
201
|
res = Rack::MockRequest.env_for(
|
190
|
-
|
191
|
-
|
202
|
+
'/',
|
203
|
+
'REQUEST_METHOD' => 'GET',
|
192
204
|
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
|
193
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
205
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
206
|
+
)
|
194
207
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_utf8))).call(res)
|
195
208
|
expect(response_body(res)).to eq(@sjis + @docomo_emoji)
|
196
209
|
end
|
197
210
|
end
|
198
211
|
|
199
|
-
context
|
200
|
-
it
|
212
|
+
context 'au のとき' do
|
213
|
+
it '数値参照絵文字が変換されること' do
|
201
214
|
res = Rack::MockRequest.env_for(
|
202
|
-
|
203
|
-
|
204
|
-
'HTTP_USER_AGENT' =>
|
205
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
215
|
+
'/',
|
216
|
+
'REQUEST_METHOD' => 'GET',
|
217
|
+
'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
|
218
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
219
|
+
)
|
206
220
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_cr))).call(res)
|
207
221
|
expect(response_body(res)).to eq(@sjis + @au_emoji)
|
208
222
|
end
|
209
223
|
|
210
|
-
it
|
224
|
+
it 'docomo のUTF-8絵文字が変換されること' do
|
211
225
|
res = Rack::MockRequest.env_for(
|
212
|
-
|
213
|
-
|
214
|
-
'HTTP_USER_AGENT' =>
|
215
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
226
|
+
'/',
|
227
|
+
'REQUEST_METHOD' => 'GET',
|
228
|
+
'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
|
229
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
230
|
+
)
|
216
231
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_utf8))).call(res)
|
217
232
|
expect(response_body(res)).to eq(@sjis + @au_emoji)
|
218
233
|
end
|
219
234
|
|
220
|
-
it
|
235
|
+
it 'au のUTF-8絵文字が変換されること' do
|
221
236
|
res = Rack::MockRequest.env_for(
|
222
|
-
|
223
|
-
|
224
|
-
'HTTP_USER_AGENT' =>
|
225
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
237
|
+
'/',
|
238
|
+
'REQUEST_METHOD' => 'GET',
|
239
|
+
'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
|
240
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
241
|
+
)
|
226
242
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_utf8))).call(res)
|
227
243
|
expect(response_body(res)).to eq(@sjis + @au_emoji)
|
228
244
|
end
|
229
245
|
|
230
|
-
it
|
246
|
+
it 'softbank のUTF-8絵文字が変換されること' do
|
231
247
|
res = Rack::MockRequest.env_for(
|
232
|
-
|
233
|
-
|
234
|
-
'HTTP_USER_AGENT' =>
|
235
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
248
|
+
'/',
|
249
|
+
'REQUEST_METHOD' => 'GET',
|
250
|
+
'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
|
251
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
252
|
+
)
|
236
253
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_utf8))).call(res)
|
237
254
|
expect(response_body(res)).to eq(@sjis + @au_emoji)
|
238
255
|
end
|
239
256
|
end
|
240
257
|
|
241
|
-
context
|
242
|
-
it
|
258
|
+
context 'softbank のとき' do
|
259
|
+
it '数値参照絵文字が変換されること' do
|
243
260
|
res = Rack::MockRequest.env_for(
|
244
|
-
|
245
|
-
|
246
|
-
'HTTP_USER_AGENT' =>
|
247
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
261
|
+
'/',
|
262
|
+
'REQUEST_METHOD' => 'GET',
|
263
|
+
'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
|
264
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
265
|
+
)
|
248
266
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_cr))).call(res)
|
249
267
|
expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
|
250
268
|
end
|
251
269
|
|
252
|
-
it
|
270
|
+
it 'docomo のUTF-8絵文字が変換されること' do
|
253
271
|
res = Rack::MockRequest.env_for(
|
254
|
-
|
255
|
-
|
256
|
-
'HTTP_USER_AGENT' =>
|
257
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
272
|
+
'/',
|
273
|
+
'REQUEST_METHOD' => 'GET',
|
274
|
+
'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
|
275
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
276
|
+
)
|
258
277
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_docomo_utf8))).call(res)
|
259
278
|
expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
|
260
279
|
end
|
261
280
|
|
262
|
-
it
|
281
|
+
it 'au のUTF-8絵文字が変換されること' do
|
263
282
|
res = Rack::MockRequest.env_for(
|
264
|
-
|
265
|
-
|
266
|
-
'HTTP_USER_AGENT' =>
|
267
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
283
|
+
'/',
|
284
|
+
'REQUEST_METHOD' => 'GET',
|
285
|
+
'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
|
286
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
287
|
+
)
|
268
288
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_au_utf8))).call(res)
|
269
289
|
expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
|
270
290
|
end
|
271
291
|
|
272
|
-
it
|
292
|
+
it 'softbank のUTF-8絵文字が変換されること' do
|
273
293
|
res = Rack::MockRequest.env_for(
|
274
|
-
|
275
|
-
|
276
|
-
'HTTP_USER_AGENT' =>
|
277
|
-
'Content-Type' => 'text/html; charset=utf-8'
|
294
|
+
'/',
|
295
|
+
'REQUEST_METHOD' => 'GET',
|
296
|
+
'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
|
297
|
+
'Content-Type' => 'text/html; charset=utf-8'
|
298
|
+
)
|
278
299
|
res = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@utf8 + @emoji_softbank_utf8))).call(res)
|
279
300
|
expect(response_body(res)).to eq(@utf8 + @softbank_emoji)
|
280
301
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
|
3
2
|
|
4
|
-
describe Jpmobile::MobileCarrier,
|
3
|
+
describe Jpmobile::MobileCarrier, 'iphone' do
|
5
4
|
include Rack::Test::Methods
|
6
5
|
|
7
|
-
context
|
8
|
-
it
|
6
|
+
context '端末種別で' do
|
7
|
+
it 'iPhone を判別できること' do
|
9
8
|
res = Rack::MockRequest.env_for(
|
10
9
|
'http://jpmobile-rails.org/',
|
11
|
-
'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
|
10
|
+
'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
|
11
|
+
)
|
12
12
|
env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
13
13
|
|
14
14
|
expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Iphone)
|
@@ -18,12 +18,13 @@ describe Jpmobile::MobileCarrier, "iphone" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
22
|
-
it
|
21
|
+
context 'IPアドレス制限で' do
|
22
|
+
it 'Softbank 網からのアクセスでも invalid になること' do
|
23
23
|
res = Rack::MockRequest.env_for(
|
24
24
|
'http://jpmobile-rails.org/',
|
25
25
|
'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16',
|
26
|
-
|
26
|
+
'REMOTE_ADDR' => '202.179.204.1'
|
27
|
+
)
|
27
28
|
env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
|
28
29
|
|
29
30
|
expect(env['rack.jpmobile'].valid_ip?).to be_falsey
|