jpmobile 7.0.0 → 7.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +5 -2
  3. data/.rubocop.yml +104 -1
  4. data/.ruby-version +1 -1
  5. data/Gemfile.lock +116 -89
  6. data/README.md +24 -3
  7. data/Rakefile +1 -1
  8. data/jpmobile.gemspec +2 -1
  9. data/lib/jpmobile/datum_conv.rb +7 -7
  10. data/lib/jpmobile/email.rb +2 -2
  11. data/lib/jpmobile/fallback_view_selector.rb +2 -2
  12. data/lib/jpmobile/filter.rb +3 -1
  13. data/lib/jpmobile/mail.rb +2 -2
  14. data/lib/jpmobile/mailer.rb +1 -1
  15. data/lib/jpmobile/method_less_action_support.rb +11 -0
  16. data/lib/jpmobile/mobile/abstract_mobile.rb +1 -1
  17. data/lib/jpmobile/mobile/android.rb +1 -1
  18. data/lib/jpmobile/mobile/au.rb +6 -8
  19. data/lib/jpmobile/mobile/black_berry.rb +1 -1
  20. data/lib/jpmobile/mobile/ddipocket.rb +1 -1
  21. data/lib/jpmobile/mobile/docomo.rb +2 -2
  22. data/lib/jpmobile/mobile/emobile.rb +2 -2
  23. data/lib/jpmobile/mobile/ipad.rb +1 -1
  24. data/lib/jpmobile/mobile/iphone.rb +1 -1
  25. data/lib/jpmobile/mobile/softbank.rb +5 -3
  26. data/lib/jpmobile/mobile/vodafone.rb +2 -2
  27. data/lib/jpmobile/mobile/willcom.rb +2 -2
  28. data/lib/jpmobile/mobile/windows_phone.rb +1 -1
  29. data/lib/jpmobile/position.rb +2 -2
  30. data/lib/jpmobile/rails.rb +1 -0
  31. data/lib/jpmobile/template_details.rb +1 -1
  32. data/lib/jpmobile/version.rb +1 -1
  33. data/lib/tasks/jpmobile_tasks.rake +2 -4
  34. data/spec/unit/decorated_mail_spec.rb +1 -1
  35. data/spec/unit/mail_spec.rb +2 -2
  36. data/spec/unit/receive_mail_spec.rb +29 -29
  37. data/test/rails/overrides/app/controllers/method_less_action_support_controller.rb +3 -0
  38. data/test/rails/overrides/app/mailers/decorated_mailer.rb +1 -1
  39. data/test/rails/overrides/app/views/method_less_action_support/index_smart_phone.html.erb +0 -0
  40. data/test/rails/overrides/config/routes.rb +4 -0
  41. data/test/rails/overrides/spec/requests/method_less_action_support_spec.rb +28 -0
  42. metadata +13 -5
@@ -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,15 +6,17 @@ 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
15
15
  # GPS取得に対応していないデバイスID
