forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests guarding against regressions identified in rails/rails@640e…
…3981 We had to revert rails/rails@6dd1929 due to some regressions it caused. Here are some tests that would prevent those regressions in the future. See previous commits for more detail.
- Loading branch information
1 parent
12dbb80
commit cd5fe84
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cases/helper" | ||
require "models/developer" | ||
|
||
module ActiveRecord | ||
class TableMetadataTest < ActiveSupport::TestCase | ||
test "#associated_table creates the right type caster for joined table with different association name" do | ||
base_table_metadata = TableMetadata.new(AuditRequiredDeveloper, Arel::Table.new("developers")) | ||
|
||
associated_table_metadata = base_table_metadata.associated_table("audit_logs") | ||
|
||
assert_equal ActiveRecord::Type::String, associated_table_metadata.arel_table.type_for_attribute(:message).class | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cases/helper" | ||
require "models/developer" | ||
|
||
module ActiveRecord | ||
module TypeCaster | ||
class ConnectionTest < ActiveSupport::TestCase | ||
test "#type_for_attribute is not aware of custom types" do | ||
type_caster = Connection.new(AttributedDeveloper, "developers") | ||
|
||
type = type_caster.type_for_attribute(:name) | ||
|
||
assert_not_equal DeveloperName, type.class | ||
assert_equal ActiveRecord::Type::String, type.class | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters