<commit_before>require 'spec_helper'

describe TreeSearchesController, 'GET to show search results in master tree' do
  let(:user) { Factory(:email_confirmed_user) }
  let(:master_tree) { Factory(:master_tree, :user => user) }
  let(:node)  { Factory(:node, :tree => master_tree) }
  
  subject { controller }

  before do
    sign_in_as(user)
    get :show, :tree_id => master_tree, :name_string => node.name_string, :format => 'json'
  end
  
  it { should respond_with(:success) }
  
end<commit_msg>spec for tree_searches_controller<commit_after>require 'spec_helper'

describe TreeSearchesController, 'GET to show search results in master tree' do
  let(:user) { Factory(:email_confirmed_user) }
  let(:master_tree) { Factory(:master_tree, :user => user) }
  let(:parent)  { Factory(:node, :tree => master_tree) }
  let(:child) { Factory(:node, :parent => parent, :tree => master_tree) }
  
  subject { controller }

  before do
    sign_in_as(user)
    get :show, :tree_id => master_tree, :name_string => child.name_string, :format => 'json'
  end
  
  it { should respond_with(:success) }
  
  it "should render the search results as JSON" do
    search_results = JSON.parse(response.body)
    search_results.first["treepath"]["name_strings"].should == parent.name_string + ' > ' + child.name_string
  end 
end

describe TreeSearchesController, 'GET to show search results in reference tree' do
  let(:user) { Factory(:email_confirmed_user) }
  let(:reference_tree) { Factory(:reference_tree) }
  let(:parent)  { Factory(:node, :tree => reference_tree) }
  let(:child) { Factory(:node, :parent => parent, :tree => reference_tree) }
  
  subject { controller }

  before do
    sign_in_as(user)
    get :show, :tree_id => reference_tree, :name_string => child.name_string, :format => 'json'
  end
  
  it { should respond_with(:success) }
  
  it "should render the search results as JSON" do
    search_results = JSON.parse(response.body)
    search_results.first["treepath"]["name_strings"].should == parent.name_string + ' > ' + child.name_string
  end 
end

describe TreeSearchesController, 'GET search in master tree without authenticating' do
  before { get :show, :tree_id => 123, :name_string => 'gnite' }
  it     { should redirect_to(sign_in_url) }
  it     { should set_the_flash.to(/sign in/) }
end
{'fraction_non_alphanumeric': 0.12829373650107992, 'fraction_numerical': 0.0012958963282937365, 'mean_word_length': 4.436619718309859, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '669450', 'n_tokens_mistral': 759, 'n_tokens_neox': 749, 'n_words': 187}