<commit_before>require "spec_helper"

describe RailsSoftDeletable do
  let (:model) { IntegerModel.create! }
  let (:decimal_model) { DecimalModel.create! }
  let (:integer_model) { IntegerModel.create! }

  context "#destroy" do
    it "marks deleted_at column" do
      Timecop.freeze(Time.now) do
        decimal_model.destroy
        integer_model.destroy

        decimal_deleted_at = DecimalModel.connection.select_value("SELECT deleted_at FROM #{DecimalModel.quoted_table_name} WHERE #{DecimalModel.primary_key} = #{decimal_model.id}")
        integer_deleted_at = IntegerModel.connection.select_value("SELECT deleted_at FROM #{IntegerModel.quoted_table_name} WHERE #{IntegerModel.primary_key} = #{integer_model.id}")

        expect(decimal_deleted_at).to eq(Time.now.to_f)
        expect(integer_deleted_at.to_i).to eq(Time.now.to_i)
      end
    end

    it "soft deletes the record" do
      Timecop.freeze(Time.now) do
        decimal_model.destroy
        integer_model.destroy

        expect(decimal_model.deleted_at).to eq(Time.now)
        expect(integer_model.deleted_at.to_i).to eq(Time.now.to_i)
      end
    end

    it "does not mark the deleted_at attribute as changed" do
      model.destroy

      expect(model).to_not be_deleted_at_changed
    end

    it "marks the record as destroyed" do
      model.destroy

      expect(model).to be_destroyed
    end

    it "does not freeze the record" do
      model.destroy

      expect(decimal_model).to_not be_frozen
    end

    it "performs destroy callbacks" do
      model.destroy

      expect(model.before_destroy_called).to be_true
      expect(model.after_destroy_called).to be_true
    end

    context "when record has already been soft deleted" do
      before do
        model.destroy
      end

      it "does not perform destroy callbacks" do
        model.destroy

        expect(model.before_destroy_called).to be_nil
        expect(model.after_destroy_called).to be_nil
      end
<commit_msg>Fix spec<commit_after>require "spec_helper"

describe RailsSoftDeletable do
  let (:model) { IntegerModel.create! }
  let (:decimal_model) { DecimalModel.create! }
  let (:integer_model) { IntegerModel.create! }

  context "#destroy" do
    it "marks deleted_at column" do
      Timecop.freeze(Time.now) do
        decimal_model.destroy
        integer_model.destroy

        decimal_deleted_at = DecimalModel.connection.select_value("SELECT deleted_at FROM #{DecimalModel.quoted_table_name} WHERE #{DecimalModel.primary_key} = #{decimal_model.id}")
        integer_deleted_at = IntegerModel.connection.select_value("SELECT deleted_at FROM #{IntegerModel.quoted_table_name} WHERE #{IntegerModel.primary_key} = #{integer_model.id}")

        expect(decimal_deleted_at).to eq(Time.now.to_f)
        expect(integer_deleted_at.to_i).to eq(Time.now.to_i)
      end
    end

    it "soft deletes the record" do
      Timecop.freeze(Time.now) do
        decimal_model.destroy
        integer_model.destroy

        expect(decimal_model.deleted_at).to eq(Time.now)
        expect(integer_model.deleted_at.to_i).to eq(Time.now.to_i)
      end
    end

    it "does not mark the deleted_at attribute as changed" do
      model.destroy

      expect(model).to_not be_deleted_at_changed
    end

    it "marks the record as destroyed" do
      model.destroy

      expect(model).to be_destroyed
    end

    it "does not freeze the record" do
      model.destroy

      expect(decimal_model).to_not be_frozen
    end

    it "performs destroy callbacks" do
      model.destroy

      expect(model.before_destroy_called).to eq(true)
      expect(model.after_destroy_called).to eq(true)
    end

    context "when record has already been soft deleted" do
      before do
        model.destroy
      end

      it "does not perform destroy callbacks" do
        model.destroy

        expect(model.before_destroy_called).to be_nil
        expect(model.after_destroy_called).to be_nil
      end

{'fraction_non_alphanumeric': 0.0812926028780611, 'fraction_numerical': 0.0, 'mean_word_length': 3.0264227642276422, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3725773', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1213, 'n_words': 275}