Sha256: 71526584b9f2405bb1f7f7fd008013367325d97d19670f78fb48094a4962a425

Contents?: true

Size: 1.01 KB

Versions: 160

Compression:

Stored size: 1.01 KB

Contents

module EnvHelpers
  def http_request_env_with_data(args = {})
    with_queue_start = args.delete(:with_queue_start)
    path = args.delete(:path) || "/blog"
    request = Rack::MockRequest.env_for(
      path,
      :params => args[:params] || {
        "controller" => "blog_posts",
        "action" => "show",
        "id" => "1"
      }
    ).merge(
      :controller => "BlogPostsController",
      :action => "show",
      :request_format => "html",
      :request_method => "GET",
      :status => "200",
      :view_runtime => 500,
      :db_runtime => 500,
      :metadata => { :key => "value" }
    ).merge(args)

    # Set default queue value
    if with_queue_start
      request["HTTP_X_QUEUE_START"] = "t=#{(fixed_time * 1_000).to_i}" # in milliseconds
    end

    request
  end

  def background_env_with_data(args = {})
    {
      :class => "BackgroundJob",
      :method => "perform",
      :priority => 1,
      :attempts => 0,
      :queue => "default",
      :queue_start => fixed_time
    }.merge(args)
  end
end

Version data entries

160 entries across 160 versions & 1 rubygems

Version Path
appsignal-4.0.6-java spec/support/helpers/env_helpers.rb
appsignal-4.0.6 spec/support/helpers/env_helpers.rb
appsignal-4.0.5-java spec/support/helpers/env_helpers.rb
appsignal-4.0.5 spec/support/helpers/env_helpers.rb
appsignal-4.0.4-java spec/support/helpers/env_helpers.rb
appsignal-4.0.4 spec/support/helpers/env_helpers.rb
appsignal-4.0.3-java spec/support/helpers/env_helpers.rb
appsignal-4.0.3 spec/support/helpers/env_helpers.rb
appsignal-4.0.2-java spec/support/helpers/env_helpers.rb
appsignal-4.0.2 spec/support/helpers/env_helpers.rb
appsignal-4.0.1-java spec/support/helpers/env_helpers.rb
appsignal-4.0.1 spec/support/helpers/env_helpers.rb
appsignal-4.0.0-java spec/support/helpers/env_helpers.rb
appsignal-4.0.0 spec/support/helpers/env_helpers.rb
appsignal-3.13.1-java spec/support/helpers/env_helpers.rb
appsignal-3.13.1 spec/support/helpers/env_helpers.rb
appsignal-3.13.1.alpha.1-java spec/support/helpers/env_helpers.rb
appsignal-3.13.1.alpha.1 spec/support/helpers/env_helpers.rb
appsignal-4.0.0.beta.2-java spec/support/helpers/env_helpers.rb
appsignal-4.0.0.beta.2 spec/support/helpers/env_helpers.rb