diff options
-rw-r--r-- | activerecord/test/cases/view_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/view_test.rb b/activerecord/test/cases/view_test.rb index 2f23d12de5..c2e71612a3 100644 --- a/activerecord/test/cases/view_test.rb +++ b/activerecord/test/cases/view_test.rb @@ -42,6 +42,13 @@ class ViewWithPrimaryKeyTest < ActiveRecord::TestCase assert_equal({"id" => 2, "name" => "Ruby for Rails", "status" => 0}, Ebook.first.attributes) end + + def test_does_not_assume_id_column_as_primary_key + model = Class.new(ActiveRecord::Base) do + self.table_name = "ebooks" + end + assert_nil model.primary_key + end end class ViewWithoutPrimaryKeyTest < ActiveRecord::TestCase @@ -80,5 +87,9 @@ class ViewWithoutPrimaryKeyTest < ActiveRecord::TestCase assert_equal({"name" => "Agile Web Development with Rails", "status" => 0}, Paperback.first.attributes) end + + def test_does_not_have_a_primary_key + assert_nil Paperback.primary_key + end end end |