Sha256: 12ab44b8ec5c7e06a7e250a54192a0f54f50c8f8726fc1e884191b6ce5e73539

Contents?: true

Size: 1.64 KB

Versions: 22

Compression:

Stored size: 1.64 KB

Contents

require 'rails_helper'

describe Kuroko2::Notifications do
  let(:instance) { create(:job_definition_with_instances, name: job_name).job_instances.first }
  let(:definition) { instance.job_definition }
  let(:admins) { definition.admins }
  let(:job_name) { 'My Job' }

  describe 'job_failure' do
    let(:mail) { Kuroko2::Notifications.job_failure(instance) }

    it 'renders the headers' do
      expect(mail.subject).to eq "[CRITICAL] Failed to execute '#{job_name}' on kuroko"
      expect(mail.to).to eq(admins.map(&:email))
      expect(mail.from).to eq(['no-reply@example.com'])
    end

    it 'renders the body' do
      expect(mail.body.encoded).to match("Name: #{job_name}")
    end
  end

  describe 'job_failure' do
    let(:mail) { Kuroko2::Notifications.remind_failure(instance) }

    before {
      instance.error_at = 2.days.ago
    }

    it 'renders the headers' do
      expect(mail.subject).to eq "[WARN] '#{job_name}' is still in ERROR state"
      expect(mail.to).to eq(admins.map(&:email))
      expect(mail.from).to eq(['no-reply@example.com'])
    end

    it 'renders the body' do
      expect(mail.body.encoded).to match("Name: #{job_name}")
    end
  end

  describe 'notify_long_elapsed_time' do
    let(:mail) { Kuroko2::Notifications.notify_long_elapsed_time(instance) }

    it 'renders the headers' do
      expect(mail.subject).to eq "[WARN] The running time is longer than expected '#{definition.name}' on kuroko"
      expect(mail.to).to eq(admins.map(&:email))
      expect(mail.from).to eq(['no-reply@example.com'])
    end

    it 'renders the body' do
      expect(mail.body.encoded).to match("Name: #{job_name}")
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kuroko2-0.8.0 spec/mailers/notifications_spec.rb
kuroko2-0.7.0 spec/mailers/notifications_spec.rb
kuroko2-0.6.0 spec/mailers/notifications_spec.rb
kuroko2-0.5.2 spec/mailers/notifications_spec.rb
kuroko2-0.5.1 spec/mailers/notifications_spec.rb
kuroko2-0.5.0 spec/mailers/notifications_spec.rb
kuroko2-0.4.6 spec/mailers/notifications_spec.rb
kuroko2-0.4.5 spec/mailers/notifications_spec.rb
kuroko2-0.4.4 spec/mailers/notifications_spec.rb
kuroko2-0.4.3 spec/mailers/notifications_spec.rb
kuroko2-0.4.2 spec/mailers/notifications_spec.rb
kuroko2-0.4.1 spec/mailers/notifications_spec.rb
kuroko2-0.4.0 spec/mailers/notifications_spec.rb
kuroko2-0.3.4 spec/mailers/notifications_spec.rb
kuroko2-0.3.3 spec/mailers/notifications_spec.rb
kuroko2-0.3.2 spec/mailers/notifications_spec.rb
kuroko2-0.3.1 spec/mailers/notifications_spec.rb
kuroko2-0.3.0 spec/mailers/notifications_spec.rb
kuroko2-0.2.3 spec/mailers/notifications_spec.rb
kuroko2-0.2.2 spec/mailers/notifications_spec.rb