Sha256: 3e89cc481eb7be818fedab1e6a415b04391c6b595e2c931c5d2b31782caabb72
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require "#{File.dirname(__FILE__)}/../helper" Mysqlplus::Test.prepare! class MacroTest < ActiveSupport::TestCase def teardown ActiveRecord::Base.clear_all_connections! ActiveRecord::Base.establish_connection( Mysqlplus::Test::CONNECTION_SPEC ) super end test "should be able to find records in a background thread" do ActiveRecord::Base.connection_pool.expects(:release_connection).twice assert_equal MysqlUser.find(:first, :defer => true), MysqlUser.find(:first) assert_instance_of MysqlUser, MysqlUser.find(:first, :defer => true) end test "should be able to find records by sql background thread" do ActiveRecord::Base.connection_pool.expects(:release_connection).once assert_equal MysqlUser.find_by_sql("SELECT * FROM mysql.user WHERE User = 'root'", true), MysqlUser.find(:all, :conditions => ['user.User = ?', 'root']) end test "should be able to preload related records on multiple connections" do ActiveRecord::Base.connection_pool.expects(:release_connection).twice assert_instance_of MysqlUser, MysqlUser.find( :first, :defer => true, :include => :mysql_user_info) sleep(0.5) end end Thread.list.each{|t| t.join unless t == Thread.main }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
methodmissing-mysqlplus_adapter-1.0.3 | test/deferrable/macro_test.rb |
methodmissing-mysqlplus_adapter-1.0.4 | test/deferrable/macro_test.rb |