Sha256: b28ab9c8f60f3533ba1f3e52ba4042f8381ab0916556ceb9212a8369710a5c80

Contents?: true

Size: 839 Bytes

Versions: 3

Compression:

Stored size: 839 Bytes

Contents

require 'spec_helper'
require 'logger'

describe ActiveRecord::LogSubscriber do

  describe 'logging' do

    let(:log) { StringIO.new }
    let(:logger) { Logger.new(log) }

    before do
      ActiveRecord::Base.logger = logger
      @backup_disabled = Standby.disabled
    end

    after do
      Standby.disabled = @backup_disabled
    end

    it 'it prefixes log messages with primary' do
      User.count
      log.rewind
      expect(log.read).to include('[primary]')
    end

    it 'it prefixes log messages with the standby connection' do
      User.on_standby.count
      log.rewind
      expect(log.read).to include('[standby]')
    end

    it 'it does nothing when standby is disabled' do
      Standby.disabled = true
      User.count
      log.rewind
      expect(log.read).to_not include('[primary]')
    end

  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
standby-5.0.0 spec/active_record/log_subscriber_spec.rb
slavery-4.0.0 spec/active_record/log_subscriber_spec.rb
standby-4.0.0 spec/active_record/log_subscriber_spec.rb