Sha256: d518b42151967649a486faca7ec15c8fbfd98df82607031e347c9012ea51a633

Contents?: true

Size: 1.27 KB

Versions: 32

Compression:

Stored size: 1.27 KB

Contents

describe Imap::Backup::Uploader do
  subject { described_class.new(folder, serializer) }

  let(:folder) do
    instance_double(
      Imap::Backup::Account::Folder, uids: [2, 3], append: 99, name: "foo"
    )
  end
  let(:serializer) do
    instance_double(
      Imap::Backup::Serializer::Mbox,
      uids: [1, 2],
      update_uid: nil
    )
  end
  let(:missing_message) do
    instance_double(Email::Mboxrd::Message, supplied_body: "missing message")
  end
  let(:existing_message) do
    instance_double(Email::Mboxrd::Message, supplied_body: "existing message")
  end

  def message_enumerator
    yield [1, missing_message]
  end

  describe "#run" do
    before do
      allow(serializer).to receive(:each_message).and_return(enum_for(:message_enumerator))
    end

    context "with messages that are missing" do
      it "restores them" do
        expect(folder).to receive(:append).with(missing_message)

        subject.run
      end

      it "updates the local message id" do
        expect(serializer).to receive(:update_uid).with(1, 99)

        subject.run
      end
    end

    context "with messages that are present on server" do
      it "does nothing" do
        expect(folder).to_not receive(:append).with(existing_message)

        subject.run
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
imap-backup-5.2.0 spec/unit/imap/backup/uploader_spec.rb
imap-backup-5.1.0 spec/unit/imap/backup/uploader_spec.rb
imap-backup-5.0.0 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.2.2 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.2.1 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.2.0 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.1.2 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.1.1 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.7 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.6 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.5 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.4 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.3 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.2 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.1 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.0 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.0.rc6 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.0.rc5 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.0.rc4 spec/unit/imap/backup/uploader_spec.rb
imap-backup-4.0.0.rc3 spec/unit/imap/backup/uploader_spec.rb