Skip to content

Commit

Permalink
Merge pull request rails#49037 from etiennebarrie/fix-test-leak
Browse files Browse the repository at this point in the history
Fix test leak
  • Loading branch information
byroot authored Aug 25, 2023
2 parents 153eae8 + 0810752 commit a8871e6
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions activerecord/test/cases/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,18 @@ def test_to_param_for_a_composite_primary_key_model
end

def test_param_delimiter_changes_delimiter_used_in_to_param
old_delimiter = Cpk::Order.param_delimiter
Cpk::Order.param_delimiter = ","
assert_equal("1,123", Cpk::Order.new(id: [1, 123]).to_param)
ensure
Cpk::Order.param_delimiter = old_delimiter
Cpk::Order.with(param_delimiter: ",") do
assert_equal("1,123", Cpk::Order.new(id: [1, 123]).to_param)
end
end

def test_param_delimiter_is_defined_per_class
old_order_delimiter = Cpk::Order.param_delimiter
old_book_delimiter = Cpk::Book.param_delimiter

Cpk::Order.param_delimiter = ","
Cpk::Book.param_delimiter = ";"

assert_equal("1,123", Cpk::Order.new(id: [1, 123]).to_param)
assert_equal("1;123", Cpk::Book.new(id: [1, 123]).to_param)
ensure
Cpk::Order.param_delimiter = old_order_delimiter
Cpk::Order.param_delimiter = old_book_delimiter
Cpk::Order.with(param_delimiter: ",") do
Cpk::Book.with(param_delimiter: ";") do
assert_equal("1,123", Cpk::Order.new(id: [1, 123]).to_param)
assert_equal("1;123", Cpk::Book.new(id: [1, 123]).to_param)
end
end
end

def test_cache_key_for_existing_record_is_not_timezone_dependent
Expand Down

0 comments on commit a8871e6

Please sign in to comment.