16
16
  GPS_UNSUPPORTED_DEVICE_ID = %w[PT21 KC26 SN28 SN26 KC23 SA28 TS25 SA25 SA24 SN23 ST14 KC15 SN22 KC14 ST13 SN17 SY15 CA14 HI14 TS14 KC13 SN15 SN16 SY14 ST12 TS13 CA13 MA13 HI13 SN13 SY13 SN12 SN14 ST11 DN11 SY12 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
17
17
 
18
+ TARGET_PARAMS = %w[ver datum unit lat lon alt time smaj smin vert majaa fm].freeze
19
+
18
20
  # EZ番号(サブスクライバID)があれば返す。無ければ +nil+ を返す。
19
21
  def subno
20
22
  @request.env['HTTP_X_UP_SUBNO']
@@ -27,7 +29,7 @@ module Jpmobile::Mobile
27
29
  return @__posotion = nil if params['lat'].nil? || params['lat'] == '' || params['lon'].nil? || params['lon'] == ''
28
30
 
29
31
  l = Jpmobile::Position.new
30
- l.options = params.select {|x, _| %w[ver datum unit lat lon alt time smaj smin vert majaa fm].include?(x) }
32
+ l.options = params.select {|x, _| TARGET_PARAMS.include?(x) }
31
33
  case params['unit']
32
34
  when '1'
33
35
  l.lat = params['lat'].to_f
@@ -83,11 +85,7 @@ module Jpmobile::Mobile
83
85
  'none'
84
86
  end
85
87
 
86
- if protocol.start_with?('https')
87
- false
88
- else
89
- true
90
- end
88
+ !protocol.start_with?('https')
91
89
  end
92
90
 
93
91
  # 文字コード変換
@@ -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,14 +5,16 @@ 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
14
14
  MAIL_CONTENT_TRANSFER_ENCODING = '8bit'.freeze
15
15
 
16
+ TARGET_PARAMS = ['pos', 'geo', 'x-acr'].freeze
17
+
16
18
  # 製造番号を返す。無ければ +nil+ を返す。
17
19
  def serial_number
18
20
  @request.env['HTTP_USER_AGENT'] =~ /SN(.+?) /
@@ -36,7 +38,7 @@ module Jpmobile::Mobile
36
38
  l = Jpmobile::Position.new
37
39
  l.lat = ((Regexp.last_match(1) == 'N') ? 1 : -1) * Jpmobile::Position.dms2deg(Regexp.last_match(2), Regexp.last_match(3), Regexp.last_match(4))
38
40
  l.lon = ((Regexp.last_match(5) == 'E') ? 1 : -1) * Jpmobile::Position.dms2deg(Regexp.last_match(6), Regexp.last_match(7), Regexp.last_match(8))
39
- l.options = params.select {|x, _| ['pos', 'geo', 'x-acr'].include?(x) }
41
+ l.options = params.select {|x, _| TARGET_PARAMS.include?(x) }
40
42
 
41
43
  @__position = l
42
44
  end
@@ -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
@@ -10,7 +10,7 @@ end
10
10
  module Jpmobile
11
11
  # 位置情報
12
12
  class Position
13
- if Object.const_defined?('GeoKit')
13
+ if Object.const_defined?(:GeoKit)
14
14
  # GeoKitが読み込まれている場合はMappableにする
15
15
  include ::GeoKit::Mappable
16
16
  def self.acts_as_mappable
@@ -35,7 +35,7 @@ module Jpmobile
35
35
 
36
36
  # 度分秒を度に変換する。
37
37
  def self.dms2deg(d, m, s)
38
- d.to_i + m.to_i.to_f / 60 + s.to_f / 3600
38
+ d.to_i + (m.to_i.to_f / 60) + (s.to_f / 3600)
39
39
  end
40
40
 
41
41
  # 日本測地系から世界測地系に変換する。
@@ -2,6 +2,7 @@ ActiveSupport.on_load(:action_controller) do
2
2
  require 'jpmobile/docomo_guid'
3
3
  require 'jpmobile/filter'
4
4
  require 'jpmobile/helpers'
5
+ require 'jpmobile/method_less_action_support'
5
6
  require 'jpmobile/trans_sid'
6
7
  require 'jpmobile/hook_test_request'
7
8
  ActionDispatch::Request.prepend Jpmobile::Encoding
@@ -19,8 +19,8 @@ module Jpmobile
19
19
  requested.formats_idx[@format],
20
20
  requested.locale_idx[@locale],
21
21
  requested.variants_idx[@variant],
22
- requested.handlers_idx[@handler],
23
22
  requested.mobile_idx[@mobile],
23
+ requested.handlers_idx[@handler],
24
24
  ]
25
25
  end
26
26
 
@@ -1,3 +1,3 @@
1
1
  module Jpmobile
2
- VERSION = '7.0.0'.freeze
2
+ VERSION = '7.0.3'.freeze
3
3
  end
@@ -84,12 +84,10 @@ namespace :test do
84
84
  unless skip
85
85
  # for cookie_only option
86
86
  config_path = File.join(rails_root, 'config', 'initializers', 'session_store.rb')
87
- File.open(config_path, 'w') do |file|
88
- file.write <<-SESSION_CONFIG
87
+ File.write(config_path, <<-SESSION_CONFIG)
89
88
  Rails.application.config.session_store :active_record_store, :key => '_session_id'
90
89
  Rails.application.config.session_options = { :cookie_only => false }
91
- SESSION_CONFIG
92
- end
90
+ SESSION_CONFIG
93
91
  end
94
92
 
95
93
  unless skip
@@ -14,7 +14,7 @@ describe 'decorated mails' do
14
14
  @mail.from = 'ちはやふる <info@jpmobile-rails.org>'
15
15
  @mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
16
16
 
17
- @photo = File.open(File.join(__dir__, 'email-fixtures/photo.jpg')).read
17
+ @photo = File.read(File.join(__dir__, 'email-fixtures/photo.jpg'))
18
18
  @mail.attachments.inline['photo.jpg'] = @photo
19
19
  @inline_url = @mail.attachments['photo.jpg'].url
20
20
  end
@@ -285,7 +285,7 @@ describe 'Jpmobile::Mail' do
285
285
  @mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
