class TransactionalFixturesOnConnectionNotification
Public Instance Methods
begin_transaction(*args)
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 704 def begin_transaction(*args); end
lock_thread=(lock_thread)
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 710 def lock_thread=(lock_thread); false; end
rollback_transaction(*args)
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 705 def rollback_transaction(*args) @rollback_transaction_called = true end
test_notification_established_transactions_are_rolled_back()
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 698 def test_notification_established_transactions_are_rolled_back # Mocha is not thread-safe so define our own stub to test connection = Class.new do attr_accessor :rollback_transaction_called attr_accessor :pool def transaction_open?; true; end def begin_transaction(*args); end def rollback_transaction(*args) @rollback_transaction_called = true end end.new connection.pool = Class.new do def lock_thread=(lock_thread); false; end end.new fire_connection_notification(connection) teardown_fixtures assert(connection.rollback_transaction_called, "Expected <mock connection>#rollback_transaction to be called but was not") end
test_transaction_created_on_connection_notification()
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 690 def test_transaction_created_on_connection_notification connection = stub(transaction_open?: false) connection.expects(:begin_transaction).with(joinable: false) pool = connection.stubs(:pool).returns(ActiveRecord::ConnectionAdapters::ConnectionPool.new(ActiveRecord::Base.connection_pool.spec)) pool.stubs(:lock_thread=).with(false) fire_connection_notification(connection) end
transaction_open?()
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 703 def transaction_open?; true; end
Private Instance Methods
fire_connection_notification(connection)
click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 719 def fire_connection_notification(connection) ActiveRecord::Base.connection_handler.stubs(:retrieve_connection).with("book").returns(connection) message_bus = ActiveSupport::Notifications.instrumenter payload = { spec_name: "book", config: nil, connection_id: connection.object_id } message_bus.instrument("!connection.active_record", payload) {} end