<commit_before>require 'spec_helper'

describe Fact do
  def self.other_one(this)
    this == :supporting ? :weakening : :supporting
  end

  def other_one(this)
    self.class.other_one(this)
  end

  subject(:fact) { create :fact }

  let(:factlink) { create :fact }

  let(:graph_user) { create(:graph_user) }

  before do
    # TODO: remove this once activities are not created in the models any more, but in interactors
    stub_const 'Activity::Subject', Class.new
    Activity::Subject.stub(:activity)
  end

  describe ".delete" do
    it "works" do
      old_id = fact.id
      data_id = fact.data.id

      fact.delete

      expect(Fact[old_id]).to be_nil
      expect(FactData.find(data_id)).to be_nil
    end

    it "removes the fact from the creators facts list" do
      gu = fact.created_by
      expect(gu.sorted_created_facts.count).to eq 1

      fact.delete
      expect(gu.sorted_created_facts.count).to eq 0
    end
  end

  it "has the GraphUser set when a opinion is added" do
    parent = create :fact
    parent.add_opinion(:believes, graph_user)
    expect(parent.opiniated(:believes).to_a).to match_array [graph_user]
  end

  it "is in the created_facts set of the creator" do
    gu = fact.created_by
    expect(gu.created_facts.to_a).to match_array [fact]
  end

  context "initially" do
    it "should have no evidence for a type, or the :both type" do
      expect(fact.evidence(:supporting).count).to eq 0
      expect(fact.evidence(:weakening).count).to eq 0
      expect(fact.evidence(:both).count).to eq 0
    end
  end<commit_msg>Removed test for GraphUser#created_facts in fact_spec (we already check for sorted_created_facts)<commit_after>require 'spec_helper'

describe Fact do
  def self.other_one(this)
    this == :supporting ? :weakening : :supporting
  end

  def other_one(this)
    self.class.other_one(this)
  end

  subject(:fact) { create :fact }

  let(:factlink) { create :fact }

  let(:graph_user) { create(:graph_user) }

  before do
    # TODO: remove this once activities are not created in the models any more, but in interactors
    stub_const 'Activity::Subject', Class.new
    Activity::Subject.stub(:activity)
  end

  describe ".delete" do
    it "works" do
      old_id = fact.id
      data_id = fact.data.id

      fact.delete

      expect(Fact[old_id]).to be_nil
      expect(FactData.find(data_id)).to be_nil
    end

    it "removes the fact from the creators facts list" do
      gu = fact.created_by
      expect(gu.sorted_created_facts.count).to eq 1

      fact.delete
      expect(gu.sorted_created_facts.count).to eq 0
    end
  end

  it "has the GraphUser set when a opinion is added" do
    parent = create :fact
    parent.add_opinion(:believes, graph_user)
    expect(parent.opiniated(:believes).to_a).to match_array [graph_user]
  end

  context "initially" do
    it "should have no evidence for a type, or the :both type" do
      expect(fact.evidence(:supporting).count).to eq 0
      expect(fact.evidence(:weakening).count).to eq 0
      expect(fact.evidence(:both).count).to eq 0
    end
  end
{'fraction_non_alphanumeric': 0.0967218435572866, 'fraction_numerical': 0.0032456994482310936, 'mean_word_length': 3.148048452220727, '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': '6254018', 'n_tokens_mistral': 1049, 'n_tokens_neox': 986, 'n_words': 287}