Sha256: 34f9fec8eece08361c1b16977864e6d016d0af0127958f63b701abf12ee7c7d4

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require "spec_helper"

describe Timber::Probes::ActionControllerBase do
  describe described_class::InstanceMethods do
    before(:each) do
      class PagesPlainController < ActionController::Base
        layout nil

        def index
          render json: {}
        end

        def method_for_action(action_name)
          action_name
        end
      end

      ::RailsApp.routes.draw do
        get 'pages_plain' => 'pages_plain#index'
      end
    end

    after(:each) do
      Object.send(:remove_const, :PagesPlainController)
    end

    let(:logger_context_class) { Timber::Contexts::Logger }
    let(:rack_request_context_class) { Timber::Contexts::HTTPRequests::Rack }
    let(:request_context_class) { Timber::Contexts::HTTPRequests::ActionControllerSpecific }
    let(:organization_context_class) { Timber::Contexts::Organizations::ActionController }
    let(:user_context_class) { Timber::Contexts::Users::ActionController }
    let(:response_context_class) { Timber::Contexts::HTTPResponses::ActionController }

    describe "#process" do
      it "should set the context" do
        allow(Timber::CurrentContext).to receive(:add).with(kind_of(logger_context_class))
        expect(Timber::CurrentContext).to receive(:add).with(kind_of(rack_request_context_class)).and_yield.once
        expect(Timber::CurrentContext).to receive(:add).with(kind_of(request_context_class), kind_of(organization_context_class), kind_of(user_context_class), kind_of(response_context_class)).and_yield.once
        dispatch_rails_request("/pages_plain")
      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_base_spec.rb