jpmobile 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +227 -0
- data/Rakefile +6 -13
- data/lib/jpmobile/docomo_guid.rb +42 -0
- data/lib/jpmobile/filter.rb +1 -1
- data/lib/jpmobile/helpers.rb +2 -1
- data/lib/jpmobile/hook_action_controller.rb +12 -0
- data/lib/jpmobile/hook_action_view.rb +82 -72
- data/lib/jpmobile/{hook_abstract_request.rb → hook_request.rb} +1 -1
- data/lib/jpmobile/mobile/au.rb +9 -3
- data/lib/jpmobile/mobile/z_display_info_docomo.rb +10 -2
- data/lib/jpmobile/mobile/z_ip_addresses_au.rb +1 -26
- data/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +2 -4
- data/lib/jpmobile/rack/auth.rb +55 -0
- data/lib/jpmobile/rack/combined_logger.rb +54 -0
- data/lib/jpmobile/rack/request.rb +7 -0
- data/lib/jpmobile/rack/trans_sid.rb +14 -0
- data/lib/jpmobile/trans_sid.rb +70 -62
- data/lib/jpmobile/version.rb +1 -1
- data/test/{au_test.rb → legacy/au_test.rb} +0 -0
- data/test/{autoload_test.rb → legacy/autoload_test.rb} +0 -0
- data/test/{docomo_test.rb → legacy/docomo_test.rb} +0 -0
- data/test/{emoticon_functional_test.rb → legacy/emoticon_functional_test.rb} +1 -1
- data/test/{emoticon_test.rb → legacy/emoticon_test.rb} +0 -0
- data/test/{filter_test.rb → legacy/filter_test.rb} +0 -0
- data/test/{helper.rb → legacy/helper.rb} +4 -5
- data/test/{helpers_test.rb → legacy/helpers_test.rb} +1 -1
- data/test/{softbank_test.rb → legacy/softbank_test.rb} +0 -0
- data/test/{willcom_test.rb → legacy/willcom_test.rb} +0 -0
- data/test/rails/overrides/app/controllers/application.rb +5 -0
- data/test/rails/overrides/app/controllers/docomo_guid_controller.rb +13 -0
- data/test/rails/overrides/app/controllers/filter_controller.rb +26 -0
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +5 -0
- data/test/rails/overrides/app/controllers/template_path_controller.rb +6 -0
- data/test/rails/overrides/app/controllers/trans_sid_controller.rb +28 -0
- data/test/rails/overrides/app/views/filter/index.html.erb +0 -0
- data/test/rails/overrides/app/views/hankaku_filter/index.html.erb +0 -0
- data/test/rails/overrides/app/views/template_path/_partial.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_mobile_docomo.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_mobile_docomo.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/partial.html.erb +2 -0
- data/test/rails/overrides/lib/tasks/rspec.rake +165 -0
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +77 -0
- data/test/rails/overrides/spec/controllers/docomo_spec.rb +28 -0
- data/test/rails/overrides/spec/controllers/emobile_spec.rb +35 -0
- data/test/rails/overrides/spec/controllers/filter_spec.rb +157 -0
- data/test/rails/overrides/spec/controllers/pc_spec.rb +11 -0
- data/test/rails/overrides/spec/controllers/softbank_emulator_spec.rb +40 -0
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +115 -0
- data/test/rails/overrides/spec/controllers/trans_sid_spec.rb +98 -0
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +13 -0
- data/test/rails/overrides/spec/rcov.opts +2 -0
- data/test/rails/overrides/spec/rspec.rake +165 -0
- data/test/rails/overrides/spec/spec.opts +4 -0
- data/test/rails/overrides/spec/spec_helper.rb +47 -0
- data/test/rails/rails_root/README +256 -0
- data/test/rails/rails_root/Rakefile +10 -0
- data/test/rails/rails_root/app/controllers/application.rb +5 -0
- data/test/rails/rails_root/app/controllers/docomo_guid_controller.rb +13 -0
- data/test/rails/rails_root/app/controllers/filter_controller.rb +26 -0
- data/test/rails/rails_root/app/controllers/mobile_spec_controller.rb +5 -0
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +6 -0
- data/test/rails/rails_root/app/controllers/trans_sid_controller.rb +26 -0
- data/test/rails/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails/rails_root/app/views/template_path/index.html.erb +1 -0
- data/test/rails/rails_root/app/views/template_path/index_mobile.html.erb +1 -0
- data/test/rails/rails_root/app/views/template_path/index_mobile_docomo.html.erb +1 -0
- data/test/rails/rails_root/config/boot.rb +109 -0
- data/test/rails/rails_root/config/database.yml +22 -0
- data/test/rails/rails_root/config/environment.rb +75 -0
- data/test/rails/rails_root/config/environments/development.rb +17 -0
- data/test/rails/rails_root/config/environments/production.rb +24 -0
- data/test/rails/rails_root/config/environments/test.rb +22 -0
- data/test/rails/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails/rails_root/config/initializers/new_rails_defaults.rb +17 -0
- data/test/rails/rails_root/config/locales/en.yml +5 -0
- data/test/rails/rails_root/config/routes.rb +43 -0
- data/test/rails/rails_root/db/development.sqlite3 +0 -0
- data/test/rails/rails_root/db/schema.rb +14 -0
- data/test/rails/rails_root/db/test.sqlite3 +0 -0
- data/test/rails/rails_root/doc/README_FOR_APP +5 -0
- data/test/rails/rails_root/lib/tasks/rspec.rake +165 -0
- data/test/rails/rails_root/log/development.log +38 -0
- data/test/rails/rails_root/log/production.log +0 -0
- data/test/rails/rails_root/log/server.log +0 -0
- data/test/rails/rails_root/log/test.log +401 -0
- data/test/rails/rails_root/public/404.html +30 -0
- data/test/rails/rails_root/public/422.html +30 -0
- data/test/rails/rails_root/public/500.html +33 -0
- data/test/rails/rails_root/public/dispatch.cgi +10 -0
- data/test/rails/rails_root/public/dispatch.fcgi +24 -0
- data/test/rails/rails_root/public/dispatch.rb +10 -0
- data/test/rails/rails_root/public/favicon.ico +0 -0
- data/test/rails/rails_root/public/images/rails.png +0 -0
- data/test/rails/rails_root/public/index.html +274 -0
- data/test/rails/rails_root/public/javascripts/application.js +2 -0
- data/test/rails/rails_root/public/javascripts/controls.js +963 -0
- data/test/rails/rails_root/public/javascripts/dragdrop.js +973 -0
- data/test/rails/rails_root/public/javascripts/effects.js +1128 -0
- data/test/rails/rails_root/public/javascripts/prototype.js +4320 -0
- data/test/rails/rails_root/public/robots.txt +5 -0
- data/test/rails/rails_root/script/about +4 -0
- data/test/rails/rails_root/script/console +3 -0
- data/test/rails/rails_root/script/dbconsole +3 -0
- data/test/rails/rails_root/script/destroy +3 -0
- data/test/rails/rails_root/script/generate +3 -0
- data/test/rails/rails_root/script/performance/benchmarker +3 -0
- data/test/rails/rails_root/script/performance/profiler +3 -0
- data/test/rails/rails_root/script/performance/request +3 -0
- data/test/rails/rails_root/script/plugin +3 -0
- data/test/rails/rails_root/script/process/inspector +3 -0
- data/test/rails/rails_root/script/process/reaper +3 -0
- data/test/rails/rails_root/script/process/spawner +3 -0
- data/test/rails/rails_root/script/runner +3 -0
- data/test/rails/rails_root/script/server +3 -0
- data/test/rails/rails_root/spec/controllers/docomo_guid_spec.rb +77 -0
- data/test/rails/rails_root/spec/controllers/docomo_spec.rb +28 -0
- data/test/rails/rails_root/spec/controllers/emobile_spec.rb +35 -0
- data/test/rails/rails_root/spec/controllers/filter_spec.rb +157 -0
- data/test/rails/rails_root/spec/controllers/pc_spec.rb +11 -0
- data/test/rails/rails_root/spec/controllers/softbank_emulator_spec.rb +40 -0
- data/test/rails/rails_root/spec/controllers/template_path_spec.rb +85 -0
- data/test/rails/rails_root/spec/controllers/trans_sid_spec.rb +96 -0
- data/test/rails/rails_root/spec/helpers/helpers_spec.rb +13 -0
- data/test/rails/rails_root/spec/rcov.opts +2 -0
- data/test/rails/rails_root/spec/rspec.rake +165 -0
- data/test/rails/rails_root/spec/spec.opts +4 -0
- data/test/rails/rails_root/spec/spec_helper.rb +47 -0
- data/test/rails/rails_root/test/performance/browsing_test.rb +9 -0
- data/test/rails/rails_root/test/test_helper.rb +38 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/CHANGELOG +7 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/MIT-LICENSE +7 -0
- data/{README → test/rails/rails_root/vendor/plugins/jpmobile/README.rdoc} +15 -17
- data/test/rails/rails_root/vendor/plugins/jpmobile/Rakefile +116 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/init.rb +3 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/install.rb +1 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +42 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/datum_conv.rb +72 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb +42 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/email.rb +19 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +123 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/au.rb +1287 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/conversion_table.rb +3908 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/docomo.rb +255 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/softbank.rb +477 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/z_combine.rb +20 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/filter.rb +173 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/helpers.rb +185 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +11 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +142 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_request.rb +13 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +73 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +97 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/display.rb +33 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +97 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/emobile.rb +17 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +110 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/willcom.rb +39 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_display_info_docomo.rb +688 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_au.rb +22 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_docomo.rb +12 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_emobile.rb +10 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_softbank.rb +17 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +117 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/position.rb +67 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/request_with_mobile.rb +44 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/trans_sid.rb +105 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +21 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/version.rb +9 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/spec.opts +6 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/spec_helper.rb +36 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/detect_by_email_spec.rb +31 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/detect_by_ua_spec.rb +42 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/is_carrier_spec.rb +93 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/spec_helper.rb +5 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/util_spec.rb +28 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/valid_ip_spec.rb +60 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tasks/jpmobile_tasks.rake +59 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/emoji/genregexp.rb +47 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_au_emoticon_table.rb +34 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_docomo_emoticon_table.rb +34 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_emoticon_conversion_table.rb +107 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_softbank_emoticon_table.rb +32 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/list_gps_unsupported_au.rb +23 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/update_display_info_docomo.rb +45 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/update_ip_addresses_au.rb +29 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/update_ip_addresses_willcom.rb +17 -0
- data/tools/update_ip_addresses_au.rb +15 -5
- metadata +188 -22
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "DoCoMo SH902i からのアクセス" do
|
4
|
+
before do
|
5
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
6
|
+
end
|
7
|
+
controller_name :mobile_spec
|
8
|
+
it "request.mobile は Docomo のインスタンスであるべき" do
|
9
|
+
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Docomo)
|
10
|
+
end
|
11
|
+
it "request.mobile? は true であるべき" do
|
12
|
+
request.mobile?.should be_true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "DoCoMo SH902i からguid付きのアクセス" do
|
17
|
+
controller_name :mobile_spec
|
18
|
+
before do
|
19
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
20
|
+
request.env['HTTP_X_DCMGUID'] = "000000a"
|
21
|
+
end
|
22
|
+
it "guidを正しく取得できること" do
|
23
|
+
request.mobile.guid.should == "000000a"
|
24
|
+
end
|
25
|
+
it "ident_subscriberでも正しく取得できること" do
|
26
|
+
request.mobile.ident_subscriber.should == "000000a"
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "H11T モバイルブラウザからのアクセス", :behaviour_type=>:controller do
|
4
|
+
before do
|
5
|
+
request.user_agent = "emobile/1.0.0 (H11T; like Gecko; Wireless) NetFront/3.4"
|
6
|
+
request.env['HTTP_X_EM_UID'] = "u00000000000000000"
|
7
|
+
request.env['REMOTE_ADDR'] = "117.55.1.232"
|
8
|
+
end
|
9
|
+
controller_name :mobile_spec
|
10
|
+
it "request.mobile は Emobile のインスタンスであること" do
|
11
|
+
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Emobile)
|
12
|
+
end
|
13
|
+
it "request.mobile? は true であること" do
|
14
|
+
request.mobile?.should be_true
|
15
|
+
end
|
16
|
+
it "のsubscribe番号を取得できること" do
|
17
|
+
request.mobile.ident_subscriber.should == "u00000000000000000"
|
18
|
+
end
|
19
|
+
it "のIPアドレス空間を正しく検証できること" do
|
20
|
+
request.mobile.valid_ip?.should be_true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "S11HT からのアクセス", :behaviour_type=>:controller do
|
25
|
+
before do
|
26
|
+
request.user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.7) S11HT"
|
27
|
+
end
|
28
|
+
controller_name :mobile_spec
|
29
|
+
it "request.mobile は Emobile のインスタンスであること" do
|
30
|
+
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Emobile)
|
31
|
+
end
|
32
|
+
it "request.mobile? は true であること" do
|
33
|
+
request.mobile?.should be_true
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "文字コードフィルタが動作しているとき", :shared => true do
|
4
|
+
it "はhtml以外は変換しないこと" do
|
5
|
+
get :rawdata
|
6
|
+
response.charset.should be_nil
|
7
|
+
response.body.should == "アブラカダブラ"
|
8
|
+
end
|
9
|
+
it "response.bodyが空のときは文字コードを変更しないこと" do
|
10
|
+
get :empty
|
11
|
+
response.charset.should_not == "Shift_JIS"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "Shift_JISで通信する端末との通信", :shared => true do
|
16
|
+
it "はShift_JISで携帯に送出されること" do
|
17
|
+
get :abracadabra_utf8
|
18
|
+
response.body.should == "アブラカダブラ".tosjis
|
19
|
+
response.charset.should == "Shift_JIS"
|
20
|
+
end
|
21
|
+
it "はxhtmlでもShift_JISで携帯に送出されること" do
|
22
|
+
get :abracadabra_xhtml_utf8
|
23
|
+
response.body.should == "アブラカダブラ".tosjis
|
24
|
+
response.charset.should == "Shift_JIS"
|
25
|
+
end
|
26
|
+
it "はShift_JISで渡されたパラメタがparamsにUTF-8に変換されて格納されること" do
|
27
|
+
get :index, :q => "アブラカダブラ".tosjis
|
28
|
+
assigns[:q].should == "アブラカダブラ"
|
29
|
+
end
|
30
|
+
it "は半角カナのparamsを変換しないこと" do
|
31
|
+
get :index, :q => "\261\314\336\327\266\300\336\314\336\327" # アブラカダブラ半角,SJIS
|
32
|
+
assigns[:q].should == "アブラカダブラ"
|
33
|
+
end
|
34
|
+
it_should_behave_like "文字コードフィルタが動作しているとき"
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "UTF-8で通信する端末との通信", :shared => true do
|
38
|
+
it "はUTF-8で携帯に送出されること" do
|
39
|
+
get :abracadabra_utf8
|
40
|
+
response.body.should == "アブラカダブラ"
|
41
|
+
response.charset.should == "utf-8"
|
42
|
+
end
|
43
|
+
it "はxhtmlでもUTF-8で携帯に送出されること" do
|
44
|
+
get :abracadabra_xhtml_utf8
|
45
|
+
response.body.should == "アブラカダブラ"
|
46
|
+
response.charset.should == "utf-8"
|
47
|
+
end
|
48
|
+
it "はparamsにUTF-8のまま格納されること" do
|
49
|
+
get :index, :q => "アブラカダブラ"
|
50
|
+
assigns[:q].should == "アブラカダブラ"
|
51
|
+
end
|
52
|
+
it "は半角カナのparamsを変換しないこと" do
|
53
|
+
get :index, :q => "アブラカダブラ"
|
54
|
+
assigns[:q].should == "アブラカダブラ"
|
55
|
+
end
|
56
|
+
it_should_behave_like "文字コードフィルタが動作しているとき"
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "Shift_JISで通信する端末との通信(半角変換付き)", :shared => true do
|
60
|
+
it "は半角に変換されShift_JISで携帯に送出されること" do
|
61
|
+
get :abracadabra_utf8
|
62
|
+
response.body.should == "\261\314\336\327\266\300\336\314\336\327" # アブラカダブラ半角,SJIS
|
63
|
+
response.charset.should == "Shift_JIS"
|
64
|
+
end
|
65
|
+
it "はShift_JISで渡されたパラメタがparamsにUTF-8に変換されて格納されること" do
|
66
|
+
get :index, :q => "アブラカダブラ".tosjis
|
67
|
+
assigns[:q].should == "アブラカダブラ"
|
68
|
+
end
|
69
|
+
it "は半角Shift_JISで渡されたパラメタがparamsに全角UTF-8に変換されて格納されること" do
|
70
|
+
get :index, :q => "\261\314\336\327\266\300\336\314\336\327" # アブラカダブラ半角,SJIS
|
71
|
+
assigns[:q].should == "アブラカダブラ"
|
72
|
+
end
|
73
|
+
it_should_behave_like "文字コードフィルタが動作しているとき"
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "UTF-8で通信する端末との通信(半角変換付き)", :shared => true do
|
77
|
+
it "はUTF-8半角で携帯に送出されること" do
|
78
|
+
get :abracadabra_utf8
|
79
|
+
response.body.should == "アブラカダブラ"
|
80
|
+
response.charset.should == "utf-8"
|
81
|
+
end
|
82
|
+
it "はparamsにUTF-8のまま格納されること" do
|
83
|
+
get :index, :q => "アブラカダブラ"
|
84
|
+
assigns[:q].should == "アブラカダブラ"
|
85
|
+
end
|
86
|
+
it "は半角で渡されたparamsを全角に変換して格納すること" do
|
87
|
+
get :index, :q => "アブラカダブラ"
|
88
|
+
assigns[:q].should == "アブラカダブラ"
|
89
|
+
end
|
90
|
+
it_should_behave_like "文字コードフィルタが動作しているとき"
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# PCからのアクセス
|
95
|
+
#
|
96
|
+
describe FilterController, "PCからのアクセス" do
|
97
|
+
it_should_behave_like "UTF-8で通信する端末との通信"
|
98
|
+
end
|
99
|
+
|
100
|
+
describe HankakuFilterController, "PCからのアクセス" do
|
101
|
+
it_should_behave_like "UTF-8で通信する端末との通信"
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# 携帯からのアクセス
|
106
|
+
#
|
107
|
+
describe FilterController, "DoCoMo SH902i からのアクセス" do
|
108
|
+
before do
|
109
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
110
|
+
end
|
111
|
+
it_should_behave_like "Shift_JISで通信する端末との通信"
|
112
|
+
end
|
113
|
+
|
114
|
+
describe FilterController, "au CA32 からのアクセス" do
|
115
|
+
before do
|
116
|
+
request.user_agent = "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
|
117
|
+
end
|
118
|
+
it_should_behave_like "Shift_JISで通信する端末との通信"
|
119
|
+
end
|
120
|
+
|
121
|
+
describe FilterController, "J-PHONE V401SH からのアクセス" do
|
122
|
+
before do
|
123
|
+
request.user_agent = "J-PHONE/3.0/V401SH"
|
124
|
+
end
|
125
|
+
it_should_behave_like "Shift_JISで通信する端末との通信"
|
126
|
+
end
|
127
|
+
|
128
|
+
describe FilterController, "Vodafone V903T からのアクセス" do
|
129
|
+
before do
|
130
|
+
request.user_agent = "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0"
|
131
|
+
end
|
132
|
+
it_should_behave_like "UTF-8で通信する端末との通信"
|
133
|
+
end
|
134
|
+
|
135
|
+
describe FilterController, "SoftBank 910T からのアクセス" do
|
136
|
+
before do
|
137
|
+
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
138
|
+
end
|
139
|
+
it_should_behave_like "UTF-8で通信する端末との通信"
|
140
|
+
end
|
141
|
+
|
142
|
+
#
|
143
|
+
# 半角フィルタ
|
144
|
+
#
|
145
|
+
describe HankakuFilterController, "DoCoMo SH902i からのアクセス" do
|
146
|
+
before do
|
147
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
148
|
+
end
|
149
|
+
it_should_behave_like "Shift_JISで通信する端末との通信(半角変換付き)"
|
150
|
+
end
|
151
|
+
|
152
|
+
describe HankakuFilterController, "SoftBank 910T からのアクセス" do
|
153
|
+
before do
|
154
|
+
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
155
|
+
end
|
156
|
+
it_should_behave_like "UTF-8で通信する端末との通信(半角変換付き)"
|
157
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "PCからのアクセスの場合", :behaviour_type=>:controller do
|
4
|
+
controller_name :mobile_spec
|
5
|
+
it "request.mobile は nil であるべき" do
|
6
|
+
request.mobile.should be_nil
|
7
|
+
end
|
8
|
+
it "request.mobile? は false であるべき" do
|
9
|
+
request.mobile?.should be_false
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "携帯電話からのアクセス", :shared => true do
|
4
|
+
it "request.mobile? は true であること" do
|
5
|
+
request.mobile?.should be_true
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Softbank Emulator からのアクセスのとき", :behaviour_type=>:controller do
|
10
|
+
before do
|
11
|
+
request.user_agent = "Semulator"
|
12
|
+
end
|
13
|
+
controller_name :mobile_spec
|
14
|
+
it "request.mobile は Softbank のインスタンスであること" do
|
15
|
+
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Softbank)
|
16
|
+
end
|
17
|
+
it_should_behave_like "携帯電話からのアクセス"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "Vodafone Emulator からのアクセスのとき", :behaviour_type=>:controller do
|
21
|
+
before do
|
22
|
+
request.user_agent = "Vemulator"
|
23
|
+
end
|
24
|
+
controller_name :mobile_spec
|
25
|
+
it "request.mobile は Vodafone のインスタンスであること" do
|
26
|
+
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Vodafone)
|
27
|
+
end
|
28
|
+
it_should_behave_like "携帯電話からのアクセス"
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "J-PHONE Emulator からのアクセスのとき", :behaviour_type=>:controller do
|
32
|
+
before do
|
33
|
+
request.user_agent = "J-EMULATOR"
|
34
|
+
end
|
35
|
+
controller_name :mobile_spec
|
36
|
+
it "request.mobile は Jphone のインスタンスであること" do
|
37
|
+
request.mobile.should be_an_instance_of(Jpmobile::Mobile::Jphone)
|
38
|
+
end
|
39
|
+
it_should_behave_like "携帯電話からのアクセス"
|
40
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
#
|
4
|
+
# 携帯からのアクセス
|
5
|
+
#
|
6
|
+
describe TemplatePathController, "DoCoMo SH902i からのアクセス" do
|
7
|
+
before do
|
8
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
9
|
+
get :index
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'テンプレートの探索順が正しいこと' do
|
13
|
+
response.template.mobile_template_candidates.should == [ 'mobile_docomo', 'mobile' ]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe TemplatePathController, "au CA32 からのアクセス" do
|
18
|
+
before do
|
19
|
+
request.user_agent = "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
|
20
|
+
get :index
|
21
|
+
end
|
22
|
+
it 'テンプレートの探索順が正しいこと' do
|
23
|
+
response.template.mobile_template_candidates.should == [ 'mobile_au', 'mobile' ]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe TemplatePathController, "J-PHONE V401SH からのアクセス" do
|
28
|
+
before do
|
29
|
+
request.user_agent = "J-PHONE/3.0/V401SH"
|
30
|
+
get :index
|
31
|
+
end
|
32
|
+
it 'テンプレートの探索順が正しいこと' do
|
33
|
+
response.template.mobile_template_candidates.should == [ 'mobile_jphone', 'mobile_vodafone', 'mobile_softbank', 'mobile' ]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe TemplatePathController, "Vodafone V903T からのアクセス" do
|
38
|
+
before do
|
39
|
+
request.user_agent = "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0"
|
40
|
+
get :index
|
41
|
+
end
|
42
|
+
it 'テンプレートの探索順が正しいこと' do
|
43
|
+
response.template.mobile_template_candidates.should == [ 'mobile_vodafone', 'mobile_softbank', 'mobile' ]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe TemplatePathController, "SoftBank 910T からのアクセス" do
|
48
|
+
before do
|
49
|
+
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
50
|
+
get :index
|
51
|
+
end
|
52
|
+
it 'テンプレートの探索順が正しいこと' do
|
53
|
+
response.template.mobile_template_candidates.should == [ 'mobile_softbank', 'mobile' ]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe TemplatePathController, "integrated_views" do
|
58
|
+
integrate_views
|
59
|
+
describe "index" do
|
60
|
+
context "PCからのアクセスの場合" do
|
61
|
+
before do
|
62
|
+
get :index
|
63
|
+
end
|
64
|
+
it 'index.html.erbが使用されること' do
|
65
|
+
response.should have_tag("h1", "index.html.erb")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
context "DoCoMoからのアクセスの場合" do
|
69
|
+
before do
|
70
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
71
|
+
get :index
|
72
|
+
end
|
73
|
+
it 'index_mobile_docomo.html.erbが使用されること' do
|
74
|
+
response.should have_tag("h1", "index_mobile_docomo.html.erb")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
context "SoftBankからのアクセスの場合" do
|
78
|
+
before do
|
79
|
+
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
80
|
+
get :index
|
81
|
+
end
|
82
|
+
it 'index_mobile.html.erbが使用されること' do
|
83
|
+
response.should have_tag("h1", "index_mobile.html.erb")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
describe "partial" do
|
88
|
+
context "PCからのアクセスの場合" do
|
89
|
+
before do
|
90
|
+
get :partial
|
91
|
+
end
|
92
|
+
it '_partial.html.erbが使用されること' do
|
93
|
+
response.should have_tag("h2", "_partial.html.erb")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
context "DoCoMoからのアクセスの場合" do
|
97
|
+
before do
|
98
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
99
|
+
get :partial
|
100
|
+
end
|
101
|
+
it '_partial_mobile_docomo.html.erbが使用されること' do
|
102
|
+
response.should have_tag("h2", "_partial_mobile_docomo.html.erb")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
context "SoftBankからのアクセスの場合" do
|
106
|
+
before do
|
107
|
+
request.user_agent = "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
|
108
|
+
get :partial
|
109
|
+
end
|
110
|
+
it '_partial_mobile.html.erbが使用されること' do
|
111
|
+
response.should have_tag("h2", "_partial_mobile.html.erb")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "trans_sid が起動しないとき", :shared => true do
|
4
|
+
it "で link_to の自動書き換えが行われない" do
|
5
|
+
get :link
|
6
|
+
response.body.should =~ %r{^<a href="/.+?/link">linkto</a>$}
|
7
|
+
end
|
8
|
+
it "で form の自動書き換えが行われない" do
|
9
|
+
get :form
|
10
|
+
response.body.should =~ %r{^<form action="/.+?/form" method="post">Hello</form>$}
|
11
|
+
end
|
12
|
+
it "で redirect の自動書き換えが行われない" do
|
13
|
+
get :redirect
|
14
|
+
response.should redirect_to('/')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "trans_sid が起動するとき", :shared => true do
|
19
|
+
before :each do
|
20
|
+
request.session.session_id = "mysessionid"
|
21
|
+
end
|
22
|
+
it "で link_to の自動書き換えが行われる" do
|
23
|
+
get :link
|
24
|
+
response.body.should =~ %r{^<a href="/.+?/link\?_session_id=mysessionid">linkto</a>$}
|
25
|
+
end
|
26
|
+
it "で form の自動書き換えが行われる" do
|
27
|
+
get :form
|
28
|
+
response.body.should =~ %r{^<form action="/.+?/form\?_session_id=mysessionid" method="post">Hello<input type="hidden" name="_session_id" value="mysessionid" /></form>$}
|
29
|
+
end
|
30
|
+
it "で redirect の自動書き換えが行われる" do
|
31
|
+
get :redirect
|
32
|
+
response.should redirect_to('/?_session_id=mysessionid')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe TransSidBaseController, "という trans_sid が有効になっていないコントローラ" do
|
37
|
+
controller_name :trans_sid_base
|
38
|
+
it "の trans_sid_mode は nil" do
|
39
|
+
controller.trans_sid_mode.should be_nil
|
40
|
+
end
|
41
|
+
it_should_behave_like "trans_sid が起動しないとき"
|
42
|
+
end
|
43
|
+
|
44
|
+
describe TransSidNoneController, "という trans_sid :none が指定されているコントローラ" do
|
45
|
+
controller_name :trans_sid_none
|
46
|
+
it "の trans_sid_mode は :none" do
|
47
|
+
controller.trans_sid_mode.should == :none
|
48
|
+
end
|
49
|
+
it_should_behave_like "trans_sid が起動しないとき"
|
50
|
+
end
|
51
|
+
|
52
|
+
describe TransSidAlwaysController, "という trans_sid :always が指定されているコントローラ" do
|
53
|
+
controller_name :trans_sid_always
|
54
|
+
before :each do
|
55
|
+
request.session.session_id = "mysessionid"
|
56
|
+
end
|
57
|
+
it "の trans_sid_mode は :always" do
|
58
|
+
controller.trans_sid_mode.should == :always
|
59
|
+
end
|
60
|
+
it_should_behave_like "trans_sid が起動するとき"
|
61
|
+
end
|
62
|
+
|
63
|
+
describe TransSidMobileController, "という trans_sid :mobile が指定されているコントローラ" do
|
64
|
+
controller_name :trans_sid_mobile
|
65
|
+
it "の trans_sid_mode は :mobile" do
|
66
|
+
controller.trans_sid_mode.should == :mobile
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def describe_mobile_with_ua(user_agent, &block)
|
71
|
+
describe("trans_sid :mobile が指定されているコントローラに #{user_agent} からアクセスしたとき") do
|
72
|
+
controller_name :trans_sid_mobile
|
73
|
+
before do
|
74
|
+
request.user_agent = user_agent
|
75
|
+
end
|
76
|
+
instance_eval(&block)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe_mobile_with_ua "DoCoMo/2.0 SH902i(c100;TB;W24H12)" do
|
81
|
+
it_should_behave_like "trans_sid が起動するとき"
|
82
|
+
end
|
83
|
+
|
84
|
+
describe_mobile_with_ua "J-PHONE/3.0/V301D" do
|
85
|
+
it_should_behave_like "trans_sid が起動するとき"
|
86
|
+
end
|
87
|
+
|
88
|
+
describe_mobile_with_ua "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0" do
|
89
|
+
it_should_behave_like "trans_sid が起動しないとき"
|
90
|
+
end
|
91
|
+
|
92
|
+
describe_mobile_with_ua "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1" do
|
93
|
+
it_should_behave_like "trans_sid が起動しないとき"
|
94
|
+
end
|
95
|
+
|
96
|
+
describe_mobile_with_ua "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0" do
|
97
|
+
it_should_behave_like "trans_sid が起動しないとき"
|
98
|
+
end
|