286
286
  @mail.mobile = @mobile
287
287
  @mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
288
- @photo = File.open(File.join(__dir__, 'email-fixtures/photo.jpg')).read
288
+ @photo = File.read(File.join(__dir__, 'email-fixtures/photo.jpg'))
289
289
  end
290
290
 
291
291
  it 'should encodes itself successfully' do
@@ -318,7 +318,7 @@ describe 'Jpmobile::Mail' do
318
318
  @mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
319
319
  @mail.mobile = @mobile
320
320
  @mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
321
- @photo = File.open(File.join(__dir__, 'email-fixtures/photo.jpg')).read
321
+ @photo = File.read(File.join(__dir__, 'email-fixtures/photo.jpg'))
322
322
  end
323
323
 
324
324
  it 'wave dash converting correctly' do
@@ -12,7 +12,7 @@ describe 'Jpmobile::Mail#receive' do
12
12
 
13
13
  describe 'PC mail' do
14
14
  before(:each) do
15
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/pc-mail-single.eml')).read)
15
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/pc-mail-single.eml')))
16
16
  end
17
17
 
18
18
  it 'subject should be parsed correctly' do
@@ -49,7 +49,7 @@ describe 'Jpmobile::Mail#receive' do
49
49
  describe 'multipart' do
50
50
  describe 'PC mail' do
51
51
  before(:each) do
52
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/pc-mail-multi.eml')).read)
52
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/pc-mail-multi.eml')))
53
53
  end
54
54
 
55
55
  it 'subject should be parsed correctly' do
@@ -68,7 +68,7 @@ describe 'Jpmobile::Mail#receive' do
68
68
 
69
69
  describe 'PC mail without subject' do
70
70
  before(:each) do
71
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/pc-mail-attached-without-subject.eml')).read)
71
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/pc-mail-attached-without-subject.eml')))
72
72
  end
73
73
 
74
74
  it 'body should be parsed correctly' do
@@ -84,7 +84,7 @@ describe 'Jpmobile::Mail#receive' do
84
84
  describe 'Docomo' do
85
85
  context 'with sjis decomail' do
86
86
  before(:each) do
87
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/docomo-gmail-sjis.eml')).read)
87
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/docomo-gmail-sjis.eml')))
88
88
  end
89
89
 
90
90
  it 'subject should be parsed correctly' do
@@ -111,7 +111,7 @@ describe 'Jpmobile::Mail#receive' do
111
111
 
112
112
  context 'with jis decomail' do
113
113
  before(:each) do
114
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/docomo-decomail.eml')).read)
114
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/docomo-decomail.eml')))
115
115
  end
116
116
 
117
117
  it 'does not contain charset within multipart Content-Type' do
@@ -129,7 +129,7 @@ describe 'Jpmobile::Mail#receive' do
129
129
 
130
130
  describe 'Au' do
131
131
  before(:each) do
132
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/au-decomail.eml')).read)
132
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/au-decomail.eml')))
133
133
  end
134
134
 
135
135
  it 'subject should be parsed correctly' do
@@ -151,7 +151,7 @@ describe 'Jpmobile::Mail#receive' do
151
151
  describe 'Softbank' do
152
152
  context 'Shift_JIS' do
153
153
  before(:each) do
154
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/softbank-gmail-sjis.eml')).read)
154
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/softbank-gmail-sjis.eml')))
155
155
  end
156
156
 
157
157
  it 'subject should be parsed correctly' do
@@ -170,7 +170,7 @@ describe 'Jpmobile::Mail#receive' do
170
170
 
171
171
  context 'UTF-8' do
172
172
  before(:each) do
173
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/softbank-gmail-utf8.eml')).read)
173
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/softbank-gmail-utf8.eml')))
174
174
  end
175
175
 
176
176
  it 'subject should be parsed correctly' do
@@ -190,7 +190,7 @@ describe 'Jpmobile::Mail#receive' do
190
190
 
191
191
  context 'bounced mail' do
192
192
  it 'should parse sub-part charset correctly' do
193
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/bounce_with_utf8_part.eml')).read)
193
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/bounce_with_utf8_part.eml')))
194
194
  expect(@mail.parts.first.charset).to match(/iso-2022-jp/i)
195
195
  expect(@mail.parts.last.charset).to match(/utf-8/i)
196
196
  end
@@ -199,7 +199,7 @@ describe 'Jpmobile::Mail#receive' do
199
199
 
200
200
  describe 'Docomo' do
201
201
  before(:each) do
202
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/docomo-emoji.eml')).read)
202
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/docomo-emoji.eml')))
203
203
  end
