jpmobile 5.2.5 → 6.0.0.beta
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 +1 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +111 -93
- data/jpmobile.gemspec +1 -1
- data/lib/jpmobile/hook_action_view.rb +4 -10
- data/lib/jpmobile/rails.rb +2 -0
- data/lib/jpmobile/resolver.rb +2 -36
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +2 -2
- data/spec/unit/receive_mail_spec.rb +9 -9
- data/test/rails/overrides/Gemfile.jpmobile +6 -1
- 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/20190419005447_create_active_storage_tables.active_storage.rb +27 -0
- data/test/rails/overrides/db/migrate/20190419005448_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/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
- metadata +53 -44
| @@ -11,6 +11,11 @@ gem 'pry-byebug' | |
| 11 11 |  | 
| 12 12 | 
             
            # Bundle gems for certain environments:
         | 
| 13 13 | 
             
            group :development, :test do
         | 
| 14 | 
            -
              gem  | 
| 14 | 
            +
              gem 'rspec', github: 'rspec/rspec'
         | 
| 15 | 
            +
              gem 'rspec-core', github: 'rspec/rspec-core'
         | 
| 16 | 
            +
              gem 'rspec-mocks', github: 'rspec/rspec-mocks'
         | 
| 17 | 
            +
              gem "rspec-expectations", github: 'rspec/rspec-expectations'
         | 
| 18 | 
            +
              gem "rspec-support", github: 'rspec/rspec-support'
         | 
| 19 | 
            +
              gem "rspec-rails", github: 'rspec/rspec-rails', branch: '4-0-dev'
         | 
| 15 20 | 
             
              gem 'rails-controller-testing'
         | 
| 16 21 | 
             
            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/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/20190419005447_create_active_storage_tables.active_storage.rb
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 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.bigint   :byte_size,  null: false
         | 
| 10 | 
            +
                  t.string   :checksum,   null: false
         | 
| 11 | 
            +
                  t.datetime :created_at, null: false
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  t.index [ :key ], unique: true
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                create_table :active_storage_attachments do |t|
         | 
| 17 | 
            +
                  t.string     :name,     null: false
         | 
| 18 | 
            +
                  t.references :record,   null: false, polymorphic: true, index: false
         | 
| 19 | 
            +
                  t.references :blob,     null: false
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  t.datetime :created_at, null: false
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
         | 
| 24 | 
            +
                  t.foreign_key :active_storage_blobs, column: :blob_id
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/test/rails/overrides/db/migrate/20190419005448_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
         | 
| @@ -498,308 +498,3 @@ describe MobileMailer, ' mail address', type: :mailer do | |
| 498 498 | 
             
                expect(emails.first.destinations).to eq(to)
         | 
| 499 499 | 
             
              end
         | 
| 500 500 | 
             
            end
         | 
| 501 | 
            -
             | 
| 502 | 
            -
            describe MobileMailer, 'receiving', type: :mailer do
         | 
| 503 | 
            -
              describe 'blank mail' do
         | 
| 504 | 
            -
                it 'softbank からの空メールがで受信できること' do
         | 
| 505 | 
            -
                  email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/softbank-blank.eml').read
         | 
| 506 | 
            -
                  expect {
         | 
| 507 | 
            -
                    email = MobileMailer.receive(email)
         | 
| 508 | 
            -
                  }.to_not raise_error
         | 
| 509 | 
            -
             | 
| 510 | 
            -
                  expect(email.subject).to be_blank
         | 
| 511 | 
            -
                  expect(email.body).to be_blank
         | 
| 512 | 
            -
                end
         | 
| 513 | 
            -
              end
         | 
| 514 | 
            -
             | 
| 515 | 
            -
              describe 'docomo からのメールを受信するとき' do
         | 
| 516 | 
            -
                before(:each) do
         | 
| 517 | 
            -
                  @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/docomo-emoji.eml').read
         | 
| 518 | 
            -
                end
         | 
| 519 | 
            -
             | 
| 520 | 
            -
                it '漢字コードを適切に変換できること' do
         | 
| 521 | 
            -
                  email = MobileMailer.receive(@email)
         | 
