<commit_before>#   Copyright (c) 2010, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

require 'spec_helper'

describe PeopleController do
  render_views

  let(:user) { Factory(:user) }
  let!(:aspect) { user.aspects.create(:name => "lame-os") }

  before do
    sign_in :user, user
  end

  describe '#index' do
    before do
      @eugene = Factory.create(:person, :profile => {:first_name => "Eugene", :last_name => "w"})
      @korth  = Factory.create(:person, :profile => {:first_name => "Evan", :last_name => "Korth"})
    end

    it "yields search results for substring of person name" do
      get :index, :q => "Eu"
      assigns[:people].should include @eugene
    end

    it 'shows a contact' do
      user2 = make_user
      connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience'))
      get :index
      assigns[:people].should include user2.person
      response.should be_success
    end

    it 'shows a non-contact' do
      user2 = make_user
      user2.person.profile.searchable = true
      user2.save
      get :index
      assigns[:people].should include user2.person
      response.should be_success
    end

    it "redirects to person page if there is exactly one match" do
      get :index, :q => "Korth"
      response.should redirect_to @korth
    end

    it "does not redirect if there are no matches" do
      get :index, :q => "Korthsauce"
      response.should_not be_redirect
    end
  end

  describe '#show' do
    it 'should go to the current_user show page' do
      get :show, :id => user.person.id
      response.should be_success
    end

    it "redirects on an invalid id" do
      get :show, :id => 'delicious'
      response.should redirect_to people_path
    end

    it "redirects on a nonexistent person" do
      get :show, :id => user.id
      response.should redirect_to people_path
    end<commit_msg>since there is only one person with that name in the db, it returns a redirect<commit_after>#   Copyright (c) 2010, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

require 'spec_helper'

describe PeopleController do
  render_views

  let(:user) { Factory(:user) }
  let!(:aspect) { user.aspects.create(:name => "lame-os") }

  before do
    sign_in :user, user
  end

  describe '#index' do
    before do
      @eugene = Factory.create(:person, :profile => {:first_name => "Eugene", :last_name => "w"})
      @korth  = Factory.create(:person, :profile => {:first_name => "Evan", :last_name => "Korth"})
    end

    it "yields search results for substring of person name" do
      get :index, :q => "Eu"
      assigns[:people].should include @eugene
    end

    it 'shows a contact' do
      user2 = make_user
      connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience'))
      get :index, :q => user2.person.profile.first_name.to_s
      assigns[:people].should include user2.person
    end

    it 'shows a non-contact' do
      user2 = make_user
      user2.person.profile.searchable = true
      user2.save
      get :index, :q => user2.person.profile.first_name.to_s
      assigns[:people].should include user2.person
    end

    it "redirects to person page if there is exactly one match" do
      get :index, :q => "Korth"
      response.should redirect_to @korth
    end

    it "does not redirect if there are no matches" do
      get :index, :q => "Korthsauce"
      response.should_not be_redirect
    end
  end

  describe '#show' do
    it 'should go to the current_user show page' do
      get :show, :id => user.person.id
      response.should be_success
    end

    it "redirects on an invalid id" do
      get :show, :id => 'delicious'
      response.should redirect_to people_path
    end

    it "redirects on a nonexistent person" do
      get :show, :id => user.id
      response.should redirect_to people_path
    end
{'fraction_non_alphanumeric': 0.10136986301369863, 'fraction_numerical': 0.006973848069738481, 'mean_word_length': 2.803030303030303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '4218057', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1254, 'n_words': 422}