jpmobile 5.2.3 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.onkcop-config.yml +423 -0
  4. data/.rubocop.yml +8 -10
  5. data/.ruby-version +1 -1
  6. data/Gemfile +2 -2
  7. data/Gemfile.lock +155 -130
  8. data/README.md +2 -2
  9. data/jpmobile.gemspec +3 -1
  10. data/lib/jpmobile.rb +1 -0
  11. data/lib/jpmobile/emoticon.rb +6 -6
  12. data/lib/jpmobile/filter.rb +7 -2
  13. data/lib/jpmobile/hook_action_view.rb +4 -10
  14. data/lib/jpmobile/hook_test_request.rb +1 -1
  15. data/lib/jpmobile/mail.rb +3 -3
  16. data/lib/jpmobile/mobile/android.rb +1 -1
  17. data/lib/jpmobile/mobile/au.rb +2 -2
  18. data/lib/jpmobile/mobile/black_berry.rb +1 -1
  19. data/lib/jpmobile/mobile/ddipocket.rb +1 -1
  20. data/lib/jpmobile/mobile/docomo.rb +2 -2
  21. data/lib/jpmobile/mobile/emobile.rb +2 -2
  22. data/lib/jpmobile/mobile/ipad.rb +1 -1
  23. data/lib/jpmobile/mobile/iphone.rb +1 -1
  24. data/lib/jpmobile/mobile/softbank.rb +2 -2
  25. data/lib/jpmobile/mobile/vodafone.rb +2 -2
  26. data/lib/jpmobile/mobile/willcom.rb +2 -2
  27. data/lib/jpmobile/mobile/windows_phone.rb +1 -1
  28. data/lib/jpmobile/rails.rb +8 -6
  29. data/lib/jpmobile/resolver.rb +4 -37
  30. data/lib/jpmobile/session/active_record_store.rb +1 -1
  31. data/lib/jpmobile/session/mem_cache_store.rb +1 -1
  32. data/lib/jpmobile/trans_sid.rb +1 -1
  33. data/lib/jpmobile/util.rb +2 -2
  34. data/lib/jpmobile/version.rb +1 -1
  35. data/lib/tasks/jpmobile_tasks.rake +4 -4
  36. data/spec/rack/jpmobile/emoticon_spec.rb +48 -48
  37. data/spec/rack_helper.rb +1 -1
  38. data/spec/unit/receive_mail_spec.rb +9 -9
  39. data/spec/unit/util_spec.rb +4 -4
  40. data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
  41. data/test/rails/overrides/app/mailboxes/application_mailbox.rb +3 -0
  42. data/test/rails/overrides/app/mailboxes/mobile_mailer_mailbox.rb +5 -0
  43. data/test/rails/overrides/app/mailers/decorated_mailer.rb +1 -1
  44. data/test/rails/overrides/db/migrate/20201111033056_create_active_storage_tables.active_storage.rb +36 -0
  45. data/test/rails/overrides/db/migrate/20201111033057_create_action_mailbox_tables.action_mailbox.rb +14 -0
  46. data/test/rails/overrides/spec/controllers/hankaku_filter_controller_spec.rb +1 -1
  47. data/test/rails/overrides/spec/controllers/template_path_spec.rb +2 -0
  48. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-attached.eml +0 -0
  49. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-decomail.eml +0 -0
  50. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji.eml +0 -0
  51. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji2.eml +0 -0
  52. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji5.eml +0 -0
  53. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/bounced-jp.eml +0 -0
  54. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-emoji.eml +0 -0
  55. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-gmail-sjis.eml +0 -0
  56. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-jis.eml +0 -0
  57. data/{spec/unit/email-fixtures → test/rails/overrides/spec/fixtures/files/mobile_mailer}/iphone-message.eml +0 -0
  58. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/no-from.eml +0 -0
  59. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/non-jp.eml +0 -0
  60. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/photo.jpg +0 -0
  61. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-blank.eml +0 -0
  62. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-emoji-utf8.eml +0 -0
  63. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-emoji.eml +0 -0
  64. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-gmail-sjis.eml +0 -0
  65. data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-gmail-utf8.eml +0 -0
  66. data/test/rails/overrides/spec/mailboxes/mobile_mailer_mailbox_spec.rb +265 -0
  67. data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +0 -305
  68. data/test/rails/overrides/spec/requests/emobile_spec.rb +2 -2
  69. metadata +80 -42
