From 638505b90f593c8ee48a060f378ed6a9c93442e1 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sat, 6 Oct 2007 00:49:58 +0000 Subject: Send the correct INSERT statement when dealing with objects with only primary keys. Closes #9523 [tarmo] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7753 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/base_test.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'activerecord/test/base_test.rb') diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 4418b8d9e6..53ef4a5e86 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -11,6 +11,7 @@ require 'fixtures/column_name' require 'fixtures/subscriber' require 'fixtures/keyboard' require 'fixtures/post' +require 'fixtures/minimalistic' class Category < ActiveRecord::Base; end class Smarts < ActiveRecord::Base; end @@ -64,7 +65,7 @@ class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base end class BasicsTest < Test::Unit::TestCase - fixtures :topics, :companies, :developers, :projects, :computers, :accounts + fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics def test_table_exists assert !NonExistentTable.table_exists? @@ -184,6 +185,15 @@ class BasicsTest < Test::Unit::TestCase assert_nil topic.title end + def test_save_for_record_with_only_primary_key + minimalistic = Minimalistic.new + assert_nothing_raised { minimalistic.save } + end + + def test_save_for_record_with_only_primary_key_that_is_provided + assert_nothing_raised { Minimalistic.create!(:id => 2) } + end + def test_hashes_not_mangled new_topic = { :title => "New Topic" } new_topic_values = { :title => "AnotherTopic" } @@ -240,6 +250,11 @@ class BasicsTest < Test::Unit::TestCase topicReloaded.send :write_attribute, 'does_not_exist', 'test' assert_nothing_raised { topicReloaded.save } end + + def test_update_for_record_with_only_primary_key + minimalistic = minimalistics(:first) + assert_nothing_raised { minimalistic.save } + end def test_write_attribute topic = Topic.new -- cgit v1.2.3