Sha256: 73759b2ef3465942d33848d1069882268346a378d0841af7f2cc233949d6e47d

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path '../helper', __FILE__

require 'airbrake/rails/controller_methods'

class TestController
  include Airbrake::Rails::ControllerMethods

  def current_user
    nil
  end
end

class NoSessionTestController
  include Airbrake::Rails::ControllerMethods

  def session
    nil
  end
end



class ControllerMethodsTest < Test::Unit::TestCase
  context "#airbrake_current_user" do
    setup do

      NilClass.class_eval do
        @@called = false

        def self.called
          !! @@called
        end

        def id
          @@called = true
        end
      end

      @controller = TestController.new
    end

    should "not call #id on NilClass" do
      @controller.send(:airbrake_current_user)
      assert_equal false, NilClass.called
    end
  end

  context '#airbrake_session_data' do
    setup do
      @controller = NoSessionTestController.new
    end
    should 'not call session if no session' do
      no_session = @controller.send(:airbrake_session_data)
      assert_equal no_session, {:session => 'no session found'}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
airbrake-3.1.16 test/controller_methods_test.rb
airbrake-3.1.15 test/controller_methods_test.rb
airbrake-3.1.14 test/controller_methods_test.rb