diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-29 09:37:13 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-29 09:37:13 -0600 |
commit | 42b9f3eb5226b4c7b59a4cbc4ff0e81a420aeb45 (patch) | |
tree | f41b55a23445ef7b300b73ca9eb3da3ba6bf20e7 | |
parent | 4a2d586cfcd58c0d65dfe7e603e4e5e84418801e (diff) | |
download | rails-42b9f3eb5226b4c7b59a4cbc4ff0e81a420aeb45.tar.gz rails-42b9f3eb5226b4c7b59a4cbc4ff0e81a420aeb45.tar.bz2 rails-42b9f3eb5226b4c7b59a4cbc4ff0e81a420aeb45.zip |
Fix test failures caused by #19501
The first one is quite straightforward. We want to give the proper error
message in the case where a top level constant exists, but we're looking
for a nested one. We just need to port over the change to use
`subclass.name` into these changes.
The second set of failures, which are only present in the mysql adapter
tests, are stranger to me. The failure occurs because we were
previously comparing `subclass.name == self.name` instead of `subclass
== self`. However, I don't think that we need to support creating
anonymous classes which share a table with a class that uses STI,
overrides `name` to return the same name as athe class that we have no
other relationship with, when not assigned to a constant so it could
never be used anyway...
The commits around why that exist give no context, and I think they're
just poorly written tests (WTF does `test_schema` mean anyway, and why
does calling `.first` on some anonymous class test it?). We'll just
disable STI on that class.
-rw-r--r-- | activerecord/lib/active_record/inheritance.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql/schema_test.rb | 1 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/schema_test.rb | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb index 53a9a9b797..741229f9c0 100644 --- a/activerecord/lib/active_record/inheritance.rb +++ b/activerecord/lib/active_record/inheritance.rb @@ -181,7 +181,7 @@ module ActiveRecord "or overwrite #{name}.inheritance_column to use another column for that information." end unless subclass == self || descendants.include?(subclass) - raise SubclassNotFound, "Invalid single-table inheritance type: #{type_name} is not a subclass of #{name}" + raise SubclassNotFound, "Invalid single-table inheritance type: #{subclass.name} is not a subclass of #{name}" end subclass end diff --git a/activerecord/test/cases/adapters/mysql/schema_test.rb b/activerecord/test/cases/adapters/mysql/schema_test.rb index 2e18f609fd..a0f3c31e78 100644 --- a/activerecord/test/cases/adapters/mysql/schema_test.rb +++ b/activerecord/test/cases/adapters/mysql/schema_test.rb @@ -14,6 +14,7 @@ module ActiveRecord @db_name = db @omgpost = Class.new(ActiveRecord::Base) do + self.inheritance_column = :disabled self.table_name = "#{db}.#{table}" def self.name; 'Post'; end end diff --git a/activerecord/test/cases/adapters/mysql2/schema_test.rb b/activerecord/test/cases/adapters/mysql2/schema_test.rb index faf2acb9cb..1ebdca661c 100644 --- a/activerecord/test/cases/adapters/mysql2/schema_test.rb +++ b/activerecord/test/cases/adapters/mysql2/schema_test.rb @@ -14,6 +14,7 @@ module ActiveRecord @db_name = db @omgpost = Class.new(ActiveRecord::Base) do + self.inheritance_column = :disabled self.table_name = "#{db}.#{table}" def self.name; 'Post'; end end |