Sha256: f6b93347c97fcf127943623864dd883ecae594d8cef1c007577ea0af72c680c4

Contents?: true

Size: 1.57 KB

Versions: 18

Compression:

Stored size: 1.57 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
      Errdo.error_name = :errors
      assert_requested :any, /.*slack.*/
    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.error_name = :errors
    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

18 entries across 18 versions & 1 rubygems

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