Sha256: 653f38d44d0efc740ff208c20f0127f240f4124b8c2cc8537bd81083755ca40e

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
require 'logger'

describe "ActiveRecord Extensions" do
  it "reloads connection pools when establishing a new connection" do
    Octoshark.configure(configs)

    spec = ActiveRecord::Base.remove_connection
    ActiveRecord::Base.establish_connection(spec)

    expect(Octoshark.find_connection_pool(:default)).to eq(ActiveRecord::Base.connection_pool)
  end

  it "logs current connection name" do
    io = StringIO.new
    logger = Logger.new(io)

    ActiveRecord::Base.logger = logger

    Octoshark.configure(configs)
    Octoshark.with_connection(:db1) do |connection|
      connection.execute("SELECT 1")
    end

    expect(io.string).to include('[Octoshark: db1]')

    ActiveRecord::Base.logger = nil
  end

  it "logs the connection name for the Octoshark connection only" do
    io = StringIO.new
    logger = Logger.new(io)

    ActiveRecord::Base.logger = logger

    Octoshark.configure(configs)
    Octoshark.with_connection(:db1) do |connection|
      ActiveRecord::Base.connection.execute("SELECT 1")
    end

    expect(io.string).not_to include('[Octoshark: db1]')

    ActiveRecord::Base.logger = nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
octoshark-0.0.9 spec/octoshark/active_record_extensions_spec.rb
octoshark-0.0.8 spec/octoshark/active_record_extensions_spec.rb
octoshark-0.0.7 spec/octoshark/active_record_extensions_spec.rb
octoshark-0.0.6 spec/octoshark/active_record_extensions_spec.rb