<commit_before>require 'spec_helper'

describe FactsController do
  render_views

  let(:user) { FactoryGirl.create(:user) }
  let(:fact) { FactoryGirl.create(:fact) }

  describe :show do
    it "should render succesful" do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save
      should_check_can :show, @fact
      get :show, :id => @fact.id
      response.should be_success
    end

    it "should render json succesful" do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save
      should_check_can :show, @fact
      get :show, id: @fact.id, format: :json
      response.should be_success
    end
  end

  describe :extended_show do
    it "should escape html in fields" do
      @fact = FactoryGirl.create(:fact)
      @fact.data.displaystring = "baas<xss> of niet"
      @fact.data.title = "baas<xss> of niet"
      @fact.data.save

      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save

      should_check_can :show, @fact
      get :extended_show, :id => @fact.id, :fact_slug => 'hoi'

      response.body.should_not match(/<xss>/)
    end
  end

  describe :destroy do
    it "should delete the fact" do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save
      @fact_id = @fact.id

      should_check_can :destroy, @fact
      get :destroy, id: @fact.id, format: :json
      response.should be_success

      Fact[@fact_id].should == nil
    end
  end

  describe :intermediate do
    it "should have the correct assignments" do
      post :intermediate, :the_action => "prepare"
      response.code.should eq("200")
    end
  end

  describe :create do
    it "should work" do
      authenticate_user!(user)
      should_check_can :create, anything
      post 'create', :url => "http://example.org/",  :displaystring => "Facity Fact", :title => "Title"
      response.should redirect_to(popup_show_fact_path(Fact.all.all[-1].id))
    end

    it "should work with json" do
      authenticate_user!(user)
      should_check_can :create, anything
      post 'create', :format => :json, :url => "http://example.org/",  :displaystring => "Facity Fact", :title => "Title"
      response.code.should eq("201")
    end
  end

  describe :new do
    it "should work" do
      authenticate_user!(user)
      post 'new', :url => "http://example.org/",  :displaystring => "Facity Fact", :title => "Title"
      response.should be_success
    end
  end

  describe :evidence_search do
    it "should work" do
      authenticate_user!(user)
      should_check_can :index, Fact
      get :evidence_search, fact_id: fact.id, s: "Skobrenden"
      response.should be_success
    end
  end

  describe "adding evidence" do
    before do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save

      @evidence = FactoryGirl.create :fact
      @evidence.created_by.user = FactoryGirl.create :user
      @evidence.created_by.save
    end
  end

end
<commit_msg>Use the correct parameter for evidence_search test<commit_after>require 'spec_helper'

describe FactsController do
  render_views

  let(:user) { FactoryGirl.create(:user) }
  let(:fact) { FactoryGirl.create(:fact) }

  describe :show do
    it "should render succesful" do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save
      should_check_can :show, @fact
      get :show, :id => @fact.id
      response.should be_success
    end

    it "should render json succesful" do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save
      should_check_can :show, @fact
      get :show, id: @fact.id, format: :json
      response.should be_success
    end
  end

  describe :extended_show do
    it "should escape html in fields" do
      @fact = FactoryGirl.create(:fact)
      @fact.data.displaystring = "baas<xss> of niet"
      @fact.data.title = "baas<xss> of niet"
      @fact.data.save

      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save

      should_check_can :show, @fact
      get :extended_show, :id => @fact.id, :fact_slug => 'hoi'

      response.body.should_not match(/<xss>/)
    end
  end

  describe :destroy do
    it "should delete the fact" do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save
      @fact_id = @fact.id

      should_check_can :destroy, @fact
      get :destroy, id: @fact.id, format: :json
      response.should be_success

      Fact[@fact_id].should == nil
    end
  end

  describe :intermediate do
    it "should have the correct assignments" do
      post :intermediate, :the_action => "prepare"
      response.code.should eq("200")
    end
  end

  describe :create do
    it "should work" do
      authenticate_user!(user)
      should_check_can :create, anything
      post 'create', :url => "http://example.org/",  :displaystring => "Facity Fact", :title => "Title"
      response.should redirect_to(popup_show_fact_path(Fact.all.all[-1].id))
    end

    it "should work with json" do
      authenticate_user!(user)
      should_check_can :create, anything
      post 'create', :format => :json, :url => "http://example.org/",  :displaystring => "Facity Fact", :title => "Title"
      response.code.should eq("201")
    end
  end

  describe :new do
    it "should work" do
      authenticate_user!(user)
      post 'new', :url => "http://example.org/",  :displaystring => "Facity Fact", :title => "Title"
      response.should be_success
    end
  end

  describe :evidence_search do
    it "should work" do
      authenticate_user!(user)
      should_check_can :index, Fact
      get :evidence_search, id: fact.id, s: "Baron"
      response.should be_success
    end
  end

  describe "adding evidence" do
    before do
      @fact = FactoryGirl.create(:fact)
      @fact.created_by.user = FactoryGirl.create :user
      @fact.created_by.save

      @evidence = FactoryGirl.create :fact
      @evidence.created_by.user = FactoryGirl.create :user
      @evidence.created_by.save
    end
  end

end

{'fraction_non_alphanumeric': 0.11455546813532652, 'fraction_numerical': 0.002202989771833202, 'mean_word_length': 2.831223628691983, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, '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': '5992375', 'n_tokens_mistral': 2113, 'n_tokens_neox': 2008, 'n_words': 524}