aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-24 11:20:47 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-24 11:20:47 +0000
commit1d618455870cac504256cd762cd0787c739dfe1f (patch)
tree34fe4009e1bab6cf722538b7c29dcb9aeab50a66 /activerecord/test
parent3d1e8dde9d023cc3d2c75dea689648434050d621 (diff)
downloadrails-1d618455870cac504256cd762cd0787c739dfe1f.tar.gz
rails-1d618455870cac504256cd762cd0787c739dfe1f.tar.bz2
rails-1d618455870cac504256cd762cd0787c739dfe1f.zip
Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@483 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/base_test.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index c5a6b7d656..f6d7e31683 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -114,7 +114,14 @@ class BasicsTest < Test::Unit::TestCase
topicReloaded = Topic.find(id)
assert_equal("New Topic", topicReloaded.title)
end
-
+
+ def test_create_columns_not_equal_attributes
+ topic = Topic.new
+ topic.title = 'Another New Topic'
+ topic.send :write_attribute, 'does_not_exist', 'test'
+ assert_nothing_raised { topic.save }
+ end
+
def test_create_through_factory
topic = Topic.create("title" => "New Topic")
topicReloaded = Topic.find(topic.id)
@@ -140,6 +147,18 @@ class BasicsTest < Test::Unit::TestCase
assert_equal("Updated topic", topicReloadedAgain.title)
end
+ def test_update_columns_not_equal_attributes
+ topic = Topic.new
+ topic.title = "Still another topic"
+ topic.save
+ id = topic.id
+
+ topicReloaded = Topic.find(id)
+ topicReloaded.title = "A New Topic"
+ topicReloaded.send :write_attribute, 'does_not_exist', 'test'
+ assert_nothing_raised { topicReloaded.save }
+ end
+
def test_preserving_date_objects
# SQL Server doesn't have a separate column type just for dates, so all are returned as time
if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter