Sha256: 31a80ed3fb73925699f7f989c055dc4eb5325423ce553740e9be8a179f9c6c55

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

require 'test_helper'

FAILSAFE_FAIL_STRING = "If you are the administrator of this website, then please read this web application's \
                        log file and/or the web server's log file to find out what went wrong.".freeze

class PluginsIntegrationTest < ActionDispatch::IntegrationTest

  setup do
    Errdo.notify_with slack: { webhook: "https://slack.com/test" }
  end

  context "slack integration" do
    should "send a slack notification when error is hit" do
      stub_request :any, /.*slack.*/
      get static_generic_error_path
      assert_requested :any, /.*slack.*/
    end

    should "not send a slack notification when error is hit if webhook is not set" do
      Errdo.instance_variable_set(:@notifiers, [])
      stub_request :any, /.*slack.*/
      get static_generic_error_path
      assert_not_requested :any, /.*slack.*/
    end

    should "correctly send a notification when there is no database stored error" do
      Errdo.error_name = nil
      stub_request :any, /.*slack.*/
      get static_generic_error_path
      assert_requested :any, /.*slack.*/
      Errdo.error_name = :errors
    end

    should "not fail when the slack ping returns an error" do
      stub_request(:any, /.*slack.*/).to_raise(StandardError)
      get static_generic_error_path
      assert_not response.body.include? FAILSAFE_FAIL_STRING
    end
  end

  teardown do
    Errdo.instance_variable_set(:@notifiers, [])
  end

  private

  def _sign_in(user)
    post user_session_path, 'user[email]' => user.email, 'user[password]' => 'foobar'
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
errdo-0.11.3 test/integrations/plugins_integration_test.rb
errdo-0.11.2 test/integrations/plugins_integration_test.rb
errdo-0.11.1 test/integrations/plugins_integration_test.rb
errdo-0.11.0 test/integrations/plugins_integration_test.rb
errdo-0.10.0 test/integrations/plugins_integration_test.rb