Skip to content

Commit 0914344

Browse files
takaokoujiclaude
andcommitted
Fix test_warn_on_joined_to_many for Ruby 2.7 with Rails 5.2
The test was failing on Ruby 2.7 with Rails 5.2.8.1 because ActiveRecord deprecation warnings were appearing in stderr alongside the expected performance warning, causing the exact string match assertion to fail. Changes: - Replace assert_equal with assert_match to check for presence of the performance warning rather than exact stderr match - Replace assert_empty with refute_match to verify the performance warning doesn't appear when disabled, while tolerating environment- specific deprecation warnings This makes the test more robust across different Ruby/Rails versions while still validating the core functionality. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 01bdcd4 commit 0914344

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

test/controllers/controller_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,14 +3682,16 @@ def test_warn_on_joined_to_many
36823682
get :index, params: {fields: {posts: 'id,title'}}
36833683
assert_response :success
36843684
end
3685-
assert_equal(err, "Performance issue detected: `Api::V4::PostResource.records` returned non-normalized results in `Api::V4::PostResource.find_fragments`.\n")
3685+
assert_match(/Performance issue detected: `Api::V4::PostResource.records` returned non-normalized results in `Api::V4::PostResource.find_fragments`\./, err)
36863686

36873687
JSONAPI.configuration.warn_on_performance_issues = false
36883688
_out, err = capture_subprocess_io do
36893689
get :index, params: {fields: {posts: 'id,title'}}
36903690
assert_response :success
36913691
end
3692-
assert_empty err
3692+
# On older Ruby/Rails combinations, there may be deprecation warnings
3693+
# but we should not see the performance issue warning
3694+
refute_match(/Performance issue detected/, err)
36933695

36943696
ensure
36953697
JSONAPI.configuration = original_config

0 commit comments

Comments
 (0)