diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/attribute_methods/read_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/primary_keys_test.rb | 14 |
3 files changed, 18 insertions, 4 deletions
diff --git a/activerecord/test/cases/attribute_methods/read_test.rb b/activerecord/test/cases/attribute_methods/read_test.rb index e03ed33591..814476ce73 100644 --- a/activerecord/test/cases/attribute_methods/read_test.rb +++ b/activerecord/test/cases/attribute_methods/read_test.rb @@ -24,6 +24,10 @@ module ActiveRecord def self.primary_key end + def self.primary_key? + false + end + def self.columns column_names.map { FakeColumn.new(name) } end diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 12c1cfb30e..77fd1d2fad 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -97,10 +97,6 @@ class BasicsTest < ActiveRecord::TestCase assert pk.primary, 'nick should be primary key' end - def test_primary_key_with_no_id - assert_nil Edge.primary_key - end - unless current_adapter?(:PostgreSQLAdapter,:OracleAdapter,:SQLServerAdapter) def test_limit_with_comma assert_nothing_raised do diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb index 489c7d8310..58badd6266 100644 --- a/activerecord/test/cases/primary_keys_test.rb +++ b/activerecord/test/cases/primary_keys_test.rb @@ -5,6 +5,7 @@ require 'models/subscriber' require 'models/movie' require 'models/keyboard' require 'models/mixed_case_monkey' +require 'models/edge' class PrimaryKeysTest < ActiveRecord::TestCase fixtures :topics, :subscribers, :movies, :mixed_case_monkeys @@ -161,4 +162,17 @@ class PrimaryKeysTest < ActiveRecord::TestCase assert_equal 'foo', model.primary_key end + + def test_no_primary_key_raises + assert_raises(ActiveRecord::UnknownPrimaryKey) do + Edge.primary_key + end + + begin + Edge.primary_key + rescue ActiveRecord::UnknownPrimaryKey => e + assert e.message.include?('edges') + assert e.message.include?('Edge') + end + end end |