Sha256: 80fd0c646e5f83af0f8021e8af2654d8cef5a6c645a667986bc43daef9863d57

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

require "#{File.dirname(__FILE__)}/../helper"

Mysqlplus::Test.prepare!

class ResultTest < ActiveSupport::TestCase
  
  def teardown
    ActiveRecord::Base.clear_all_connections!
    ActiveRecord::Base.establish_connection( Mysqlplus::Test::CONNECTION_SPEC )
    super
  end
  
  test "should be able to raise exceptions from the background Thread" do
    assert_raises( StandardError ) do
      ActiveRecord::Deferrable::Result.new do
        raise StandardError
      end.to_s
    end  
  end 
  
  test "should release the checked out connection for the background Thread at all times" do
    ActiveRecord::Base.connection_pool.expects(:release_connection).once
    ActiveRecord::Deferrable::Result.new do
      raise StandardError
    end
  end
  
  test "should only block when an immediate result is required" do
    ActiveRecord::Deferrable::Result.any_instance.expects(:validate!).never
    ActiveRecord::Deferrable::Result.new do
      sleep(5)
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
methodmissing-mysqlplus_adapter-1.0.3 test/deferrable/result_test.rb
methodmissing-mysqlplus_adapter-1.0.4 test/deferrable/result_test.rb