1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #40104 from p8/happy-human

Rename horrible and dirty to puzzled and confused in test models
This commit is contained in:
Eugene Kenny 2020-08-25 22:32:18 +01:00 committed by GitHub
commit 34c54f9668
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View file

@ -297,7 +297,7 @@ class InverseHasOneTests < ActiveRecord::TestCase
end
def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error
assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Human.first.dirty_face }
assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Human.first.confused_face }
end
end
@ -648,7 +648,7 @@ class InverseBelongsToTests < ActiveRecord::TestCase
end
def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error
assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.first.horrible_human }
assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.first.puzzled_human }
end
def test_building_has_many_parent_association_inverses_one_record
@ -766,12 +766,12 @@ class InversePolymorphicBelongsToTests < ActiveRecord::TestCase
def test_trying_to_access_inverses_that_dont_exist_shouldnt_raise_an_error
# Ideally this would, if only for symmetry's sake with other association types
assert_nothing_raised { Face.first.horrible_polymorphic_human }
assert_nothing_raised { Face.first.puzzled_polymorphic_human }
end
def test_trying_to_set_polymorphic_inverses_that_dont_exist_at_all_should_raise_an_error
# fails because no class has the correct inverse_of for horrible_polymorphic_human
assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.first.horrible_polymorphic_human = Human.first }
# fails because no class has the correct inverse_of for puzzled_polymorphic_human
assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.first.puzzled_polymorphic_human = Human.first }
end
def test_trying_to_set_polymorphic_inverses_that_dont_exist_on_the_instance_being_set_should_raise_an_error

View file

@ -7,8 +7,8 @@ class Face < ActiveRecord::Base
# Oracle identifier length is limited to 30 bytes or less, `polymorphic` renamed `poly`
belongs_to :poly_human_without_inverse, polymorphic: true
# These are "broken" inverse_of associations for the purposes of testing
belongs_to :horrible_human, class_name: "Human", inverse_of: :horrible_face
belongs_to :horrible_polymorphic_human, polymorphic: true, inverse_of: :horrible_polymorphic_face
belongs_to :puzzled_human, class_name: "Human", inverse_of: :puzzled_face
belongs_to :puzzled_polymorphic_human, polymorphic: true, inverse_of: :puzzled_polymorphic_face
validate do
human

View file

@ -23,7 +23,7 @@ class Human < ActiveRecord::Base
after_add: :add_called,
inverse_of: :polymorphic_human
# These are "broken" inverse_of associations for the purposes of testing
has_one :dirty_face, class_name: "Face", inverse_of: :dirty_human
has_one :confused_face, class_name: "Face", inverse_of: :confused_human
has_many :secret_interests, class_name: "Interest", inverse_of: :secret_human
has_one :mixed_case_monkey

View file

@ -1020,8 +1020,8 @@ ActiveRecord::Schema.define do
t.string :polymorphic_human_type
t.integer :poly_human_without_inverse_id
t.string :poly_human_without_inverse_type
t.integer :horrible_polymorphic_human_id
t.string :horrible_polymorphic_human_type
t.integer :puzzled_polymorphic_human_id
t.string :puzzled_polymorphic_human_type
t.references :super_human, polymorphic: true, index: false
end