mirror of https://github.com/rails/rails
Test `ignored_columns` value is inheritable by subclasses
This commit is contained in:
parent
a69f423e8b
commit
207c37a1ec
|
@ -1444,17 +1444,24 @@ class BasicsTest < ActiveRecord::TestCase
|
||||||
cache_columns = Developer.connection.schema_cache.columns_hash(Developer.table_name)
|
cache_columns = Developer.connection.schema_cache.columns_hash(Developer.table_name)
|
||||||
assert_includes cache_columns.keys, "first_name"
|
assert_includes cache_columns.keys, "first_name"
|
||||||
assert_not_includes Developer.columns_hash.keys, "first_name"
|
assert_not_includes Developer.columns_hash.keys, "first_name"
|
||||||
|
assert_not_includes SubDeveloper.columns_hash.keys, "first_name"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "ignored columns have no attribute methods" do
|
test "ignored columns have no attribute methods" do
|
||||||
refute Developer.new.respond_to?(:first_name)
|
refute Developer.new.respond_to?(:first_name)
|
||||||
refute Developer.new.respond_to?(:first_name=)
|
refute Developer.new.respond_to?(:first_name=)
|
||||||
refute Developer.new.respond_to?(:first_name?)
|
refute Developer.new.respond_to?(:first_name?)
|
||||||
|
refute SubDeveloper.new.respond_to?(:first_name)
|
||||||
|
refute SubDeveloper.new.respond_to?(:first_name=)
|
||||||
|
refute SubDeveloper.new.respond_to?(:first_name?)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "ignored columns don't prevent explicit declaration of attribute methods" do
|
test "ignored columns don't prevent explicit declaration of attribute methods" do
|
||||||
assert Developer.new.respond_to?(:last_name)
|
assert Developer.new.respond_to?(:last_name)
|
||||||
assert Developer.new.respond_to?(:last_name=)
|
assert Developer.new.respond_to?(:last_name=)
|
||||||
assert Developer.new.respond_to?(:last_name?)
|
assert Developer.new.respond_to?(:last_name?)
|
||||||
|
assert SubDeveloper.new.respond_to?(:last_name)
|
||||||
|
assert SubDeveloper.new.respond_to?(:last_name=)
|
||||||
|
assert SubDeveloper.new.respond_to?(:last_name?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,6 +87,9 @@ class Developer < ActiveRecord::Base
|
||||||
private :track_instance_count
|
private :track_instance_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class SubDeveloper < Developer
|
||||||
|
end
|
||||||
|
|
||||||
class AuditLog < ActiveRecord::Base
|
class AuditLog < ActiveRecord::Base
|
||||||
belongs_to :developer, validate: true
|
belongs_to :developer, validate: true
|
||||||
belongs_to :unvalidated_developer, class_name: "Developer"
|
belongs_to :unvalidated_developer, class_name: "Developer"
|
||||||
|
|
Loading…
Reference in New Issue