Skip to content

Commit 746d115

Browse files
authored
Merge pull request rails#44521 from ghousemohamed/make-activerecord-tests-more-consistent
Makes some of the activerecord tests more syntactically consistent
2 parents fa8c2dd + 6b52db8 commit 746d115

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

activerecord/test/cases/base_test.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,26 +608,29 @@ def test_equality_of_relation_and_collection_proxy
608608
car = Car.create!
609609
car.bulbs.build
610610
car.save
611+
bulbs_of_car = Bulb.where(car_id: car.id)
611612

612-
assert car.bulbs == Bulb.where(car_id: car.id), "CollectionProxy should be comparable with Relation"
613-
assert Bulb.where(car_id: car.id) == car.bulbs, "Relation should be comparable with CollectionProxy"
613+
assert_equal car.bulbs, bulbs_of_car, "CollectionProxy should be comparable with Relation"
614+
assert_equal bulbs_of_car, car.bulbs, "Relation should be comparable with CollectionProxy"
614615
end
615616

616617
def test_equality_of_relation_and_array
617618
car = Car.create!
618619
car.bulbs.build
619620
car.save
621+
bulbs_of_car = Bulb.where(car_id: car.id)
620622

621-
assert Bulb.where(car_id: car.id) == car.bulbs.to_a, "Relation should be comparable with Array"
623+
assert_equal bulbs_of_car, car.bulbs.to_a, "Relation should be comparable with Array"
622624
end
623625

624626
def test_equality_of_relation_and_association_relation
625627
car = Car.create!
626628
car.bulbs.build
627629
car.save
630+
bulbs_of_car = Bulb.where(car_id: car.id)
628631

629-
assert_equal Bulb.where(car_id: car.id), car.bulbs.includes(:car), "Relation should be comparable with AssociationRelation"
630-
assert_equal car.bulbs.includes(:car), Bulb.where(car_id: car.id), "AssociationRelation should be comparable with Relation"
632+
assert_equal bulbs_of_car, car.bulbs.includes(:car), "Relation should be comparable with AssociationRelation"
633+
assert_equal car.bulbs.includes(:car), bulbs_of_car, "AssociationRelation should be comparable with Relation"
631634
end
632635

633636
def test_equality_of_collection_proxy_and_association_relation

activerecord/test/cases/invertible_migration_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,8 @@ def test_up_only
515515
horse1.reload
516516
horse2 = Horse.create
517517

518-
assert 1, horse1.oldie # created before migration
519-
assert 0, horse2.oldie # created after migration
518+
assert_equal 1, horse1.oldie # created before migration
519+
assert_equal 0, horse2.oldie # created after migration
520520

521521
UpOnlyMigration.new.migrate(:down) # should be no error
522522
connection = ActiveRecord::Base.connection

activerecord/test/cases/statement_cache_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_statement_cache_values_differ
9696
end
9797

9898
additional_books = cache.execute([], Book.connection)
99-
assert first_books != additional_books
99+
assert_not_equal first_books, additional_books
100100
end
101101

102102
def test_unprepared_statements_dont_share_a_cache_with_prepared_statements

0 commit comments

Comments
 (0)