@@ -37,6 +37,11 @@ module Jpmobile
37
37
  }
38
38
  end
39
39
 
40
+ ALLOWED_CONTENT_TYPE_REGEXP = Regexp.union(
41
+ Regexp.escape('text/html'),
42
+ Regexp.escape('application/xhtml+xm'),
43
+ )
44
+
40
45
  class << self
41
46
  def hankaku_format(str)
42
47
  replace_chars(str, zen_to_han_table)
@@ -90,8 +95,8 @@ module Jpmobile
90
95
  end
91
96
 
92
97
  def apply_outgoing?
93
- @controller.request.mobile? and
94
- [nil, 'text/html', 'application/xhtml+xml'].include?(@controller.response.content_type)
98
+ @controller.request.mobile? &&
99
+ @controller.response.content_type&.match?(ALLOWED_CONTENT_TYPE_REGEXP)
95
100
  end
96
101
 
97
102
  def to_internal(str)
@@ -11,18 +11,12 @@ end
11
11
  # :stopdoc:
12
12
  # accept-charset に charset を変更できるようにする
13
13
  module Jpmobile
14
- module ActionView
15
- module HtmlOptionsWithAcceptCharset
16
- private
17
-
18
- def html_options_for_form(url_for_options, options, *parameters_for_url)
19
- super.tap do |o|
20
- o['accept-charset'] = (Rails.application.config.jpmobile.form_accept_charset_conversion && request && request.mobile && request.mobile.default_charset) || o['accept-charset']
21
- end
14
+ module HtmlOptionsWithAcceptCharset
15
+ def html_options_for_form(url_for_options, options)
16
+ super.tap do |o|
17
+ o['accept-charset'] = (Rails.application.config.jpmobile.form_accept_charset_conversion && request && request.mobile && request.mobile.default_charset) || o['accept-charset']
22
18
  end
23
19
  end
24
20
  end
25
21
  end
26
-
27
- ::ActionView::Helpers::FormTagHelper.send :prepend, Jpmobile::ActionView::HtmlOptionsWithAcceptCharset
28
22
  #:startdoc:
@@ -1,2 +1,2 @@
1
1
  require 'action_controller/test_case'
2
- ActionController::TestRequest.send :include, Jpmobile::RequestWithMobileTesting
2
+ ActionController::TestRequest.include Jpmobile::RequestWithMobileTesting
@@ -173,7 +173,7 @@ module Mail
173
173
  text_body_part = find_part_by_content_type('text/plain').first
174
174
  html_body_part = find_part_by_content_type('text/html').first
175
175
  html_body_part.transport_encoding = 'quoted-printable' if html_body_part
176
- inline_images = []
176
+ inline_images = []
177
177
  attached_files = []
178
178
  attachments.each do |p|
179
179
  if p.content_type.match(%r{^image/}) && p.content_disposition.match(/^inline/)
@@ -579,8 +579,8 @@ module Mail
579
579
 
580
580
  def get_display_name_with_jpmobile
581
581
  get_display_name_without_jpmobile
