aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attribute_methods_test.rb
diff options
context:
space:
mode:
authorGannon McGibbon <gannon.mcgibbon@gmail.com>2018-11-29 14:43:38 -0500
committerGannon McGibbon <gannon.mcgibbon@gmail.com>2018-11-29 14:49:17 -0500
commit72e63c71bb3f73870e280964def25b7578818b1b (patch)
treeeb8c7b4225d927ad244ae037db40e7b6ca1f0b46 /activerecord/test/cases/attribute_methods_test.rb
parent5bb4546439ed20a864c6df18788dce0eb45d8326 (diff)
downloadrails-72e63c71bb3f73870e280964def25b7578818b1b.tar.gz
rails-72e63c71bb3f73870e280964def25b7578818b1b.tar.bz2
rails-72e63c71bb3f73870e280964def25b7578818b1b.zip
Allow aliased attributes in update
Allow aliased attributes to be used in `#update_columns` and `#update`.
Diffstat (limited to 'activerecord/test/cases/attribute_methods_test.rb')
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 12a4027a4e..d341dd0083 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -323,6 +323,12 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_raises(ActiveModel::UnknownAttributeError) { topic.update(no_column_exists: "Hello!") }
end
+ test "write_attribute allows writing to aliased attributes" do
+ topic = Topic.first
+ assert_nothing_raised { topic.update_columns(heading: "Hello!") }
+ assert_nothing_raised { topic.update(heading: "Hello!") }
+ end
+
test "read_attribute" do
topic = Topic.new
topic.title = "Don't change the topic"