mirror of
https://github.com/github/rails.git
synced 2026-01-30 00:38:00 -05:00
Let inspect on AR classes work when the table doesn't exist. Closes #9194 [tarmo, nzkoz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7278 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -912,9 +912,11 @@ module ActiveRecord #:nodoc:
|
||||
super
|
||||
elsif abstract_class?
|
||||
"#{super}(abstract)"
|
||||
else
|
||||
elsif table_exists?
|
||||
attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', '
|
||||
"#{super}(#{attr_list})"
|
||||
else
|
||||
"#{super}(Table doesn't exist)"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1696,6 +1696,10 @@ class BasicsTest < Test::Unit::TestCase
|
||||
assert_equal %(#<Topic id: 1>), Topic.find(:first, :select => 'id', :conditions => 'id = 1').inspect
|
||||
assert_equal %(#<Topic id: 1, title: "The First Topic">), Topic.find(:first, :select => 'id, title', :conditions => 'id = 1').inspect
|
||||
end
|
||||
|
||||
def test_inspect_class_without_table
|
||||
assert_equal "NonExistentTable(Table doesn't exist)", NonExistentTable.inspect
|
||||
end
|
||||
|
||||
def test_attribute_for_inspect
|
||||
t = topics(:first)
|
||||
|
||||
Reference in New Issue
Block a user