204
204
 
205
205
  it 'subject should be parsed correctly' do
@@ -234,7 +234,7 @@ describe 'Jpmobile::Mail#receive' do
234
234
 
235
235
  context 'JIS mail' do
236
236
  before(:each) do
237
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/docomo-jis.eml')).read)
237
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/docomo-jis.eml')))
238
238
  end
239
239
 
240
240
  it 'subject should be parsed correctly' do
@@ -250,7 +250,7 @@ describe 'Jpmobile::Mail#receive' do
250
250
  describe 'Au' do
251
251
  context 'au-emoji.eml' do
252
252
  before(:each) do
253
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/au-emoji.eml')).read)
253
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/au-emoji.eml')))
254
254
  end
255
255
 
256
256
  it 'subject should be parsed correctly' do
@@ -286,36 +286,36 @@ describe 'Jpmobile::Mail#receive' do
286
286
 
287
287
  it 'should not be raised when parsing incoming email #41' do
288
288
  expect {
289
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/au-email.eml')).read)
289
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/au-email.eml')))
290
290
  }.not_to raise_error
291
291
  end
292
292
 
293
293
  it 'should not be raised when parsing incoming email #45' do
294
294
  expect {
295
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/au-decomail2.eml')).read)
295
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/au-decomail2.eml')))
296
296
  }.not_to raise_error
297
297
  end
298
298
 
299
299
  it 'should not be raised when parsing incoming email - include kigou' do
300
300
  expect {
301
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/au-kigou.eml')).read)
301
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/au-kigou.eml')))
302
302
  }.not_to raise_error
303
303
  end
304
304
 
305
305
  context 'From au iPhone' do
306
306
  it 'charset should be UTF-8' do
307
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/iphone-message.eml')).read)
307
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/iphone-message.eml')))
308
308
  expect(@mail.mobile).to be_a(Jpmobile::Mobile::Au)
309
309
  expect(@mail.charset).to match(/utf-8/i)
310
310
  end
311
311
 
312
312
  it 'should be encoded correctly' do
313
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/iphone-message.eml')).read)
313
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/iphone-message.eml')))
314
314
  expect(@mail.encoded).to match(Regexp.escape("%[\e$B1`;yL>\e(B]%\e$B$N\e(B%[\e$BJ]8n<TL>\e(B]%"))
315
315
  end
316
316
 
317
317
  it 'should decode cp932-encoded mail correctly' do
318
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/iphone-cp932.eml')).read)
318
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/iphone-cp932.eml')))
319
319
  expect(@mail.subject).to eq 'Re: 【NKSC】test'
320
320
  expect(@mail.body.to_s).to eq 'テストです。㈱'
321
321
  end
@@ -323,20 +323,20 @@ describe 'Jpmobile::Mail#receive' do
323
323
 
324
324
  context 'From iPad' do
325
325
  it 'charset should be UTF-8' do
326
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/iphone-mail3.eml')).read)
326
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/iphone-mail3.eml')))
327
327
  expect(@mail.mobile).to be_a(Jpmobile::Mobile::AbstractMobile)
328
328
  expect(@mail.charset).to match(/utf-8/i)
329
329
  end
330
330
 
331
331
  it 'should be encoded correctly' do
