From b17a486242c7071f05fe2698ed0bf67a581ca4b0 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sat, 23 Dec 2023 19:46:36 +0100 Subject: [PATCH] Just convert test to ActiveSupport::TestCase --- test/active_record/associated_object_test.rb | 29 ++++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/test/active_record/associated_object_test.rb b/test/active_record/associated_object_test.rb index 1309948..39616fe 100644 --- a/test/active_record/associated_object_test.rb +++ b/test/active_record/associated_object_test.rb @@ -3,10 +3,9 @@ require "test_helper" class ActiveRecord::AssociatedObjectTest < ActiveSupport::TestCase - include ActiveJob::TestHelper # TODO: Switch back to Minitest::Test, but need to fix `tagged_logger` NoMethodError. + include ActiveJob::TestHelper - def setup - super + setup do @post = Post.first @publisher = @post.publisher @@ -17,7 +16,7 @@ def setup @rating = @comment.rating end - def test_associated_object_alias + test "associated object alias" do assert_equal @post, @publisher.post assert_equal @publisher.post, @publisher.record @@ -25,7 +24,7 @@ def test_associated_object_alias assert_equal @rating.comment, @rating.record end - def test_associated_object_method_missing_extraction + test "associated object method missing extraction" do assert_equal @publisher, Post::Publisher.first assert_equal @publisher, Post::Publisher.last assert_equal @publisher, Post::Publisher.find(1) @@ -43,7 +42,7 @@ def test_associated_object_method_missing_extraction assert_equal [ @rating ], Post::Comment::Rating.where(Post::Comment::Rating.primary_key => [[@post.id, @author.id]]) end - def test_introspection + test "introspection" do assert_equal Post, @publisher.record_klass assert_equal Post, Post::Publisher.record_klass @@ -63,22 +62,22 @@ def test_introspection assert_equal :rating, Post::Comment::Rating.attribute_name end - def test_unscoped_passthrough + test "unscoped passthrough" do # TODO: lol what's this actually supposed to do? Need to look more into GlobalID. # https://github.com/rails/globalid/blob/3ddb0f87fd5c22b3330ab2b4e5c41a85953ac886/lib/global_id/locator.rb#L164 assert_equal [ @post ], @publisher.class.unscoped end - def test_transaction_passthrough + test "transaction passthrough" do assert_equal @post, Post::Publisher.transaction { Post.first } assert_equal @post, @publisher.transaction { Post.first } end - def test_primary_key_passthrough + test "primary_key passthrough" do assert_equal Post.primary_key, Post::Publisher.primary_key end - def test_callback_passing + test "callback forwarding" do @post.update title: "Updated title" assert_equal "Updated title", @publisher.captured_title @@ -87,7 +86,7 @@ def test_callback_passing refute_empty Post.all end - def test_kredis_integration + test "kredis integration" do Time.new(2022, 4, 20, 1).tap do |publish_at| @publisher.publish_at.value = publish_at @@ -100,7 +99,7 @@ def test_kredis_integration assert @rating.moderated? end - def test_global_id_integration + test "global_id integration" do assert_equal "gid://test/Post::Publisher/1", @publisher.to_gid.to_s assert_equal @publisher, GlobalID.find(@publisher.to_gid.to_s) @@ -117,7 +116,7 @@ def test_global_id_integration assert_equal [ @rating ], GlobalID::Locator.locate_many([ @rating.to_gid.to_s, missing_rating.to_gid.to_s ], ignore_missing: true) end - def test_active_job_integration + test "Active Job integration" do @publisher.performed = false assert_performed_with job: Post::Publisher::PublishJob, args: [ @publisher ], queue: "important" do @@ -127,11 +126,11 @@ def test_active_job_integration assert @publisher.performed end - def test_calling_method + test "calling method" do assert @rating.great? end - def test_record_klass_extension + test "record_klass extension" do assert_predicate Post::Comment.great.first, :rated_great? assert_match /test\/boot\/associated_object/, Post::Comment.instance_method(:rated_great?).source_location.first end