diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-25 12:43:59 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-25 12:43:59 +0900 |
commit | c7dfe33f3958295a857d7bfb1070302e5b7429ff (patch) | |
tree | 893eb97d975eaf335efcccecd19cac2c48278365 /activerecord/test | |
parent | f1a30d8ad5ae17e6202fd3a126027378773dcaea (diff) | |
parent | 226116a44010f4da857f6b26d73bec2618dea890 (diff) | |
download | rails-c7dfe33f3958295a857d7bfb1070302e5b7429ff.tar.gz rails-c7dfe33f3958295a857d7bfb1070302e5b7429ff.tar.bz2 rails-c7dfe33f3958295a857d7bfb1070302e5b7429ff.zip |
Merge pull request #31751 from yoreek/clear_transaction_state_when_ar_object_is_duped
Clear the transaction state when AR object is duped
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/dup_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/dup_test.rb b/activerecord/test/cases/dup_test.rb index 73da31996e..59c3331595 100644 --- a/activerecord/test/cases/dup_test.rb +++ b/activerecord/test/cases/dup_test.rb @@ -3,6 +3,7 @@ require "cases/helper" require "models/reply" require "models/topic" +require "models/movie" module ActiveRecord class DupTest < ActiveRecord::TestCase @@ -157,5 +158,20 @@ module ActiveRecord record.dup end end + + def test_dup_record_not_persisted_after_rollback_transaction + movie = Movie.new(name: "test") + + assert_raises(ActiveRecord::RecordInvalid) do + Movie.transaction do + movie.save! + duped = movie.dup + duped.name = nil + duped.save! + end + end + + assert !movie.persisted? + end end end |