332
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/iphone-mail3.eml')).read)
332
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/iphone-mail3.eml')))
333
333
  expect(@mail.encoded).to match(/BK\\J82~9T\$J\$7!2#5#1#2J8;z!2/)
334
334
  end
335
335
  end
336
336
 
337
337
  it 'should not raise when parsing attached email' do
338
338
  expect {
339
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/au-attached.eml')).read)
339
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/au-attached.eml')))
340
340
  expect(@mail.encoded).to match('/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPQAA')
341
341
  }.not_to raise_error
342
342
  end
@@ -344,7 +344,7 @@ describe 'Jpmobile::Mail#receive' do
344
344
 
345
345
  describe 'Softbank' do
346
346
  before(:each) do
347
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/softbank-emoji.eml')).read)
347
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/softbank-emoji.eml')))
348
348
  end
349
349
 
350
350
  it 'subject should be parsed correctly' do
@@ -379,7 +379,7 @@ describe 'Jpmobile::Mail#receive' do
379
379
 
380
380
  describe 'blank-mail' do
381
381
  before(:each) do
382
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/softbank-blank.eml')).read)
382
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/softbank-blank.eml')))
383
383
  end
384
384
 
385
385
  it 'subject should be parsed correctly' do
@@ -395,7 +395,7 @@ describe 'Jpmobile::Mail#receive' do
395
395
  describe 'iPhone' do
396
396
  context 'JIS mail' do
397
397
  before(:each) do
398
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/iphone-jis.eml')).read)
398
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/iphone-jis.eml')))
399
399
  end
400
400
 
401
401
  it 'body should be parsed correctly' do
@@ -405,7 +405,7 @@ describe 'Jpmobile::Mail#receive' do
405
405
 
406
406
  context 'when the mail contains UTF-8 emojis' do
407
407
  before(:each) do
408
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/iphone-unicode-emoji.eml')).read)
408
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/iphone-unicode-emoji.eml')))
409
409
  end
410
410
 
411
411
  it 'subject should be parsed correctly' do
@@ -419,7 +419,7 @@ describe 'Jpmobile::Mail#receive' do
419
419
 
420
420
  context 'when the mail contains circled-numbers' do
421
421
  before(:each) do
422
- @mail = Mail.new(File.open(File.join(__dir__, 'email-fixtures/iphone-circled-numbers-in-jis.eml')).read)
422
+ @mail = Mail.new(File.read(File.join(__dir__, 'email-fixtures/iphone-circled-numbers-in-jis.eml')))
423
423
  end
424
424
 
425
425
  it 'subject should be parsed correctly' do
@@ -435,7 +435,7 @@ describe 'Jpmobile::Mail#receive' do
435
435
  describe 'bounced mail' do
436
436
  context 'has jp address' do
437
437
  before(:each) do
438
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/bounced-jp.eml')).read)
438
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/bounced-jp.eml')))
439
439
  end
440
440
 
441
441
  it 'mobile should abstract mobile' do
@@ -447,7 +447,7 @@ describe 'Jpmobile::Mail#receive' do
447
447
  describe 'non-Japanese mail' do
448
448
  context 'us-ascii' do
449
449
  before(:each) do
450
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/non-jp.eml')).read)
450
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/non-jp.eml')))
451
451
  end
452
452
 
453
453
  it 'mobile should be nil' do
@@ -458,7 +458,7 @@ describe 'Jpmobile::Mail#receive' do
458
458
 
459
459
  context 'no From header' do
460
460
  before(:each) do
461
- @mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/no-from.eml')).read)
461
+ @mail = Mail.new(File.read(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/no-from.eml')))
462
462
  end
463
463
 
464
464
  it 'mobile should be nil' do
@@ -0,0 +1,3 @@
1
+ class MethodLessActionSupportController < ApplicationController
2
+ include Jpmobile::MethodLessActionSupport
3
+ end
@@ -3,7 +3,7 @@ class DecoratedMailer < Jpmobile::Mailer::Base
3
3
  default to: 'info@jp.mobile'
4
4
 
5
5
  def deco_mail(to_mail)
6
- attachments.inline['photo.jpg'] = File.open(File.join(Rails.root, 'spec/fixtures/files/mobile_mailer/photo.jpg')).read
6
+ attachments.inline['photo.jpg'] = File.read(File.join(Rails.root, 'spec/fixtures/files/mobile_mailer/photo.jpg'))
7
7
 
8
8
  mail(to: to_mail, subject: '題名', decorated: true)
9
9
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Performance/CollectionLiteralInLoop
1
2
  RailsRoot::Application.routes.draw do
2
3
  resources :users
3
4
  namespace :admin do
@@ -101,4 +102,7 @@ RailsRoot::Application.routes.draw do
101
102
  get "#{c}/#{a}", to: "#{c}##{a}"
102
103
  end
103
104
  end
105
+
106
+ get 'method_less_action_support', to: 'method_less_action_support#index'
104
107
  end
108
+ # rubocop:enable Performance/CollectionLiteralInLoop
@@ -0,0 +1,28 @@
1
+ require 'rails_helper'
2
+
3
+ describe 'Method-less mobile template only action', type: :request do
4
+ subject do
5
+ get '/method_less_action_support', headers: headers
6
+ end
7
+
8
+ let(:headers) do
9
+ {}
10
+ end
11
+
12
+ context 'when accessed with mobile User-Agent' do
13
+ before do
14
+ headers['User-Agent'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
15
+ end
16
+
17
+ it 'successfully renders mobile template' do
18
+ subject
19
+ expect(response).to have_http_status(200)
20
+ end
21
+ end
22
+
23
+ context 'when accessed with non-mobile User-Agent' do
24
+ it 'raises AbstractController::ActionNotFound' do
25
+ expect { subject }.to raise_error(AbstractController::ActionNotFound)
26
+ end
27
+ end
28
+ end