582
- rescue NoMethodError => ex
583
- raise ex unless ex.message.match?(/undefined method `gsub' for nil:NilClass/)
582
+ rescue NoMethodError => e
583
+ raise e unless e.message.match?(/undefined method `gsub' for nil:NilClass/)
584
584
 
585
585
  name = unquote(tree.display_name.text_value.strip.to_s)
586
586
  strip_all_comments(name.to_s)
@@ -6,6 +6,6 @@ module Jpmobile::Mobile
6
6
  include Jpmobile::Mobile::GoogleEmoticon
7
7
 
8
8
  # 対応するUser-Agentの正規表現
9
- USER_AGENT_REGEXP = /Android/
9
+ USER_AGENT_REGEXP = /Android/.freeze
10
10
  end
11
11
  end
@@ -6,9 +6,9 @@ module Jpmobile::Mobile
6
6
  class Au < AbstractMobile
7
7
  # 対応するUser-Agentの正規表現
8
8
  # User-Agent文字列中に "UP.Browser" を含むVodafoneの端末があるので注意が必要
9
- USER_AGENT_REGEXP = %r{^(?:KDDI|UP.Browser/.+?)-(.+?) }
9
+ USER_AGENT_REGEXP = %r{^(?:KDDI|UP.Browser/.+?)-(.+?) }.freeze
10
10
  # 対応するメールアドレスの正規表現
11
- MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp/
11
+ MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp/.freeze
12
12
  # 簡易位置情報取得に対応していないデバイスID
13
13
  # http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
14
14
  LOCATION_UNSUPPORTED_DEVICE_ID = %w[PT21 TS25 KCTE TST9 KCU1 SYT5 KCTD TST8 TST7 KCTC SYT4 KCTB KCTA TST6 KCT9 TST5 TST4 KCT8 SYT3 KCT7 MIT1 MAT3 KCT6 TST3 KCT5 KCT4 SYT2 MAT1 MAT2 TST2 KCT3 KCT2 KCT1 TST1 SYT1].freeze
@@ -4,6 +4,6 @@ module Jpmobile::Mobile
4
4
  # ==BlackBerry
5
5
  class BlackBerry < SmartPhone
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = /BlackBerry/
7
+ USER_AGENT_REGEXP = /BlackBerry/.freeze
8
8
  end
9
9
  end
@@ -4,7 +4,7 @@ module Jpmobile::Mobile
4
4
  # スーパクラスはWillcom。
5
5
  class Ddipocket < Willcom
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = %r{^Mozilla/3.0\(DDIPOCKET}
7
+ USER_AGENT_REGEXP = %r{^Mozilla/3.0\(DDIPOCKET}.freeze
8
8
 
9
9
  MAIL_ADDRESS_REGEXP = nil # DdipocketはEmail判定だとWillcomと判定させたい
10
10
  end
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
4
4
  # ==DoCoMo携帯電話
5
5
  class Docomo < AbstractMobile
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = /^DoCoMo/
7
+ USER_AGENT_REGEXP = /^DoCoMo/.freeze
8
8
  # 対応するメールアドレスの正規表現
9
- MAIL_ADDRESS_REGEXP = /.+@docomo\.ne\.jp/
9
+ MAIL_ADDRESS_REGEXP = /.+@docomo\.ne\.jp/.freeze
10
10
  # メールのデフォルトのcharset
11
11
  MAIL_CHARSET = 'Shift_JIS'.freeze
12
12
  # テキスト部分の content-transfer-encoding
@@ -3,9 +3,9 @@
3
3
  module Jpmobile::Mobile
4
4
  # ==EMOBILE携帯電話
5
5
  class Emobile < AbstractMobile
6
- USER_AGENT_REGEXP = %r{^emobile/|^Mozilla/5.0 \(H11T; like Gecko; OpenBrowser\) NetFront/3.4$|^Mozilla/4.0 \(compatible; MSIE 6.0; Windows CE; IEMobile 7.7\) S11HT$}
6
+ USER_AGENT_REGEXP = %r{^emobile/|^Mozilla/5.0 \(H11T; like Gecko; OpenBrowser\) NetFront/3.4$|^Mozilla/4.0 \(compatible; MSIE 6.0; Windows CE; IEMobile 7.7\) S11HT$}.freeze
7
7
  # 対応するメールアドレスの正規表現
8
- MAIL_ADDRESS_REGEXP = /.+@emnet\.ne\.jp/
8
+ MAIL_ADDRESS_REGEXP = /.+@emnet\.ne\.jp/.freeze
9
9
  # EMnet対応端末から通知されるユニークなユーザIDを取得する。
10
10
  def em_uid
11
11
  @request.env['HTTP_X_EM_UID']
@@ -6,6 +6,6 @@ module Jpmobile::Mobile
6
6
  include Jpmobile::Mobile::UnicodeEmoticon
7
7
 
8
8
  # 対応するUser-Agentの正規表現
9
- USER_AGENT_REGEXP = /iPad/
9
+ USER_AGENT_REGEXP = /iPad/.freeze
10
10
  end
11
11
  end
@@ -6,6 +6,6 @@ module Jpmobile::Mobile
6
6
  include Jpmobile::Mobile::UnicodeEmoticon
7
7
 
8
8
  # 対応するUser-Agentの正規表現
9
- USER_AGENT_REGEXP = /iPhone/
9
+ USER_AGENT_REGEXP = /iPhone/.freeze
10
10
  end
11
11
  end
@@ -5,9 +5,9 @@ module Jpmobile::Mobile
5
5
  # Vodafoneのスーパクラス。
6
6
  class Softbank < AbstractMobile
7
7
  # 対応するuser-agentの正規表現
8
- USER_AGENT_REGEXP = /^(?:SoftBank|Semulator)/
8
+ USER_AGENT_REGEXP = /^(?:SoftBank|Semulator)/.freeze
9
9
  # 対応するメールアドレスの正規表現 ディズニーモバイル対応
10
- MAIL_ADDRESS_REGEXP = /.+@(?:softbank\.ne\.jp|disney\.ne\.jp)/
10
+ MAIL_ADDRESS_REGEXP = /.+@(?:softbank\.ne\.jp|disney\.ne\.jp)/.freeze
11
11
  # メールのデフォルトのcharset
12
12
  MAIL_CHARSET = 'Shift_JIS'.freeze
13
13
  # テキスト部分の content-transfer-encoding
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
4
4
  # スーパクラスはSoftbank。
5
5
  class Vodafone < Softbank
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/
7
+ USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/.freeze
8
8
  # 対応するメールアドレスの正規表現
9
- MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp/
9
+ MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp/.freeze
10
10
 
11
11
  # cookieに対応しているか?
12
12
  def supports_cookie?
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
4
4
  # Ddipocketのスーパクラス。
5
5
  class Willcom < AbstractMobile
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}
7
+ USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}.freeze
8
8
  # 対応するメールアドレスの正規表現
9
- MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)/
9
+ MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)/.freeze
10
10
 
