aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/dirty_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/dirty_test.rb')
-rw-r--r--activerecord/test/cases/dirty_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index 14c4e3cbd4..d1a7366f5f 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -736,6 +736,25 @@ class DirtyTest < ActiveRecord::TestCase
assert record.save
end
+ test "virtual attributes are not written with partial_writes off" do
+ original_partial_writes = ActiveRecord::Base.partial_writes
+ begin
+ ActiveRecord::Base.partial_writes = false
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = "people"
+ attribute :non_persisted_attribute, :string
+ end
+
+ record = klass.new(first_name: "Sean")
+ record.non_persisted_attribute_will_change!
+
+ assert_predicate record, :non_persisted_attribute_changed?
+ assert record.save
+ ensure
+ ActiveRecord::Base.partial_writes = original_partial_writes
+ end
+ end
+
test "mutating and then assigning doesn't remove the change" do
pirate = Pirate.create!(catchphrase: "arrrr")
pirate.catchphrase << " matey!"