Skip to content

Commit

Permalink
Remove deprecated #set_state from the transaction object
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Jan 17, 2019
1 parent 5f3ed87 commit 6c745b0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
@@ -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. * Remove deprecated `#supports_statement_cache?` from the database adapters.


*Rafael Mendonça França* *Rafael Mendonça França*
Expand Down
Expand Up @@ -40,24 +40,6 @@ def completed?
committed? || rolledback? committed? || rolledback?
end 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! def rollback!
@children.each { |c| c.rollback! } @children.each { |c| c.rollback! }
@state = :rolledback @state = :rolledback
Expand Down
11 changes: 0 additions & 11 deletions activerecord/test/cases/transactions_test.rb
Expand Up @@ -884,17 +884,6 @@ def test_transactions_state_from_commit
assert_predicate transaction.state, :committed? assert_predicate transaction.state, :committed?
end 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 def test_mark_transaction_state_as_committed
connection = Topic.connection connection = Topic.connection
transaction = ActiveRecord::ConnectionAdapters::TransactionManager.new(connection).begin_transaction transaction = ActiveRecord::ConnectionAdapters::TransactionManager.new(connection).begin_transaction
Expand Down

0 comments on commit 6c745b0

Please sign in to comment.