11
11
  # 位置情報があれば Position のインスタンスを返す。無ければ +nil+ を返す。
12
12
  def position
@@ -4,6 +4,6 @@ module Jpmobile::Mobile
4
4
  # ==WindowsPhone
5
5
  class WindowsPhone < SmartPhone
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = /Windows Phone/
7
+ USER_AGENT_REGEXP = /Windows Phone/.freeze
8
8
  end
9
9
  end
@@ -4,24 +4,26 @@ ActiveSupport.on_load(:action_controller) do
4
4
  require 'jpmobile/helpers'
5
5
  require 'jpmobile/trans_sid'
6
6
  require 'jpmobile/hook_test_request'
7
- ActionDispatch::Request.send :prepend, Jpmobile::Encoding
8
- ActionDispatch::Request.send :include, Jpmobile::RequestWithMobile
9
- ActionController::Base.send :prepend, Jpmobile::FallbackViewSelector
10
- ActionController::Base.send :prepend, Jpmobile::TransSidRedirecting
7
+ ActionDispatch::Request.prepend Jpmobile::Encoding
8
+ ActionDispatch::Request.include Jpmobile::RequestWithMobile
9
+ ActionController::Base.prepend Jpmobile::FallbackViewSelector
10
+ ActionController::Base.prepend Jpmobile::TransSidRedirecting
11
11
  end
12
12
 
13
13
  ActiveSupport.on_load(:action_view) do
14
14
  require 'jpmobile/hook_action_view'
15
+
16
+ self.prepend Jpmobile::HtmlOptionsWithAcceptCharset
15
17
  end
16
18
 
17
19
  ActiveSupport.on_load(:after_initialize) do
18
20
  case Rails.application.config.session_store.to_s
19
21
  when 'ActionDispatch::Session::MemCacheStore'
20
22
  require 'jpmobile/session/mem_cache_store'
21
- ActionDispatch::Session::MemCacheStore.send :prepend, Jpmobile::ParamsOverCookie
23
+ ActionDispatch::Session::MemCacheStore.prepend Jpmobile::ParamsOverCookie
22
24
  when 'ActionDispatch::Session::ActiveRecordStore'
23
25
  require 'jpmobile/session/active_record_store'
24
- ActionDispatch::Session::AbstractStore.send :prepend, Jpmobile::ParamsOverCookie
26
+ ActionDispatch::Session::AbstractStore.prepend Jpmobile::ParamsOverCookie
25
27
  else
26
28
  Rails.application.config.jpmobile.mount_session_store
27
29
  end
@@ -1,47 +1,14 @@
1
1
  module Jpmobile
