jpmobile 5.2.3 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.onkcop-config.yml +423 -0
- data/.rubocop.yml +8 -10
- data/.ruby-version +1 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +155 -130
- data/README.md +2 -2
- data/jpmobile.gemspec +3 -1
- data/lib/jpmobile.rb +1 -0
- data/lib/jpmobile/emoticon.rb +6 -6
- data/lib/jpmobile/filter.rb +7 -2
- data/lib/jpmobile/hook_action_view.rb +4 -10
- data/lib/jpmobile/hook_test_request.rb +1 -1
- data/lib/jpmobile/mail.rb +3 -3
- data/lib/jpmobile/mobile/android.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 +2 -2
- 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/rails.rb +8 -6
- data/lib/jpmobile/resolver.rb +4 -37
- data/lib/jpmobile/session/active_record_store.rb +1 -1
- data/lib/jpmobile/session/mem_cache_store.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +1 -1
- data/lib/jpmobile/util.rb +2 -2
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +4 -4
- data/spec/rack/jpmobile/emoticon_spec.rb +48 -48
- data/spec/rack_helper.rb +1 -1
- data/spec/unit/receive_mail_spec.rb +9 -9
- data/spec/unit/util_spec.rb +4 -4
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/mailboxes/application_mailbox.rb +3 -0
- data/test/rails/overrides/app/mailboxes/mobile_mailer_mailbox.rb +5 -0
- data/test/rails/overrides/app/mailers/decorated_mailer.rb +1 -1
- data/test/rails/overrides/db/migrate/20201111033056_create_active_storage_tables.active_storage.rb +36 -0
- data/test/rails/overrides/db/migrate/20201111033057_create_action_mailbox_tables.action_mailbox.rb +14 -0
- data/test/rails/overrides/spec/controllers/hankaku_filter_controller_spec.rb +1 -1
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +2 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-attached.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-decomail.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji2.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji5.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/bounced-jp.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-emoji.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-gmail-sjis.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-jis.eml +0 -0
- data/{spec/unit/email-fixtures → test/rails/overrides/spec/fixtures/files/mobile_mailer}/iphone-message.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/no-from.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/non-jp.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/photo.jpg +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-blank.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-emoji-utf8.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-emoji.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-gmail-sjis.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-gmail-utf8.eml +0 -0
- data/test/rails/overrides/spec/mailboxes/mobile_mailer_mailbox_spec.rb +265 -0
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +0 -305
- data/test/rails/overrides/spec/requests/emobile_spec.rb +2 -2
- metadata +80 -42
data/spec/rack_helper.rb
CHANGED
@@ -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/mobile_mailer/docomo-gmail-sjis.eml')).read)
|
87
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/docomo-gmail-sjis.eml')).read)
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'subject should be parsed correctly' 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/mobile_mailer/au-decomail.eml')).read)
|
132
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/au-decomail.eml')).read)
|
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/mobile_mailer/softbank-gmail-sjis.eml')).read)
|
154
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/softbank-gmail-sjis.eml')).read)
|
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/mobile_mailer/softbank-gmail-utf8.eml')).read)
|
173
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/softbank-gmail-utf8.eml')).read)
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'subject should be parsed correctly' do
|
@@ -304,13 +304,13 @@ describe 'Jpmobile::Mail#receive' do
|
|
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__, '
|
307
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/iphone-message.eml')).read)
|
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__, '
|
313
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/iphone-message.eml')).read)
|
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
|
|
@@ -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/mobile_mailer/bounced-jp.eml')).read)
|
438
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/bounced-jp.eml')).read)
|
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/mobile_mailer/non-jp.eml')).read)
|
450
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/non-jp.eml')).read)
|
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/mobile_mailer/no-from.eml')).read)
|
461
|
+
@mail = Mail.new(File.open(File.join(__dir__, '../../test/rails/overrides/spec/fixtures/files/mobile_mailer/no-from.eml')).read)
|
462
462
|
end
|
463
463
|
|
464
464
|
it 'mobile should be nil' do
|
data/spec/unit/util_spec.rb
CHANGED
@@ -197,10 +197,10 @@ describe Jpmobile::Util do
|
|
197
197
|
hash = invert_table(
|
198
198
|
{
|
199
199
|
[0x1F1E8, 0x1F1F3] => 0x3013,
|
200
|
-
0x1F1FF
|
201
|
-
0x1F526
|
202
|
-
[0x0023, 0x20E3]
|
203
|
-
0x1F354
|
200
|
+
0x1F1FF => 0x3013,
|
201
|
+
0x1F526 => 0xE6FB,
|
202
|
+
[0x0023, 0x20E3] => 0xE6E0,
|
203
|
+
0x1F354 => 0xE673,
|
204
204
|
},
|
205
205
|
)
|
206
206
|
expect(hash[0x3013]).to eq([0x1F1E8, 0x1F1F3])
|
@@ -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/mobile_mailer/photo.jpg')).read
|
6
|
+
attachments.inline['photo.jpg'] = File.open(File.join(Rails.root, 'spec/fixtures/files/mobile_mailer/photo.jpg')).read
|
7
7
|
|
8
8
|
mail(to: to_mail, subject: '題名', decorated: true)
|
9
9
|
end
|
data/test/rails/overrides/db/migrate/20201111033056_create_active_storage_tables.active_storage.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# This migration comes from active_storage (originally 20170806125915)
|
2
|
+
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
3
|
+
def change
|
4
|
+
create_table :active_storage_blobs do |t|
|
5
|
+
t.string :key, null: false
|
6
|
+
t.string :filename, null: false
|
7
|
+
t.string :content_type
|
8
|
+
t.text :metadata
|
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
|
13
|
+
|
14
|
+
t.index [:key], unique: true
|
15
|
+
end
|
16
|
+
|
17
|
+
create_table :active_storage_attachments do |t|
|
18
|
+
t.string :name, null: false
|
19
|
+
t.references :record, null: false, polymorphic: true, index: false
|
20
|
+
t.references :blob, null: false
|
21
|
+
|
22
|
+
t.datetime :created_at, null: false
|
23
|
+
|
24
|
+
t.index [:record_type, :record_id, :name, :blob_id], name: 'index_active_storage_attachments_uniqueness', unique: true
|
25
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
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
|
35
|
+
end
|
36
|
+
end
|
data/test/rails/overrides/db/migrate/20201111033057_create_action_mailbox_tables.action_mailbox.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# This migration comes from action_mailbox (originally 20180917164000)
|
2
|
+
class CreateActionMailboxTables < ActiveRecord::Migration[6.0]
|
3
|
+
def change
|
4
|
+
create_table :action_mailbox_inbound_emails do |t|
|
5
|
+
t.integer :status, default: 0, null: false
|
6
|
+
t.string :message_id, null: false
|
7
|
+
t.string :message_checksum, null: false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
|
11
|
+
t.index [:message_id, :message_checksum], name: 'index_action_mailbox_inbound_emails_uniqueness', unique: true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-attached.eml
RENAMED
File without changes
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-decomail.eml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/bounced-jp.eml
RENAMED
File without changes
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-emoji.eml
RENAMED
File without changes
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-gmail-sjis.eml
RENAMED
File without changes
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-jis.eml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-blank.eml
RENAMED
File without changes
|
File without changes
|
data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-emoji.eml
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,265 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
require 'action_mailbox/test_helper'
|
3
|
+
|
4
|
+
describe MobileMailerMailbox, type: :mailbox do
|
5
|
+
include ActionMailbox::TestHelper
|
6
|
+
|
7
|
+
describe 'blank mail' do
|
8
|
+
it 'softbank からの空メールがで受信できること' do
|
9
|
+
expect {
|
10
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/softbank-blank.eml')
|
11
|
+
|
12
|
+
expect(inbound_email.mail.subject).to be_blank
|
13
|
+
expect(inbound_email.mail.body).to be_blank
|
14
|
+
}.to_not raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'docomo からのメールを受信するとき' do
|
19
|
+
it '漢字コードを適切に変換できること' do
|
20
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/docomo-emoji.eml')
|
21
|
+
|
22
|
+
expect(inbound_email.mail.subject).to match(/題名/)
|
23
|
+
expect(inbound_email.mail.body).to match(/本文/)
|
24
|
+
end
|
25
|
+
|
26
|
+
it '絵文字が数値参照に変わること' do
|
27
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/docomo-emoji.eml')
|
28
|
+
|
29
|
+
expect(inbound_email.mail.subject).to match(//)
|
30
|
+
expect(inbound_email.mail.body).to match(//)
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'jis コードの場合に' do
|
34
|
+
it '適切に変換できること' do
|
35
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/docomo-jis.eml')
|
36
|
+
|
37
|
+
expect(inbound_email.mail.subject).to match(/テスト/)
|
38
|
+
expect(inbound_email.mail.body).to match(/テスト本文/)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'au からのメールを受信するとき' do
|
44
|
+
describe 'jpmobile で送信したメールの場合' do
|
45
|
+
it '漢字コードを適切に変換できること' do
|
46
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/au-emoji.eml')
|
47
|
+
|
48
|
+
expect(inbound_email.mail.subject).to match(/題名/)
|
49
|
+
expect(inbound_email.mail.body).to match(/本文/)
|
50
|
+
end
|
51
|
+
|
52
|
+
it '絵文字が数値参照に変わること' do
|
53
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/au-emoji.eml')
|
54
|
+
|
55
|
+
expect(inbound_email.mail.subject).to match(//)
|
56
|
+
expect(inbound_email.mail.body).to match(//)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '実機からのメールの場合' do
|
61
|
+
it '漢字コードを適切に変換できること' do
|
62
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/au-emoji2.eml')
|
63
|
+
|
64
|
+
expect(inbound_email.mail.subject).to match(/題名/)
|
65
|
+
expect(inbound_email.mail.body).to match(/本文/)
|
66
|
+
end
|
67
|
+
|
68
|
+
it '絵文字が数値参照に変わること' do
|
69
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/au-emoji2.eml')
|
70
|
+
|
71
|
+
expect(inbound_email.mail.subject).to match(//)
|
72
|
+
expect(inbound_email.mail.body).to match(//)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'softbank からのメールを受信するとき' do
|
78
|
+
describe 'shift_jis のとき' do
|
79
|
+
it '漢字コードを適切に変換できること' do
|
80
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/softbank-emoji.eml')
|
81
|
+
|
82
|
+
expect(inbound_email.mail.subject).to match(/題名/)
|
83
|
+
expect(inbound_email.mail.body).to match(/本文/)
|
84
|
+
end
|
85
|
+
|
86
|
+
it '絵文字が数値参照に変わること' do
|
87
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/softbank-emoji.eml')
|
88
|
+
|
89
|
+
expect(inbound_email.mail.subject).to match(//)
|
90
|
+
expect(inbound_email.mail.body).to match(//)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'utf-8 のとき' do
|
95
|
+
it '漢字コードを適切に変換できること' do
|
96
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/softbank-emoji.eml')
|
97
|
+
|
98
|
+
expect(inbound_email.mail.subject).to match(/題名/)
|
99
|
+
expect(inbound_email.mail.body).to match(/本文/)
|
100
|
+
end
|
101
|
+
|
102
|
+
it '絵文字が数値参照に変わること' do
|
103
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/softbank-emoji-utf8.eml')
|
104
|
+
|
105
|
+
expect(inbound_email.mail.subject).to match(//)
|
106
|
+
expect(inbound_email.mail.body).to match(//)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'multipart メールを受信するとき' do
|
112
|
+
describe 'docomo の場合' do
|
113
|
+
# NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
|
114
|
+
it '正常に受信できること' do
|
115
|
+
expect {
|
116
|
+
receive_inbound_email_from_fixture('mobile_mailer/docomo-gmail-sjis.eml')
|
117
|
+
}.not_to raise_exception
|
118
|
+
end
|
119
|
+
|
120
|
+
it '絵文字が変換されること' do
|
121
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/docomo-gmail-sjis.eml')
|
122
|
+
|
123
|
+
expect(inbound_email.mail.subject).to match(//)
|
124
|
+
|
125
|
+
expect(inbound_email.mail.parts.size).to eq(1)
|
126
|
+
expect(inbound_email.mail.parts.first.parts.size).to eq(2)
|
127
|
+
|
128
|
+
parts = inbound_email.mail.parts.first.parts
|
129
|
+
expect(parts.first.body).to match('テストです')
|
130
|
+
expect(parts.last.body.raw_source).to match('テストです')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe 'au の場合' do
|
135
|
+
it '正常に受信できること' do
|
136
|
+
expect {
|
137
|
+
receive_inbound_email_from_fixture('mobile_mailer/au-decomail.eml')
|
138
|
+
}.not_to raise_exception
|
139
|
+
end
|
140
|
+
|
141
|
+
it '絵文字が変換されること' do
|
142
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/au-decomail.eml')
|
143
|
+
|
144
|
+
expect(inbound_email.mail.subject).to match(//)
|
145
|
+
|
146
|
+
expect(inbound_email.mail.parts.size).to eq(1)
|
147
|
+
expect(inbound_email.mail.parts.first.parts.size).to eq(2)
|
148
|
+
|
149
|
+
parts = inbound_email.mail.parts.first.parts
|
150
|
+
expect(parts.first.body).to match(/テストです/)
|
151
|
+
expect(parts.last.body.raw_source).to match(/テストです/)
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'iPhone' do
|
155
|
+
it 'should parse correctly' do
|
156
|
+
expect {
|
157
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/iphone-message.eml')
|
158
|
+
inbound_email.mail.encoded
|
159
|
+
}.not_to raise_error
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe 'softbank(sjis) の場合' do
|
165
|
+
# NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
|
166
|
+
it '正常に受信できること' do
|
167
|
+
expect {
|
168
|
+
receive_inbound_email_from_fixture('mobile_mailer/softbank-gmail-sjis.eml')
|
169
|
+
}.not_to raise_exception
|
170
|
+
end
|
171
|
+
|
172
|
+
it '絵文字が変換されること' do
|
173
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/softbank-gmail-sjis.eml')
|
174
|
+
|
175
|
+
expect(inbound_email.mail.subject).to match(//)
|
176
|
+
|
177
|
+
expect(inbound_email.mail.parts.size).to eq(2)
|
178
|
+
|
179
|
+
expect(inbound_email.mail.parts.first.body).to match(/テストです/)
|
180
|
+
expect(inbound_email.mail.parts.last.body.raw_source).to match(/テストです/)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe 'softbank(utf8) の場合' do
|
185
|
+
# NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
|
186
|
+
it '正常に受信できること' do
|
187
|
+
expect {
|
188
|
+
receive_inbound_email_from_fixture('mobile_mailer/softbank-gmail-utf8.eml')
|
189
|
+
}.not_to raise_exception
|
190
|
+
end
|
191
|
+
|
192
|
+
it '絵文字が変換されること' do
|
193
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/softbank-gmail-utf8.eml')
|
194
|
+
|
195
|
+
expect(inbound_email.mail.subject).to match(/テストです/)
|
196
|
+
|
197
|
+
expect(inbound_email.mail.parts.size).to eq(2)
|
198
|
+
|
199
|
+
expect(inbound_email.mail.parts.first.body).to match(/テストです/)
|
200
|
+
expect(inbound_email.mail.parts.last.body.raw_source).to match(/テストです/)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe '添付ファイルがある場合' do
|
205
|
+
# NOTE: au のみテスト
|
206
|
+
it '正常に受信できること' do
|
207
|
+
expect {
|
208
|
+
receive_inbound_email_from_fixture('mobile_mailer/au-attached.eml')
|
209
|
+
}.not_to raise_exception
|
210
|
+
end
|
211
|
+
|
212
|
+
it '添付ファイルが壊れないこと' do
|
213
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/au-attached.eml')
|
214
|
+
|
215
|
+
expect(inbound_email.mail.subject).to match(//)
|
216
|
+
|
217
|
+
expect(inbound_email.mail.parts.size).to eq(2)
|
218
|
+
|
219
|
+
expect(inbound_email.mail.parts.first.body).to match(/カレンダーだ/)
|
220
|
+
|
221
|
+
expect(inbound_email.mail.has_attachments?).to be_truthy
|
222
|
+
expect(inbound_email.mail.attachments.size).to eq(1)
|
223
|
+
expect(inbound_email.mail.attachments['20098calendar01.jpg'].content_type).to match('image/jpeg')
|
224
|
+
expect(inbound_email.mail.attachments['20098calendar01.jpg'].body.to_s.size).to eq(86412)
|
225
|
+
expect(inbound_email.mail.attachments['20098calendar01.jpg'].body.to_s[6..9]).to eq('JFIF')
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
describe 'PCからメールを受信するとき' do
|
231
|
+
describe '日本語ではない場合' do
|
232
|
+
before(:each) do
|
233
|
+
@email = file_fixture('mobile_mailer/non-jp.eml').read
|
234
|
+
end
|
235
|
+
|
236
|
+
it '正常に受信できること' do
|
237
|
+
expect {
|
238
|
+
receive_inbound_email_from_fixture('mobile_mailer/non-jp.eml')
|
239
|
+
}.not_to raise_exception
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'mobile が nil であること' do
|
243
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/non-jp.eml')
|
244
|
+
expect(inbound_email.mail.mobile).to be_nil
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe 'From がない場合' do
|
249
|
+
before(:each) do
|
250
|
+
@email = file_fixture('mobile_mailer/no-from.eml').read
|
251
|
+
end
|
252
|
+
|
253
|
+
it '正常に受信できること' do
|
254
|
+
expect {
|
255
|
+
receive_inbound_email_from_fixture('mobile_mailer/no-from.eml')
|
256
|
+
}.not_to raise_exception
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'mobile が nil であること' do
|
260
|
+
inbound_email = receive_inbound_email_from_fixture('mobile_mailer/no-from.eml')
|
261
|
+
expect(inbound_email.mail.mobile).to be_nil
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|