<commit_before># frozen_string_literal: true

require "cases/helper"
require "models/post"

module ActiveRecord
  class RelationMutationTest < ActiveRecord::TestCase
    (Relation::MULTI_VALUE_METHODS - [:extending, :order, :unscope, :select]).each do |method|
      test "##{method}!" do
        assert relation.public_send("#{method}!", :foo).equal?(relation)
        assert_equal [:foo], relation.public_send("#{method}_values")
      end
    end

    test "#_select!" do
      assert relation._select!(:foo).equal?(relation)
      assert_equal [:foo], relation.select_values
    end

    test "#order!" do
      assert relation.order!("name ASC").equal?(relation)
      assert_equal ["name ASC"], relation.order_values
    end

    test "#order! with symbol prepends the table name" do
      assert relation.order!(:name).equal?(relation)
      node = relation.order_values.first
      assert_predicate node, :ascending?
      assert_equal "name", node.expr.name
      assert_equal "posts", node.expr.relation.name
    end

    test "#order! on non-string does not attempt regexp match for references" do
      obj = Object.new
      assert_not_called(obj, :=~) do
        assert relation.order!(obj)
        assert_equal [obj], relation.order_values
      end
    end

    test "extending!" do
      mod, mod2 = Module.new, Module.new

      assert relation.extending!(mod).equal?(relation)
      assert_equal [mod], relation.extending_values
      assert relation.is_a?(mod)

      relation.extending!(mod2)
      assert_equal [mod, mod2], relation.extending_values<commit_msg>Remove assert_not_called Object#=~ here for Ruby 3.2 compat<commit_after># frozen_string_literal: true

require "cases/helper"
require "models/post"

module ActiveRecord
  class RelationMutationTest < ActiveRecord::TestCase
    (Relation::MULTI_VALUE_METHODS - [:extending, :order, :unscope, :select]).each do |method|
      test "##{method}!" do
        assert relation.public_send("#{method}!", :foo).equal?(relation)
        assert_equal [:foo], relation.public_send("#{method}_values")
      end
    end

    test "#_select!" do
      assert relation._select!(:foo).equal?(relation)
      assert_equal [:foo], relation.select_values
    end

    test "#order!" do
      assert relation.order!("name ASC").equal?(relation)
      assert_equal ["name ASC"], relation.order_values
    end

    test "#order! with symbol prepends the table name" do
      assert relation.order!(:name).equal?(relation)
      node = relation.order_values.first
      assert_predicate node, :ascending?
      assert_equal "name", node.expr.name
      assert_equal "posts", node.expr.relation.name
    end

    test "#order! on non-string does not attempt regexp match for references" do
      obj = Object.new
      assert relation.order!(obj)
      assert_equal [obj], relation.order_values
    end

    test "extending!" do
      mod, mod2 = Module.new, Module.new

      assert relation.extending!(mod).equal?(relation)
      assert_equal [mod], relation.extending_values
      assert relation.is_a?(mod)

      relation.extending!(mod2)
      assert_equal [mod, mod2], relation.extending_values
{'fraction_non_alphanumeric': 0.1176842771274913, 'fraction_numerical': 0.002530844669408415, 'mean_word_length': 3.4472573839662446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5037758', 'n_tokens_mistral': 935, 'n_tokens_neox': 926, 'n_words': 233}