| 522 | 
            -
                  expect(email.subject).to match(/題名/)
         | 
| 523 | 
            -
                  expect(email.body).to match(/本文/)
         | 
| 524 | 
            -
                end
         | 
| 525 | 
            -
             | 
| 526 | 
            -
                it '絵文字が数値参照に変わること' do
         | 
| 527 | 
            -
                  email = MobileMailer.receive(@email)
         | 
| 528 | 
            -
             | 
| 529 | 
            -
                  expect(email.subject).to match(//)
         | 
| 530 | 
            -
                  expect(email.body).to match(//)
         | 
| 531 | 
            -
                end
         | 
| 532 | 
            -
             | 
| 533 | 
            -
                describe 'jis コードの場合に' do
         | 
| 534 | 
            -
                  before(:each) do
         | 
| 535 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/docomo-jis.eml').read
         | 
| 536 | 
            -
                  end
         | 
| 537 | 
            -
             | 
| 538 | 
            -
                  it '適切に変換できること' do
         | 
| 539 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 540 | 
            -
             | 
| 541 | 
            -
                    expect(email.subject).to match(/テスト/)
         | 
| 542 | 
            -
                    expect(email.body).to match(/テスト本文/)
         | 
| 543 | 
            -
                  end
         | 
| 544 | 
            -
                end
         | 
| 545 | 
            -
              end
         | 
| 546 | 
            -
             | 
| 547 | 
            -
              describe 'au からのメールを受信するとき' do
         | 
| 548 | 
            -
                describe 'jpmobile で送信したメールの場合' do
         | 
| 549 | 
            -
                  before(:each) do
         | 
| 550 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/au-emoji.eml').read
         | 
| 551 | 
            -
                  end
         | 
| 552 | 
            -
             | 
| 553 | 
            -
                  it '漢字コードを適切に変換できること' do
         | 
| 554 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 555 | 
            -
             | 
| 556 | 
            -
                    expect(email.subject).to match(/題名/)
         | 
| 557 | 
            -
                    expect(email.body).to match(/本文/)
         | 
| 558 | 
            -
                  end
         | 
| 559 | 
            -
             | 
| 560 | 
            -
                  it '絵文字が数値参照に変わること' do
         | 
| 561 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 562 | 
            -
             | 
| 563 | 
            -
                    expect(email.subject).to match(//)
         | 
| 564 | 
            -
                    expect(email.body).to match(//)
         | 
| 565 | 
            -
                  end
         | 
| 566 | 
            -
                end
         | 
| 567 | 
            -
             | 
| 568 | 
            -
                describe '実機からのメールの場合' do
         | 
| 569 | 
            -
                  before(:each) do
         | 
| 570 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/au-emoji2.eml').read
         | 
| 571 | 
            -
                  end
         | 
| 572 | 
            -
             | 
| 573 | 
            -
                  it '漢字コードを適切に変換できること' do
         | 
| 574 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 575 | 
            -
             | 
| 576 | 
            -
                    expect(email.subject).to match(/題名/)
         | 
| 577 | 
            -
                    expect(email.body).to match(/本文/)
         | 
| 578 | 
            -
                  end
         | 
| 579 | 
            -
             | 
| 580 | 
            -
                  it '絵文字が数値参照に変わること' do
         | 
| 581 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 582 | 
            -
             | 
| 583 | 
            -
                    expect(email.subject).to match(//)
         | 
| 584 | 
            -
                    expect(email.body).to match(//)
         | 
| 585 | 
            -
                  end
         | 
| 586 | 
            -
                end
         | 
| 587 | 
            -
              end
         | 
| 588 | 
            -
             | 
| 589 | 
            -
              describe 'softbank からのメールを受信するとき' do
         | 
| 590 | 
            -
                describe 'shift_jis のとき' do
         | 
| 591 | 
            -
                  before(:each) do
         | 
| 592 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/softbank-emoji.eml').read
         | 
| 593 | 
            -
                  end
         | 
| 594 | 
            -
             | 
| 595 | 
            -
                  it '漢字コードを適切に変換できること' do
         | 
| 596 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 597 | 
            -
             | 
| 598 | 
            -
                    expect(email.subject).to match(/題名/)
         | 
| 599 | 
            -
                    expect(email.body).to match(/本文/)
         | 
| 600 | 
            -
                  end
         | 
| 601 | 
            -
             | 
| 602 | 
            -
                  it '絵文字が数値参照に変わること' do
         | 
| 603 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 604 | 
            -
             | 
| 605 | 
            -
                    expect(email.subject).to match(//)
         | 
| 606 | 
            -
                    expect(email.body).to match(//)
         | 
| 607 | 
            -
                  end
         | 
| 608 | 
            -
                end
         | 
| 609 | 
            -
             | 
| 610 | 
            -
                describe 'utf-8 のとき' do
         | 
| 611 | 
            -
                  before(:each) do
         | 
| 612 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/softbank-emoji-utf8.eml').read
         | 
| 613 | 
            -
                  end
         | 
| 614 | 
            -
             | 
| 615 | 
            -
                  it '漢字コードを適切に変換できること' do
         | 
| 616 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 617 | 
            -
             | 
| 618 | 
            -
                    expect(email.subject).to match(/題名/)
         | 
| 619 | 
            -
                    expect(email.body).to match(/本文/)
         | 
| 620 | 
            -
                  end
         | 
| 621 | 
            -
             | 
| 622 | 
            -
                  it '絵文字が数値参照に変わること' do
         | 
| 623 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 624 | 
            -
             | 
| 625 | 
            -
                    expect(email.subject).to match(//)
         | 
| 626 | 
            -
                    expect(email.body).to match(//)
         | 
| 627 | 
            -
                  end
         | 
| 628 | 
            -
                end
         | 
| 629 | 
            -
              end
         | 
| 630 | 
            -
             | 
| 631 | 
            -
              describe 'multipart メールを受信するとき' do
         | 
| 632 | 
            -
                describe 'docomo の場合' do
         | 
| 633 | 
            -
                  # NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
         | 
| 634 | 
            -
                  before(:each) do
         | 
| 635 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml').read
         | 
| 636 | 
            -
                  end
         | 
| 637 | 
            -
             | 
| 638 | 
            -
                  it '正常に受信できること' do
         | 
| 639 | 
            -
                    expect {
         | 
| 640 | 
            -
                      MobileMailer.receive(@email)
         | 
| 641 | 
            -
                    }.not_to raise_exception
         | 
| 642 | 
            -
                  end
         | 
| 643 | 
            -
             | 
| 644 | 
            -
                  it '絵文字が変換されること' do
         | 
| 645 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 646 | 
            -
             | 
| 647 | 
            -
                    expect(email.subject).to match(//)
         | 
| 648 | 
            -
             | 
| 649 | 
            -
                    expect(email.parts.size).to eq(1)
         | 
| 650 | 
            -
                    expect(email.parts.first.parts.size).to eq(2)
         | 
| 651 | 
            -
             | 
| 652 | 
            -
                    parts = email.parts.first.parts
         | 
| 653 | 
            -
                    expect(parts.first.body).to match('テストです')
         | 
| 654 | 
            -
                    expect(parts.last.body.raw_source).to match('テストです')
         | 
| 655 | 
            -
                  end
         | 
| 656 | 
            -
                end
         | 
| 657 | 
            -
             | 
| 658 | 
            -
                describe 'au の場合' do
         | 
| 659 | 
            -
                  before(:each) do
         | 
| 660 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/au-decomail.eml').read
         | 
| 661 | 
            -
                  end
         | 
| 662 | 
            -
             | 
| 663 | 
            -
                  it '正常に受信できること' do
         | 
| 664 | 
            -
                    expect {
         | 
| 665 | 
            -
                      MobileMailer.receive(@email)
         | 
| 666 | 
            -
                    }.not_to raise_exception
         | 
| 667 | 
            -
                  end
         | 
| 668 | 
            -
             | 
| 669 | 
            -
                  it '絵文字が変換されること' do
         | 
| 670 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 671 | 
            -
             | 
| 672 | 
            -
                    expect(email.subject).to match(//)
         | 
| 673 | 
            -
             | 
| 674 | 
            -
                    expect(email.parts.size).to eq(1)
         | 
| 675 | 
            -
                    expect(email.parts.first.parts.size).to eq(2)
         | 
| 676 | 
            -
             | 
| 677 | 
            -
                    parts = email.parts.first.parts
         | 
| 678 | 
            -
                    expect(parts.first.body).to match(/テストです/)
         | 
| 679 | 
            -
                    expect(parts.last.body.raw_source).to match(/テストです/)
         | 
| 680 | 
            -
                  end
         | 
| 681 | 
            -
             | 
| 682 | 
            -
                  context 'iPhone' do
         | 
| 683 | 
            -
                    it 'should parse correctly' do
         | 
| 684 | 
            -
                      expect {
         | 
| 685 | 
            -
                        @mail = MobileMailer.receive(File.open(File.join(Rails.root, '../../../spec/unit/email-fixtures/iphone-message.eml')).read)
         | 
| 686 | 
            -
                        @mail.encoded
         | 
| 687 | 
            -
                      }.not_to raise_error
         | 
| 688 | 
            -
                    end
         | 
| 689 | 
            -
                  end
         | 
| 690 | 
            -
                end
         | 
| 691 | 
            -
             | 
| 692 | 
            -
                describe 'softbank(sjis) の場合' do
         | 
| 693 | 
            -
                  # NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
         | 
| 694 | 
            -
                  before(:each) do
         | 
| 695 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml').read
         | 
| 696 | 
            -
                  end
         | 
| 697 | 
            -
             | 
| 698 | 
            -
                  it '正常に受信できること' do
         | 
| 699 | 
            -
                    expect {
         | 
| 700 | 
            -
                      MobileMailer.receive(@email)
         | 
| 701 | 
            -
                    }.not_to raise_exception
         | 
| 702 | 
            -
                  end
         | 
| 703 | 
            -
             | 
| 704 | 
            -
                  it '絵文字が変換されること' do
         | 
| 705 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 706 | 
            -
             | 
| 707 | 
            -
                    expect(email.subject).to match(//)
         | 
| 708 | 
            -
             | 
| 709 | 
            -
                    expect(email.parts.size).to eq(2)
         | 
| 710 | 
            -
             | 
| 711 | 
            -
                    expect(email.parts.first.body).to match(/テストです/)
         | 
| 712 | 
            -
                    expect(email.parts.last.body.raw_source).to match(/テストです/)
         | 
| 713 | 
            -
                  end
         | 
| 714 | 
            -
                end
         | 
| 715 | 
            -
             | 
| 716 | 
            -
                describe 'softbank(utf8) の場合' do
         | 
| 717 | 
            -
                  # NOTE: キャリアメールサーバで絵文字を変換するため検証は困難
         | 
| 718 | 
            -
                  before(:each) do
         | 
| 719 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml').read
         | 
| 720 | 
            -
                  end
         | 
| 721 | 
            -
             | 
| 722 | 
            -
                  it '正常に受信できること' do
         | 
| 723 | 
            -
                    expect {
         | 
| 724 | 
            -
                      MobileMailer.receive(@email)
         | 
| 725 | 
            -
                    }.not_to raise_exception
         | 
| 726 | 
            -
                  end
         | 
| 727 | 
            -
             | 
| 728 | 
            -
                  it '絵文字が変換されること' do
         | 
| 729 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 730 | 
            -
             | 
| 731 | 
            -
                    expect(email.subject).to match(/テストです/)
         | 
| 732 | 
            -
             | 
| 733 | 
            -
                    expect(email.parts.size).to eq(2)
         | 
| 734 | 
            -
             | 
| 735 | 
            -
                    expect(email.parts.first.body).to match(/テストです/)
         | 
| 736 | 
            -
                    expect(email.parts.last.body.raw_source).to match(/テストです/)
         | 
| 737 | 
            -
                  end
         | 
| 738 | 
            -
                end
         | 
| 739 | 
            -
             | 
| 740 | 
            -
                describe '添付ファイルがある場合' do
         | 
| 741 | 
            -
                  # NOTE: au のみテスト
         | 
| 742 | 
            -
                  before(:each) do
         | 
| 743 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/au-attached.eml').read
         | 
| 744 | 
            -
                  end
         | 
| 745 | 
            -
             | 
| 746 | 
            -
                  it '正常に受信できること' do
         | 
| 747 | 
            -
                    expect {
         | 
| 748 | 
            -
                      MobileMailer.receive(@email)
         | 
| 749 | 
            -
                    }.not_to raise_exception
         | 
| 750 | 
            -
                  end
         | 
| 751 | 
            -
             | 
| 752 | 
            -
                  it '添付ファイルが壊れないこと' do
         | 
| 753 | 
            -
                    email = MobileMailer.receive(@email)
         | 
| 754 | 
            -
             | 
| 755 | 
            -
                    expect(email.subject).to match(//)
         | 
| 756 | 
            -
             | 
| 757 | 
            -
                    expect(email.parts.size).to eq(2)
         | 
| 758 | 
            -
             | 
| 759 | 
            -
                    expect(email.parts.first.body).to match(/カレンダーだ/)
         | 
| 760 | 
            -
             | 
| 761 | 
            -
                    expect(email.has_attachments?).to be_truthy
         | 
| 762 | 
            -
                    expect(email.attachments.size).to eq(1)
         | 
| 763 | 
            -
                    expect(email.attachments['20098calendar01.jpg'].content_type).to match('image/jpeg')
         | 
| 764 | 
            -
                    expect(email.attachments['20098calendar01.jpg'].body.to_s.size).to eq(86412)
         | 
| 765 | 
            -
                    expect(email.attachments['20098calendar01.jpg'].body.to_s[6..9]).to eq('JFIF')
         | 
| 766 | 
            -
                  end
         | 
| 767 | 
            -
                end
         | 
| 768 | 
            -
              end
         | 
| 769 | 
            -
             | 
| 770 | 
            -
              describe 'PCからメールを受信するとき' do
         | 
| 771 | 
            -
                describe '日本語ではない場合' do
         | 
| 772 | 
            -
                  before(:each) do
         | 
| 773 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/non-jp.eml').read
         | 
| 774 | 
            -
                  end
         | 
| 775 | 
            -
             | 
| 776 | 
            -
                  it '正常に受信できること' do
         | 
| 777 | 
            -
                    expect {
         | 
| 778 | 
            -
                      MobileMailer.receive(@email)
         | 
| 779 | 
            -
                    }.not_to raise_exception
         | 
| 780 | 
            -
                  end
         | 
| 781 | 
            -
             | 
| 782 | 
            -
                  it 'mobile が nil であること' do
         | 
| 783 | 
            -
                    mail = MobileMailer.receive(@email)
         | 
| 784 | 
            -
                    expect(mail.mobile).to be_nil
         | 
| 785 | 
            -
                  end
         | 
| 786 | 
            -
                end
         | 
| 787 | 
            -
             | 
| 788 | 
            -
                describe 'From がない場合' do
         | 
| 789 | 
            -
                  before(:each) do
         | 
| 790 | 
            -
                    @email = File.open(Rails.root + 'spec/fixtures/mobile_mailer/no-from.eml').read
         | 
| 791 | 
            -
                  end
         | 
| 792 | 
            -
             | 
| 793 | 
            -
                  it '正常に受信できること' do
         | 
| 794 | 
            -
                    expect {
         | 
| 795 | 
            -
                      MobileMailer.receive(@email)
         | 
| 796 | 
            -
                    }.not_to raise_exception
         | 
| 797 | 
            -
                  end
         | 
| 798 | 
            -
             | 
| 799 | 
            -
                  it 'mobile が nil であること' do
         | 
| 800 | 
            -
                    mail = MobileMailer.receive(@email)
         | 
| 801 | 
            -
                    expect(mail.mobile).to be_nil
         | 
| 802 | 
            -
                  end
         | 
| 803 | 
            -
                end
         | 
| 804 | 
            -
              end
         | 
| 805 | 
            -
            end
         |