Sha256: b6528a310ce6eb9aafa211704b96c6266d8f3d01bce364ce8d587fc9b21a2774

Contents?: true

Size: 1.32 KB

Versions: 14

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

describe Spotlight::IndexingCompleteMailer do
  subject { described_class.documents_indexed [1, 2, 3], exhibit, user, indexed_count: 3 }

  let(:user) { double(email: 'test@example.com') }
  let(:exhibit) { double(title: 'Exhibit title') }

  it 'renders the receiver email' do
    expect(subject.to).to eql([user.email])
  end

  it 'includes a title' do
    expect(subject.body.encoded).to match 'Your CSV file has just finished being processed'
  end

  it 'describes how many documents were indexed' do
    expect(subject.body.encoded).to match '3 documents'
  end

  context 'single item' do
    subject { described_class.documents_indexed [1], exhibit, user }

    it 'handles pluralization when only a single item was indexed' do
      expect(subject.body.encoded).to match '1 document has'
    end
  end

  it 'includes the exhibit title' do
    expect(subject.body.encoded).to match exhibit.title
  end

  context 'with errors' do
    subject { described_class.documents_indexed [], exhibit, user, indexed_count: 0, errors: { 1 => ['missing title'], 20 => ['whatever'] } }

    it 'includes some errors' do
      expect(subject.body.encoded).to match 'Errors'
      expect(subject.body.encoded).to match 'Row 1: missing title'
      expect(subject.body.encoded).to match 'Row 20: whatever'
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
blacklight-spotlight-3.4.0 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.3.0 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.2.0 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.1.0 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.3 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.2 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.1 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.0 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.0.rc6 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.0.rc5 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.0.rc4 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.0.rc3 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.0.rc2 spec/mailers/spotlight/indexing_complete_mailer_spec.rb
blacklight-spotlight-3.0.0.rc1 spec/mailers/spotlight/indexing_complete_mailer_spec.rb