class RR::Committers::NeverCommitter
Starts a transaction but does never commit it. Useful during testing.
Public Class Methods
current_session()
click to toggle source
Returns the last active data session
# File lib/rubyrep/committers/committers.rb, line 115 def self.current_session @@current_session end
current_session=(session)
click to toggle source
Saves the provided database session as class variable. Purpose: the last database session stays available after the NeverCommitter
is destroyed so that also later the transaction rollback can still be executed.
# File lib/rubyrep/committers/committers.rb, line 123 def self.current_session=(session) @@current_session = session end
new(session)
click to toggle source
Refer to DefaultCommitter#initialize for details. Starts new transactions on left and right database connectin of session. Additionally rolls back transactions started in previous NeverCommitter
instances.
Calls superclass method
RR::Committers::DefaultCommitter::new
# File lib/rubyrep/committers/committers.rb, line 142 def initialize(session) super self.class.rollback_current_session self.class.current_session = session session.left.begin_db_transaction session.right.begin_db_transaction end
rollback_current_session()
click to toggle source
Rolls back transactions of current session (if there is one). This would be called e. g. in rspec's after(:each) to ensure that the next test case finds the original test data.
# File lib/rubyrep/committers/committers.rb, line 130 def self.rollback_current_session if self.current_session self.current_session.left.rollback_db_transaction self.current_session.right.rollback_db_transaction self.current_session = nil end end