<commit_before>require 'spec_helper'

describe Channel::UserStream do
  subject { u1.stream }

  let(:u1) { FactoryGirl.create(:user).graph_user }

  describe "initially" do
    it { subject.facts.to_a.should =~ []}
    its(:discontinued) {should == false}
    its(:editable?) {should == false}
    its(:followable?) {should == false}
    its(:title) {should == "All" }
    its(:description) {should == "All facts" }
    its(:unread_count) {should == 0 }
  end  

  describe "after adding one empty channel" do
    before do
      @ch1 = create(:channel, :created_by => u1)
      Channel.recalculate_all
    end
    it { subject.facts.to_a.should =~ []}
  end
  
  describe "after creating a fact" do
    before do
      @f1 = create(:fact, :created_by => u1)
    end
    pending { subject.facts.to_a.should =~ [@f1]}
  end

  describe "after adding channel with one fact" do
    before do
      @ch1 = create(:channel, :created_by => u1)
      @f1 = create(:fact)
      @ch1.add_fact(@f1)
      Channel.recalculate_all
    end
    it { subject.facts.to_a.should =~ [@f1]}
    its(:unread_count) {should == 0 }
    describe "after retrieving the user_stream from the database" do
      it {GraphUser[subject.id].stream.facts.to_a.should =~[@f1]}
    end
  end
  describe "after adding two channels with one fact" do
    before do
      @ch1 = create(:channel, :created_by => u1)
      @f1 = create(:fact)
      @ch1.add_fact(@f1)
      @ch2 = create(:channel, :created_by => u1)
      @f2 = create(:fact)
      @ch2.add_fact(@f2)
      Channel.recalculate_all
    end
    it { subject.facts.to_a.should =~ [@f1,@f2]}
    its(:unread_count) {should == 0 }
    describe "after creating a fact" do
      before do
        @f3 = create(:fact, :created_by => u1)
      end
      pending { subject.facts.to_a.should =~ [@f1,@f2,@f3]}
    end
    describe "after creating a factrelation" do
      before do
        @fr = FactRelation.get_or_create(@f1,:supporting,@f2,u1)
      end
      it { subject.facts.to_a.should =~ [@f1,@f2]}
      its(:unread_count) {should == 0 }
    end
    
  end

end<commit_msg>added failing test to test with<commit_after>require 'spec_helper'

describe Channel::UserStream do
  subject { u1.stream }

  let(:u1) { FactoryGirl.create(:user).graph_user }

  describe "initially" do
    it {1.should == 2}
    
    it { subject.facts.to_a.should =~ []}
    its(:discontinued) {should == false}
    its(:editable?) {should == false}
    its(:followable?) {should == false}
    its(:title) {should == "All" }
    its(:description) {should == "All facts" }
    its(:unread_count) {should == 0 }
  end  

  describe "after adding one empty channel" do
    before do
      @ch1 = create(:channel, :created_by => u1)
      Channel.recalculate_all
    end
    it { subject.facts.to_a.should =~ []}
  end
  
  describe "after creating a fact" do
    before do
      @f1 = create(:fact, :created_by => u1)
    end
    pending { subject.facts.to_a.should =~ [@f1]}
  end

  describe "after adding channel with one fact" do
    before do
      @ch1 = create(:channel, :created_by => u1)
      @f1 = create(:fact)
      @ch1.add_fact(@f1)
      Channel.recalculate_all
    end
    it { subject.facts.to_a.should =~ [@f1]}
    its(:unread_count) {should == 0 }
    describe "after retrieving the user_stream from the database" do
      it {GraphUser[subject.id].stream.facts.to_a.should =~[@f1]}
    end
  end
  describe "after adding two channels with one fact" do
    before do
      @ch1 = create(:channel, :created_by => u1)
      @f1 = create(:fact)
      @ch1.add_fact(@f1)
      @ch2 = create(:channel, :created_by => u1)
      @f2 = create(:fact)
      @ch2.add_fact(@f2)
      Channel.recalculate_all
    end
    it { subject.facts.to_a.should =~ [@f1,@f2]}
    its(:unread_count) {should == 0 }
    describe "after creating a fact" do
      before do
        @f3 = create(:fact, :created_by => u1)
      end
      pending { subject.facts.to_a.should =~ [@f1,@f2,@f3]}
    end
    describe "after creating a factrelation" do
      before do
        @fr = FactRelation.get_or_create(@f1,:supporting,@f2,u1)
      end
      it { subject.facts.to_a.should =~ [@f1,@f2]}
      its(:unread_count) {should == 0 }
    end
    
  end

end
{'fraction_non_alphanumeric': 0.13912429378531074, 'fraction_numerical': 0.019303201506591337, 'mean_word_length': 2.7271929824561405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '5993455', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1491, 'n_words': 363}