Skip to content

Commit

Permalink
Test ignored_columns value is inheritable by subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
kamipo committed Oct 29, 2017
1 parent 7903fb4 commit 439c746
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions activerecord/test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1512,17 +1512,24 @@ def test_default_values_are_deeply_dupped
cache_columns = Developer.connection.schema_cache.columns_hash(Developer.table_name)
assert_includes cache_columns.keys, "first_name"
assert_not_includes Developer.columns_hash.keys, "first_name"
assert_not_includes SubDeveloper.columns_hash.keys, "first_name"
end

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 SubDeveloper.new.respond_to?(:first_name)
refute SubDeveloper.new.respond_to?(:first_name=)
refute SubDeveloper.new.respond_to?(:first_name?)
end

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 SubDeveloper.new.respond_to?(:last_name)
assert SubDeveloper.new.respond_to?(:last_name=)
assert SubDeveloper.new.respond_to?(:last_name?)
end
end
3 changes: 3 additions & 0 deletions activerecord/test/models/developer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def track_instance_count
private :track_instance_count
end

class SubDeveloper < Developer
end

class AuditLog < ActiveRecord::Base
belongs_to :developer, validate: true
belongs_to :unvalidated_developer, class_name: "Developer"
Expand Down

0 comments on commit 439c746

Please sign in to comment.