Sha256: 119898bb9cce5fe5c881a5d3b7b8d5ba4ac33eeb4ceaf6d9cdf6e8a40058c11d

Contents?: true

Size: 1.71 KB

Versions: 19

Compression:

Stored size: 1.71 KB

Contents

require 'test_helper'


if defined?(ActiveJob::Base)
  class FailJob < ActiveJob::Base

    queue_as :default

    def perform(*_args)
      raise "AsynchronousFailure"
    end

  end
end

class NonWebTest < ActionDispatch::IntegrationTest

  # rubocop:disable Style/RescueModifier
  # rubocop:disable Lint/HandleExceptions
  context "rake tasks" do
    setup do
      load "#{Rails.root}/lib/tasks/test.rake"
    end

    teardown do
      Rake.application['test:error'].reenable
      Rake.application['test:interrupt'].reenable
    end

    should "create an error when a task fails" do
      Errdo.log_task_exceptions = true
      assert_difference 'Errdo::ErrorOccurrence.count', 1 do
        Rake.application['test:error'].invoke rescue ""
      end
    end

    should "not create an error when a task fails with an interrupt" do
      Errdo.log_task_exceptions = true
      load "#{Rails.root}/lib/tasks/test.rake"
      assert_difference 'Errdo::ErrorOccurrence.count', 0 do
        begin
          Rake.application['test:interrupt'].invoke
        rescue Interrupt
        end
      end
    end

    should "create not an error when a task fails when not set" do
      Errdo.log_task_exceptions = false
      assert_difference 'Errdo::ErrorOccurrence.count', 0 do
        Rake.application['test:error'].invoke rescue ""
      end
    end
  end
  # rubocop:enable Style/RescueModifier
  # rubocop:enable Lint/HandleExceptions

  if defined?(ActiveJob::Base)
    context "active jobs" do
      should "log to errdo when job fails asynchronously" do
        assert_difference 'Errdo::ErrorOccurrence.count', 1 do
          # rubocop:disable Style/RescueModifier
          FailJob.perform_now rescue ""
        end
      end
    end
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
errdo-0.12.14 test/integrations/non_web_test.rb
errdo-0.12.13 test/integrations/non_web_test.rb
errdo-0.12.12 test/integrations/non_web_test.rb
errdo-0.12.11 test/integrations/non_web_test.rb
errdo-0.12.10 test/integrations/non_web_test.rb
errdo-0.12.9 test/integrations/non_web_test.rb
errdo-0.12.8 test/integrations/non_web_test.rb
errdo-0.12.7 test/integrations/non_web_test.rb
errdo-0.12.6 test/integrations/non_web_test.rb
errdo-0.12.5 test/integrations/non_web_test.rb
errdo-0.12.4 test/integrations/non_web_test.rb
errdo-0.12.3 test/integrations/non_web_test.rb
errdo-0.12.2 test/integrations/non_web_test.rb
errdo-0.12.1 test/integrations/non_web_test.rb
errdo-0.12.0 test/integrations/non_web_test.rb
errdo-0.11.6 test/integrations/non_web_test.rb
errdo-0.11.5 test/integrations/non_web_test.rb
errdo-0.11.4 test/integrations/non_web_test.rb
errdo-0.11.3 test/integrations/non_web_test.rb