summaryrefslogtreecommitdiff
path: root/spec/mailers/emails/imports_spec.rb
blob: 039113d309804316f76a1f44b506f05511448e40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'spec_helper'
require 'email_spec'

RSpec.describe Emails::Imports, feature_category: :importers do
  include EmailSpec::Matchers

  let(:errors) { { 'gist_id1' => "Title can't be blank", 'gist_id2' => 'Snippet maximum file count exceeded' } }
  let(:user) { build_stubbed(:user) }

  describe '#github_gists_import_errors_email' do
    subject { Notify.github_gists_import_errors_email('user_id', errors) }

    before do
      allow(User).to receive(:find).and_return(user)
    end

    it 'sends success email' do
      expect(subject).to have_subject('GitHub Gists import finished with errors')
      expect(subject).to have_content('GitHub gists that were not imported:')
      expect(subject).to have_content("Gist with id gist_id1 failed due to error: Title can't be blank.")
      expect(subject).to have_content('Gist with id gist_id2 failed due to error: Snippet maximum file count exceeded.')
    end

    it_behaves_like 'appearance header and footer enabled'
    it_behaves_like 'appearance header and footer not enabled'
  end
end