jpmobile 6.0.0 → 7.0.0
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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +8 -3
- data/.onkcop-config.yml +4 -31
- data/.rubocop.yml +67 -3
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +152 -158
- data/README.md +5 -20
- data/jpmobile.gemspec +6 -3
- data/lib/jpmobile/configuration.rb +7 -3
- data/lib/jpmobile/docomo_guid.rb +4 -4
- data/lib/jpmobile/email.rb +2 -4
- data/lib/jpmobile/emoticon.rb +10 -17
- data/lib/jpmobile/filter.rb +2 -2
- data/lib/jpmobile/hook_action_view.rb +3 -3
- data/lib/jpmobile/hook_template_details_requested.rb +12 -0
- data/lib/jpmobile/hook_test_request.rb +1 -1
- data/lib/jpmobile/mail.rb +4 -4
- data/lib/jpmobile/mailer.rb +2 -2
- data/lib/jpmobile/mobile/abstract_mobile.rb +1 -1
- data/lib/jpmobile/mobile/android.rb +1 -1
- data/lib/jpmobile/mobile/android_tablet.rb +1 -1
- data/lib/jpmobile/mobile/au.rb +2 -2
- data/lib/jpmobile/mobile/black_berry.rb +1 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -1
- data/lib/jpmobile/mobile/docomo.rb +6 -8
- data/lib/jpmobile/mobile/emobile.rb +2 -2
- data/lib/jpmobile/mobile/ipad.rb +1 -1
- data/lib/jpmobile/mobile/iphone.rb +1 -1
- data/lib/jpmobile/mobile/softbank.rb +2 -2
- data/lib/jpmobile/mobile/vodafone.rb +2 -2
- data/lib/jpmobile/mobile/willcom.rb +2 -2
- data/lib/jpmobile/mobile/windows_phone.rb +1 -1
- data/lib/jpmobile/path_set.rb +10 -36
- data/lib/jpmobile/rack/params_filter.rb +5 -4
- data/lib/jpmobile/rails.rb +9 -41
- data/lib/jpmobile/resolver.rb +44 -6
- data/lib/jpmobile/session/active_record_store.rb +1 -1
- data/lib/jpmobile/session/mem_cache_store.rb +1 -1
- data/lib/jpmobile/template_details.rb +38 -0
- data/lib/jpmobile/trans_sid.rb +2 -2
- data/lib/jpmobile/util.rb +3 -4
- data/lib/jpmobile/version.rb +1 -1
- data/lib/jpmobile/view_selector.rb +25 -0
- data/lib/jpmobile.rb +14 -0
- data/lib/tasks/jpmobile_tasks.rake +4 -3
- data/spec/rack/jpmobile/emoticon_spec.rb +48 -48
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +1 -0
- data/spec/rack_helper.rb +1 -5
- data/spec/unit/email_spec.rb +1 -1
- data/spec/unit/receive_mail_spec.rb +1 -1
- data/test/rails/overrides/Gemfile.jpmobile +5 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +3 -0
- data/test/rails/overrides/app/views/mobile_spec/mobile_not_exist.html.erb +3 -0
- data/test/rails/overrides/config/routes.rb +1 -1
- data/test/rails/overrides/db/migrate/{20190419005447_create_active_storage_tables.active_storage.rb → 20201111033056_create_active_storage_tables.active_storage.rb} +14 -5
- data/test/rails/overrides/db/migrate/{20190419005448_create_action_mailbox_tables.action_mailbox.rb → 20201111033057_create_action_mailbox_tables.action_mailbox.rb} +0 -0
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +2 -2
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +3 -3
- data/test/rails/overrides/spec/rails_helper.rb +1 -1
- data/test/rails/overrides/spec/requests/filter_spec.rb +106 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +1 -1
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +9 -9
- data/test/rails/overrides/spec/{features → system}/admin/top_spec.rb +2 -2
- data/test/rails/overrides/spec/{features → system}/filter_spec.rb +2 -7
- data/test/rails/overrides/spec/system/support/cuprite_setup.rb +14 -0
- data/test/rails/overrides/spec/system_helper.rb +3 -0
- metadata +44 -21
- data/test/rails/overrides/app/views/mobile_spec/no_mobile.html.erb +0 -3
@@ -0,0 +1,38 @@
|
|
1
|
+
module Jpmobile
|
2
|
+
class TemplateDetails < ActionView::TemplateDetails
|
3
|
+
def initialize(locale, handler, format, variant, mobile)
|
4
|
+
@mobile = mobile
|
5
|
+
|
6
|
+
super(locale, handler, format, variant)
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(requested)
|
10
|
+
requested.formats_idx[@format] &&
|
11
|
+
requested.locale_idx[@locale] &&
|
12
|
+
requested.variants_idx[@variant] &&
|
13
|
+
requested.handlers_idx[@handler] &&
|
14
|
+
requested.mobile_idx[@mobile]
|
15
|
+
end
|
16
|
+
|
17
|
+
def sort_key_for(requested)
|
18
|
+
[
|
19
|
+
requested.formats_idx[@format],
|
20
|
+
requested.locale_idx[@locale],
|
21
|
+
requested.variants_idx[@variant],
|
22
|
+
requested.handlers_idx[@handler],
|
23
|
+
requested.mobile_idx[@mobile],
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
class Requested < ActionView::TemplateDetails::Requested
|
28
|
+
attr_reader :mobile, :mobile_idx
|
29
|
+
|
30
|
+
def initialize(locale:, handlers:, formats:, variants:, mobile:)
|
31
|
+
super(locale: locale, handlers: handlers, formats: formats, variants: variants)
|
32
|
+
|
33
|
+
@mobile = mobile.map(&:to_sym)
|
34
|
+
@mobile_idx = build_idx_hash(mobile)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/jpmobile/trans_sid.rb
CHANGED
@@ -51,7 +51,7 @@ module Jpmobile
|
|
51
51
|
|
52
52
|
# session_idを埋め込むためのhidden fieldを出力する。
|
53
53
|
def sid_hidden_field_tag
|
54
|
-
"<input type=\"hidden\" name=\"#{CGI.escapeHTML
|
54
|
+
"<input type=\"hidden\" name=\"#{CGI.escapeHTML(session_key.to_s)}\" value=\"#{CGI.escapeHTML(jpmobile_session_id.to_s)}\" />"
|
55
55
|
end
|
56
56
|
|
57
57
|
# formにsession_idを追加する。
|
@@ -91,7 +91,7 @@ module Jpmobile
|
|
91
91
|
end
|
92
92
|
|
93
93
|
module ActionController
|
94
|
-
class Metal
|
94
|
+
class Metal # :nodoc:
|
95
95
|
class_attribute :trans_sid_mode
|
96
96
|
|
97
97
|
class << self
|
data/lib/jpmobile/util.rb
CHANGED
@@ -255,9 +255,8 @@ module Jpmobile
|
|
255
255
|
SJIS
|
256
256
|
when ::Encoding::UTF_8
|
257
257
|
UTF8
|
258
|
-
when ::Encoding::ASCII_8BIT
|
259
|
-
BINARY
|
260
258
|
else
|
259
|
+
# 上記以外はすべて BINARY 扱い
|
261
260
|
BINARY
|
262
261
|
end
|
263
262
|
end
|
@@ -292,12 +291,12 @@ module Jpmobile
|
|
292
291
|
def split_text(str, size = 15)
|
293
292
|
return nil if str.nil? || (str == '')
|
294
293
|
|
295
|
-
[str[0..(size - 1)], str[size
|
294
|
+
[str[0..(size - 1)], str[size..]]
|
296
295
|
end
|
297
296
|
|
298
297
|
def invert_table(hash)
|
299
298
|
result = {}
|
300
|
-
hash.
|
299
|
+
hash.each_key do |key|
|
301
300
|
if result[hash[key]]
|
302
301
|
if !key.is_a?(Array) && !result[hash[key]].is_a?(Array) && result[hash[key]] > key
|
303
302
|
result[hash[key]] = key
|
data/lib/jpmobile/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Jpmobile
|
2
|
+
module ViewSelector
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
before_action :register_mobile
|
7
|
+
|
8
|
+
self.view_paths = Jpmobile::PathSet.new(self.view_paths.paths.map(&:path))
|
9
|
+
end
|
10
|
+
|
11
|
+
def register_mobile
|
12
|
+
if request.mobile
|
13
|
+
# register mobile
|
14
|
+
self.lookup_context.mobile = request.mobile.variants
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def disable_mobile_view!
|
19
|
+
self.lookup_context.mobile = []
|
20
|
+
end
|
21
|
+
|
22
|
+
private :register_mobile, :disable_mobile_view!
|
23
|
+
end
|
24
|
+
Rails::Application::Configuration.include Jpmobile::Configuration::RailsConfiguration
|
25
|
+
end
|
data/lib/jpmobile.rb
CHANGED
@@ -48,9 +48,19 @@ module Jpmobile
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.carriers=(ary)
|
51
|
+
@all_variants = nil
|
52
|
+
|
51
53
|
@carriers = ary
|
52
54
|
end
|
53
55
|
|
56
|
+
def self.all_variants
|
57
|
+
return @all_variants if @all_variants
|
58
|
+
|
59
|
+
@all_variants = carriers.map {|carrier|
|
60
|
+
Jpmobile::Mobile.const_get(carrier).new({}, {}).variants
|
61
|
+
}.flatten.uniq
|
62
|
+
end
|
63
|
+
|
54
64
|
require 'jpmobile/mobile/abstract_mobile'
|
55
65
|
end
|
56
66
|
|
@@ -63,6 +73,10 @@ module Jpmobile
|
|
63
73
|
autoload :Mailer, 'jpmobile/mailer'
|
64
74
|
autoload :Resolver, 'jpmobile/resolver'
|
65
75
|
|
76
|
+
autoload :PathSet, 'jpmobile/path_set'
|
77
|
+
autoload :TemplateDetails, 'jpmobile/template_details'
|
78
|
+
|
79
|
+
autoload :ViewSelector, 'jpmobile/view_selector'
|
66
80
|
autoload :FallbackViewSelector, 'jpmobile/fallback_view_selector'
|
67
81
|
|
68
82
|
autoload :ParamsOverCookie, 'jpmobile/trans_sid'
|
@@ -33,7 +33,7 @@ namespace :test do
|
|
33
33
|
# generate rails app
|
34
34
|
FileUtils.rm_rf(rails_root)
|
35
35
|
FileUtils.mkdir_p(rails_root)
|
36
|
-
`rails new #{rails_root} --skip-bundle`
|
36
|
+
`rails new #{rails_root} --skip-bundle --skip-bootsnap --skip-webpack-install --skip-git --skip-spring`
|
37
37
|
end
|
38
38
|
|
39
39
|
# setup jpmobile
|
@@ -104,7 +104,7 @@ namespace :test do
|
|
104
104
|
|
105
105
|
# run tests in rails
|
106
106
|
Dir.chdir(rails_root) do
|
107
|
-
Bundler.
|
107
|
+
Bundler.with_unbundled_env do
|
108
108
|
original_env = ENV.to_hash
|
109
109
|
|
110
110
|
ENV.update('RBENV_VERSION' => nil)
|
@@ -112,12 +112,13 @@ namespace :test do
|
|
112
112
|
|
113
113
|
system 'bundle install'
|
114
114
|
system 'bin/rails db:migrate RAILS_ENV=test' unless skip
|
115
|
-
system 'bin/rails spec'
|
115
|
+
system 'bin/rails spec', exception: true
|
116
116
|
|
117
117
|
ENV.replace(original_env)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
121
|
+
|
121
122
|
desc 'Run sinatra on jpmobile tests'
|
122
123
|
Rake::TestTask.new(:sinatra) do |t|
|
123
124
|
t.libs << 'lib'
|
@@ -28,23 +28,23 @@ describe '絵文字が' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'docomo 絵文字が変換されないこと' do
|
31
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
31
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
32
32
|
expect(response_body(response)).to eq(@docomo_cr)
|
33
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
33
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
34
34
|
expect(response_body(response)).to eq(@docomo_utf8)
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'au 絵文字が変換されないこと' do
|
38
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
38
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
39
39
|
expect(response_body(response)).to eq(@au_cr)
|
40
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
40
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
41
41
|
expect(response_body(response)).to eq(@au_utf8)
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'softbank 絵文字が変換されないこと' do
|
45
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
45
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
46
46
|
expect(response_body(response)).to eq(@softbank_cr)
|
47
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
47
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
48
48
|
expect(response_body(response)).to eq(@softbank_utf8)
|
49
49
|
end
|
50
50
|
end
|
@@ -72,38 +72,38 @@ describe '絵文字が' do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'docomo 絵文字が画像に変換されること' do
|
75
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
75
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
76
76
|
expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'docomo 絵文字コードが画像に変換されること' do
|
80
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
80
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
81
81
|
expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'au 絵文字が画像に変換されること' do
|
85
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
85
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
86
86
|
expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'au 絵文字コードが画像に変換されること' do
|
90
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
90
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
91
91
|
expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'softbank 絵文字が画像に変換されること' do
|
95
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
95
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
96
96
|
expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'softbank 絵文字コードが画像に変換されること' do
|
100
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
100
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
101
101
|
expect(response_body(response)).to eq("<img src=\"#{@path}/sun.gif\" alt=\"sun\" />")
|
102
102
|
end
|
103
103
|
|
104
104
|
it 'Content-Type が変換できないものである場合には変換しないこと' do
|
105
105
|
@res = Rack::MockRequest.env_for('/', 'Content-Type' => 'image/jpeg')
|
106
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
106
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
107
107
|
expect(response_body(response)).to eq(@softbank_utf8)
|
108
108
|
end
|
109
109
|
end
|
@@ -118,26 +118,26 @@ describe '絵文字が' do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'docomo 絵文字が変換されること' do
|
121
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
121
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
122
122
|
expect(response_body(response)).to eq(sjis("\xf8\x9f"))
|
123
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
123
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
124
124
|
expect(response_body(response)).to eq(sjis("\xf8\x9f"))
|
125
125
|
|
126
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)
|
126
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)
|
127
127
|
expect(response_body(response)).to eq(sjis("\xf9\x79"))
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'au 絵文字が変換されること' do
|
131
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
131
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
132
132
|
expect(response_body(response)).to eq(sjis("\xf8\x9f"))
|
133
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
133
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
134
134
|
expect(response_body(response)).to eq(sjis("\xf8\x9f"))
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'softbank 絵文字が変換されること' do
|
138
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
138
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
139
139
|
expect(response_body(response)).to eq(sjis("\xf8\x9f"))
|
140
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
140
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
141
141
|
expect(response_body(response)).to eq(sjis("\xf8\x9f"))
|
142
142
|
end
|
143
143
|
|
@@ -167,26 +167,26 @@ describe '絵文字が' do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
it 'docomo 絵文字が変換されること' do
|
170
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
170
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
171
171
|
expect(response_body(response)).to eq(sjis("\xf6\x60"))
|
172
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
172
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
173
173
|
expect(response_body(response)).to eq(sjis("\xf6\x60"))
|
174
174
|
|
175
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)
|
175
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)
|
176
176
|
expect(response_body(response)).to eq(utf8_to_sjis('[ドコモポイント]'))
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'au 絵文字が変換されること' do
|
180
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
180
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
181
181
|
expect(response_body(response)).to eq(sjis("\xf6\x60"))
|
182
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
182
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
183
183
|
expect(response_body(response)).to eq(sjis("\xf6\x60"))
|
184
184
|
end
|
185
185
|
|
186
186
|
it 'softbank 絵文字が変換されること' do
|
187
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
187
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
188
188
|
expect(response_body(response)).to eq(sjis("\xf6\x60"))
|
189
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
189
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
190
190
|
expect(response_body(response)).to eq(sjis("\xf6\x60"))
|
191
191
|
end
|
192
192
|
|
@@ -216,26 +216,26 @@ describe '絵文字が' do
|
|
216
216
|
end
|
217
217
|
|
218
218
|
it 'docomo 絵文字が変換されること' do
|
219
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
219
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_cr))).call(@res)
|
220
220
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
221
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
221
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_utf8))).call(@res)
|
222
222
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
223
223
|
|
224
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)
|
224
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@docomo_docomopoint))).call(@res)
|
225
225
|
expect(response_body(response)).to eq('[ドコモポイント]')
|
226
226
|
end
|
227
227
|
|
228
228
|
it 'au 絵文字が変換されること' do
|
229
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
229
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_cr))).call(@res)
|
230
230
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
231
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
231
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@au_utf8))).call(@res)
|
232
232
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
233
233
|
end
|
234
234
|
|
235
235
|
it 'softbank 絵文字が変換されること' do
|
236
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
236
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
237
237
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
238
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
238
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
239
239
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
240
240
|
end
|
241
241
|
|
@@ -265,9 +265,9 @@ describe '絵文字が' do
|
|
265
265
|
end
|
266
266
|
|
267
267
|
it 'softbank 絵文字が変換されること' do
|
268
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
268
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
269
269
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
270
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
270
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
271
271
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
272
272
|
end
|
273
273
|
|
@@ -298,9 +298,9 @@ describe '絵文字が' do
|
|
298
298
|
end
|
299
299
|
|
300
300
|
it 'should convert Softbank emoticon' do
|
301
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
301
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_cr))).call(@res)
|
302
302
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
303
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
303
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@softbank_utf8))).call(@res)
|
304
304
|
expect(response_body(response)).to eq([0xe04a].pack('U'))
|
305
305
|
end
|
306
306
|
|
@@ -320,7 +320,7 @@ describe '絵文字が' do
|
|
320
320
|
end
|
321
321
|
|
322
322
|
it 'should not convert 〓' do
|
323
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
323
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
324
324
|
expect(response_body(response)).to eq('〓')
|
325
325
|
end
|
326
326
|
end
|
@@ -337,9 +337,9 @@ describe '絵文字が' do
|
|
337
337
|
end
|
338
338
|
|
339
339
|
it 'should convert Unicode emoticon' do
|
340
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@unicode_single))).call(@res)
|
340
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@unicode_single))).call(@res)
|
341
341
|
expect(response_body(response)).to eq([0x2600].pack('U*'))
|
342
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@unicode_multi))).call(@res)
|
342
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@unicode_multi))).call(@res)
|
343
343
|
expect(response_body(response)).to eq([0x26C5].pack('U*'))
|
344
344
|
end
|
345
345
|
|
@@ -359,7 +359,7 @@ describe '絵文字が' do
|
|
359
359
|
end
|
360
360
|
|
361
361
|
it 'should not convert 〓' do
|
362
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
362
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
363
363
|
expect(response_body(response)).to eq('〓')
|
364
364
|
end
|
365
365
|
end
|
@@ -381,9 +381,9 @@ describe '絵文字が' do
|
|
381
381
|
end
|
382
382
|
|
383
383
|
it 'should convert Google emoticon' do
|
384
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_single))).call(@res)
|
384
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_single))).call(@res)
|
385
385
|
expect(response_body(response)).to eq([0xFE000].pack('U*'))
|
386
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_multi))).call(@res)
|
386
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_multi))).call(@res)
|
387
387
|
expect(response_body(response)).to eq([0xFE00F].pack('U*'))
|
388
388
|
end
|
389
389
|
|
@@ -403,7 +403,7 @@ describe '絵文字が' do
|
|
403
403
|
end
|
404
404
|
|
405
405
|
it 'should not convert 〓' do
|
406
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
406
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
407
407
|
expect(response_body(response)).to eq('〓')
|
408
408
|
end
|
409
409
|
end
|
@@ -418,9 +418,9 @@ describe '絵文字が' do
|
|
418
418
|
end
|
419
419
|
|
420
420
|
it 'should convert Google emoticon' do
|
421
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_single))).call(@res)
|
421
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_single))).call(@res)
|
422
422
|
expect(response_body(response)).to eq([0xFE000].pack('U*'))
|
423
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_multi))).call(@res)
|
423
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new(@google_multi))).call(@res)
|
424
424
|
expect(response_body(response)).to eq([0xFE00F].pack('U*'))
|
425
425
|
end
|
426
426
|
|
@@ -440,7 +440,7 @@ describe '絵文字が' do
|
|
440
440
|
end
|
441
441
|
|
442
442
|
it 'should not convert 〓' do
|
443
|
-
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
443
|
+
response = Jpmobile::MobileCarrier.new(Jpmobile::Filter.new(UnitApplication.new('〓'))).call(@res)
|
444
444
|
expect(response_body(response)).to eq('〓')
|
445
445
|
end
|
446
446
|
|
@@ -17,6 +17,7 @@ describe Jpmobile::MobileCarrier do
|
|
17
17
|
[Jpmobile::Mobile::Emobile, 'emobile/1.0.0 (H11T; like Gecko; Wireless) NetFront/3.4'],
|
18
18
|
[Jpmobile::Mobile::Iphone, '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'],
|
19
19
|
[Jpmobile::Mobile::Android, 'Mozilla/5.0 (Linux; U; Android 1.6; ja-jp; SonyEriccsonSO-01B Build/R1EA018) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1'],
|
20
|
+
[Jpmobile::Mobile::Android, 'Mozilla/5.0 (Linux; Android 9; ANE-LX2J Build/HUAWEIANE-LX2J; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.93 Mobile Safari/537.36 Instagram 172.0.0.21.123 Android (28/9; 480dpi; 1080x2060; HUAWEI; ANE-LX2J; HWANE; hi6250; ja_JP; 269790805)'],
|
20
21
|
[Jpmobile::Mobile::WindowsPhone, 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)'],
|
21
22
|
[Jpmobile::Mobile::BlackBerry, 'BlackBerry9000/4.6.0.224 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/220'],
|
22
23
|
[Jpmobile::Mobile::Ipad, 'Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.5'],
|
data/spec/rack_helper.rb
CHANGED
@@ -74,9 +74,7 @@ module Jpmobile::RackHelper
|
|
74
74
|
def response_body(res)
|
75
75
|
body = case res
|
76
76
|
when Array
|
77
|
-
res[2]
|
78
|
-
when String
|
79
|
-
res.body
|
77
|
+
res[2]
|
80
78
|
else
|
81
79
|
res.body
|
82
80
|
end
|
@@ -84,8 +82,6 @@ module Jpmobile::RackHelper
|
|
84
82
|
case body
|
85
83
|
when Array
|
86
84
|
body.first
|
87
|
-
when String
|
88
|
-
body
|
89
85
|
else
|
90
86
|
body
|
91
87
|
end
|
data/spec/unit/email_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe 'Jpmobile::Email' do
|
|
56
56
|
|
57
57
|
describe 'japanese_mail_address_regexp' do
|
58
58
|
before do
|
59
|
-
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp(?:[^a-zA-Z
|
59
|
+
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp(?:[^a-zA-Z.\-]|$)/)
|
60
60
|
end
|
61
61
|
|
62
62
|
it '#detect_from_mail_header should return Jpmobile::Mobile::AbstractMobile when the header contains .jp address' do
|
@@ -7,7 +7,7 @@ describe 'Jpmobile::Mail#receive' do
|
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
@to = 'info@jpmobile-rails.org'
|
10
|
-
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z
|
10
|
+
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z.\-]/)
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'PC mail' do
|
@@ -4,7 +4,7 @@ gem 'jpmobile', path: './vendor/jpmobile'
|
|
4
4
|
gem 'jpmobile-terminfo', path: './vendor/jpmobile-terminfo'
|
5
5
|
gem 'jpmobile-ipaddresses', path: './vendor/jpmobile-ipaddresses'
|
6
6
|
|
7
|
-
gem 'activerecord-session_store', '
|
7
|
+
gem 'activerecord-session_store', git: 'https://github.com/rails/activerecord-session_store.git', ref: 'f188efbc49a522123cc8acc805143824176d01c1'
|
8
8
|
|
9
9
|
gem 'pry'
|
10
10
|
gem 'pry-byebug'
|
@@ -14,3 +14,7 @@ group :development, :test do
|
|
14
14
|
gem "rspec-rails"
|
15
15
|
gem 'rails-controller-testing'
|
16
16
|
end
|
17
|
+
|
18
|
+
group :test do
|
19
|
+
gem 'cuprite'
|
20
|
+
end
|
@@ -2,13 +2,14 @@
|
|
2
2
|
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
3
3
|
def change
|
4
4
|
create_table :active_storage_blobs do |t|
|
5
|
-
t.string :key,
|
6
|
-
t.string :filename,
|
5
|
+
t.string :key, null: false
|
6
|
+
t.string :filename, null: false
|
7
7
|
t.string :content_type
|
8
8
|
t.text :metadata
|
9
|
-
t.
|
10
|
-
t.
|
11
|
-
t.
|
9
|
+
t.string :service_name, null: false
|
10
|
+
t.bigint :byte_size, null: false
|
11
|
+
t.string :checksum, null: false
|
12
|
+
t.datetime :created_at, null: false
|
12
13
|
|
13
14
|
t.index [:key], unique: true
|
14
15
|
end
|
@@ -23,5 +24,13 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
|
23
24
|
t.index [:record_type, :record_id, :name, :blob_id], name: 'index_active_storage_attachments_uniqueness', unique: true
|
24
25
|
t.foreign_key :active_storage_blobs, column: :blob_id
|
25
26
|
end
|
27
|
+
|
28
|
+
create_table :active_storage_variant_records do |t|
|
29
|
+
t.belongs_to :blob, null: false, index: false
|
30
|
+
t.string :variation_digest, null: false
|
31
|
+
|
32
|
+
t.index %i[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true
|
33
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
File without changes
|
@@ -6,7 +6,7 @@ shared_examples_for 'docomo_guid が起動しないとき' do
|
|
6
6
|
it 'で link_to の自動書き換えが行われない' do
|
7
7
|
get :link
|
8
8
|
|
9
|
-
expect(response.body).to match(%r{href
|
9
|
+
expect(response.body).to match(%r{href=".+/link"})
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ shared_examples_for 'docomo_guid が起動するとき' do
|
|
14
14
|
it 'で link_to の自動書き換えが行われる' do
|
15
15
|
get :link
|
16
16
|
|
17
|
-
expect(response.body).to match(%r{href
|
17
|
+
expect(response.body).to match(%r{href=".+/link\?guid=ON"})
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -52,7 +52,7 @@ describe MobileSpecController, type: :controller do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe "GET '
|
55
|
+
describe "GET 'mobile_not_exist'" do
|
56
56
|
around do |example|
|
57
57
|
orig_value = Jpmobile.config.fallback_view_selector
|
58
58
|
Jpmobile.config.fallback_view_selector = true
|
@@ -65,7 +65,7 @@ describe MobileSpecController, type: :controller do
|
|
65
65
|
context 'PC access' do
|
66
66
|
it 'should be successful' do
|
67
67
|
request.user_agent = 'Mozilla'
|
68
|
-
get '
|
68
|
+
get 'mobile_not_exist'
|
69
69
|
|
70
70
|
expect(response).to be_successful
|
71
71
|
expect(response.body).not_to match('RailsRoot PC mobile')
|
@@ -75,7 +75,7 @@ describe MobileSpecController, type: :controller do
|
|
75
75
|
context 'mobile access' do
|
76
76
|
it 'should be successful' do
|
77
77
|
request.user_agent = 'DoCoMo/2.0 SH902i(c100;TB;W24H12)'
|
78
|
-
get '
|
78
|
+
get 'mobile_not_exist'
|
79
79
|
|
80
80
|
expect(response).to be_successful
|
81
81
|
expect(response.body).not_to match('RailsRoot mobile')
|
@@ -48,7 +48,7 @@ RSpec.configure do |config|
|
|
48
48
|
# # ...
|
49
49
|
# end
|
50
50
|
#
|
51
|
-
# The different available types are documented in the
|
51
|
+
# The different available types are documented in the system, such as in
|
52
52
|
# https://relishapp.com/rspec/rspec-rails/docs
|
53
53
|
config.infer_spec_type_from_file_location!
|
54
54
|
|