Sha256: 6310f26997bad9aaf9aca7ad327f04ad02f549311ecd570ee4950043431e4ab2

Contents?: true

Size: 1.55 KB

Versions: 9

Compression:

Stored size: 1.55 KB

Contents

module NotifierHelpers
  def reconfigure_notifier
    Rollbar.clear_notifier!

    Rollbar.reconfigure do |config|
      # special test access token
      config.access_token = test_access_token
      config.logger = ::Rails.logger
      config.root = ::Rails.root
      config.framework = "Rails: #{::Rails::VERSION::STRING}"
      config.open_timeout = 60
      config.request_timeout = 60
    end
  end

  def preconfigure_rails_notifier
    rails_logger = if defined?(::Rails.logger)
                     ::Rails.logger
                   elsif defined?(RAILS_DEFAULT_LOGGER)
                     RAILS_DEFAULT_LOGGER
                   end

    Rollbar.preconfigure do |config|
      config.logger = rails_logger
      config.environment = defined?(::Rails.env) && ::Rails.env || defined?(RAILS_ENV) && RAILS_ENV
      config.root = defined?(::Rails.root) && ::Rails.root || defined?(RAILS_ROOT) && RAILS_ROOT
      config.framework = defined?(::Rails.version) && "Rails: #{::Rails.version}" || defined?(::Rails::VERSION::STRING) && "Rails: #{::Rails::VERSION::STRING}"
    end
  end

  def test_access_token
    'bfec94a1ede64984b862880224edd0ed'
  end

  def reset_configuration
    Rollbar.reconfigure do |config|
    end
  end

  def clear_proxy_env_vars
    env_vars = {}
    proxy_env_vars.each do |var|
      env_vars[var] = ENV.delete(var)
    end
    env_vars
  end

  def restore_proxy_env_vars(env_vars)
    proxy_env_vars.each do |var|
      ENV[var] = env_vars[var]
    end
  end

  def proxy_env_vars
    %w[http_proxy HTTP_PROXY https_proxy HTTPS_PROXY]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rollbar-2.18.2 spec/support/notifier_helpers.rb
rollbar-2.18.0 spec/support/notifier_helpers.rb
rollbar-2.17.0 spec/support/notifier_helpers.rb
rollbar-2.16.4 spec/support/notifier_helpers.rb
rollbar-2.16.3 spec/support/notifier_helpers.rb
rollbar-2.16.2 spec/support/notifier_helpers.rb
rollbar-2.16.0 spec/support/notifier_helpers.rb
rollbar-2.15.6 spec/support/notifier_helpers.rb
rollbar-2.15.5 spec/support/notifier_helpers.rb