Skip to content

Commit d8c6127

Browse files
committed
Coerce tests to check for subclasses rather than actual classes
1 parent a3475a2 commit d8c6127

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/cases/coerced_tests.rb

+31
Original file line numberDiff line numberDiff line change
@@ -2653,3 +2653,34 @@ def test_url_invalid_adapter_coerced
26532653
end
26542654
end
26552655
end
2656+
2657+
module ActiveRecord
2658+
class TableMetadataTest < ActiveSupport::TestCase
2659+
# Adapter returns an object that is subclass of what is expected in the original test.
2660+
coerce_tests! %r{#associated_table creates the right type caster for joined table with different association name}
2661+
def associated_table_creates_the_right_type_caster_for_joined_table_with_different_association_name_coerced
2662+
base_table_metadata = TableMetadata.new(AuditRequiredDeveloper, Arel::Table.new("developers"))
2663+
2664+
associated_table_metadata = base_table_metadata.associated_table("audit_logs")
2665+
2666+
assert associated_table_metadata.arel_table.type_for_attribute(:message).is_a?(ActiveRecord::Type::String)
2667+
end
2668+
end
2669+
end
2670+
2671+
module ActiveRecord
2672+
module TypeCaster
2673+
class ConnectionTest < ActiveSupport::TestCase
2674+
# Adapter returns an object that is subclass of what is expected in the original test.
2675+
coerce_tests! %r{#type_for_attribute is not aware of custom types}
2676+
def type_for_attribute_is_not_aware_of_custom_types_coerced
2677+
type_caster = Connection.new(AttributedDeveloper, "developers")
2678+
2679+
type = type_caster.type_for_attribute(:name)
2680+
2681+
assert_not_equal DeveloperName, type.class
2682+
assert type.is_a?(ActiveRecord::Type::String)
2683+
end
2684+
end
2685+
end
2686+
end

0 commit comments

Comments
 (0)