2
- class Resolver < ActionView::FileSystemResolver
2
+ class Resolver < ::ActionView::FileSystemResolver
3
3
  EXTENSIONS = [:locale, :formats, :handlers, :mobile].freeze
4
4
  DEFAULT_PATTERN = ':prefix/:action{_:mobile,}{.:locale,}{.:formats,}{+:variants,}{.:handlers,}'.freeze
5
5
 
6
- def initialize(path, pattern = nil)
6
+ def initialize(path)
7
7
  raise ArgumentError, 'path already is a Resolver class' if path.is_a?(Resolver)
8
8
 
9
- super(path, pattern || DEFAULT_PATTERN)
9
+ super
10
+ @pattern = DEFAULT_PATTERN
10
11
  @path = File.expand_path(path)
11
12
  end
12
-
13
- private
14
-
15
- def query(path, details, formats, outside_app_allowed)
16
- query = build_query(path, details)
17
-
18
- template_paths = find_template_paths(query)
19
- template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed
20
-
21
- template_paths.map do |template|
22
- handler, format, variant = extract_handler_and_format_and_variant(template)
23
- contents = File.binread(template)
24
-
25
- virtual_path = if format
26
- if template =~ /.+#{path}(.+)\.#{format.to_sym.to_s}.*$/
27
- path.to_str + Regexp.last_match(1)
28
- else
29
- path.virtual
30
- end
31
- else
32
- path.virtual
33
- end
34
-
35
- ActionView::Template.new(
36
- contents,
37
- File.expand_path(template),
38
- handler,
39
- virtual_path: virtual_path,
40
- format: format,
41
- variant: variant,
42
- updated_at: mtime(template),
43
- )
44
- end
45
- end
46
13
  end
47
14
  end
@@ -8,4 +8,4 @@ module Jpmobile
8
8
  end
9
9
  end
10
10
 
11
- ActionDispatch::Session::ActiveRecordStore.send :prepend, Jpmobile::ActiveRecordStoreRegenerateSessionId
11
+ ActionDispatch::Session::ActiveRecordStore.prepend Jpmobile::ActiveRecordStoreRegenerateSessionId
@@ -8,4 +8,4 @@ module Jpmobile
8
8
  end
9
9
  end
10
10
 
11
- ActionDispatch::Session::MemCacheStore.send :prepend, Jpmobile::MemCacheStoreRegenerateSessionId
11
+ ActionDispatch::Session::MemCacheStore.prepend Jpmobile::MemCacheStoreRegenerateSessionId
@@ -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 session_key}\" value=\"#{CGI.escapeHTML jpmobile_session_id}\" />"
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を追加する。
@@ -312,9 +312,9 @@ module Jpmobile
312
312
  def decode(str, encoding, charset)
313
313
  _str = case encoding
314
314
  when /quoted-printable/i
315
- str.unpack('M').first.strip
315
+ str.unpack1('M').strip
316
316
  when /base64/i
317
- str.unpack('m').first.strip
317
+ str.unpack1('m').strip
318
318
  else
319
319
  str
320
320
  end
@@ -1,3 +1,3 @@
1
1
  module Jpmobile
2
- VERSION = '5.2.3'.freeze
2
+ VERSION = '6.1.0'.freeze
3
3
  end
@@ -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
@@ -94,8 +94,8 @@ namespace :test do
94
94
 
95
95
  unless skip
96
96
  # add gems for jpmobile spec
97
- config_path = File.join(rails_root, 'Gemfile')
98
- File.open(config_path, 'a+') do |file|
97
+ gemfile_path = File.join(rails_root, 'Gemfile')
98
+ File.open(gemfile_path, 'a+') do |file|
99
99
  file.write <<-GEMFILE
100
100
  instance_eval File.read(File.expand_path(__FILE__) + '.jpmobile')
101
101
  GEMFILE
@@ -104,7 +104,7 @@ namespace :test do
104
104
 
105
105
  # run tests in rails
106
106
  Dir.chdir(rails_root) do
107
- Bundler.with_clean_env do
107
+ Bundler.with_unbundled_env do
108
108
  original_env = ENV.to_hash
109
109
 
110
110
  ENV.update('RBENV_VERSION' => nil)
@@ -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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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)[2]
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