Sha256: 4ce782d3f5fa1721db7e3b05258a123945bc642ac501670fceeff6b3317da4fb

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

describe Timber::Probes::ActiveSupportLogSubscriber::ActiveRecord do
  before(:each) { Timber::Probes::ActiveSupportLogSubscriber.insert! }

  let(:logger_context_class) { Timber::Contexts::Logger }
  let(:active_record_context_class) { Timber::Contexts::SQLQueries::ActiveRecord }
  let(:active_record_specific_context_class) { Timber::Contexts::SQLQueries::ActiveRecordSpecific }

  describe "#sql" do
    context "log level debug" do
      before(:each) do
        @old_level = ::ActiveRecord::Base.logger.level
        ::ActiveRecord::Base.logger.level = Logger::DEBUG
      end

      after(:each) { ::ActiveRecord::Base.logger.level = @old_level }

      it "should set the context" do
        expect(Timber::CurrentContext).to receive(:add).with(kind_of(logger_context_class)).and_yield.once
        expect(Timber::CurrentContext).to receive(:add).with(kind_of(active_record_context_class), kind_of(active_record_specific_context_class)).and_yield.once
        ActiveRecord::Base.connection.execute("select * from users")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 spec/timber/probes/action_controller_log_subscriber/active_record_spec.rb