Skip to content
Permalink
Browse files
Remove deprecated #set_state from the transaction object
  • Loading branch information
rafaelfranca committed Jan 17, 2019
1 parent 5f3ed87 commit 6c745b0c5152a4437163a67707e02f4464493983
@@ -1,3 +1,7 @@
* Remove deprecated `#set_state` from the transaction object.

*Rafael Mendonça França*

* Remove deprecated `#supports_statement_cache?` from the database adapters.

*Rafael Mendonça França*
@@ -40,24 +40,6 @@ def completed?
committed? || rolledback?
end

def set_state(state)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
The set_state method is deprecated and will be removed in
Rails 6.0. Please use rollback! or commit! to set transaction
state directly.
MSG
case state
when :rolledback
rollback!
when :committed
commit!
when nil
nullify!
else
raise ArgumentError, "Invalid transaction state: #{state}"
end
end

def rollback!
@children.each { |c| c.rollback! }
@state = :rolledback
@@ -884,17 +884,6 @@ def test_transactions_state_from_commit
assert_predicate transaction.state, :committed?
end

def test_set_state_method_is_deprecated
connection = Topic.connection
transaction = ActiveRecord::ConnectionAdapters::TransactionManager.new(connection).begin_transaction

transaction.commit

assert_deprecated do
transaction.state.set_state(:rolledback)
end
end

def test_mark_transaction_state_as_committed
connection = Topic.connection
transaction = ActiveRecord::ConnectionAdapters::TransactionManager.new(connection).begin_transaction

0 comments on commit 6c745b0

Please sign in to comment.