<commit_before># frozen_string_literal: true
require 'test_helper'
require 'support/web_mocking'

class SearchControllerTest < ActionController::TestCase
  include WebMocking
  include Devise::Test::ControllerHelpers

  setup do
    @ad = FactoryGirl.create(:ad)
    @user = FactoryGirl.create(:user)
  end

  test 'should work search with a WOEID param' do
    mocking_yahoo_woeid_info(@ad.woeid_code) do
      get :search, q: 'ordenador', woeid: @ad.woeid_code
      assert_response :success
    end
  end

  test 'should work search with a WOEID param - no results' do
    mocking_yahoo_woeid_info(@ad.woeid_code) do
      get :search, q: 'notfound', woeid: @ad.woeid_code
      assert_response :success
    end
  end

  test 'should work search with a logged in user with a WOEID code' do
    mocking_yahoo_woeid_info(@user.woeid) do
      sign_in @user
      get :search, q: 'ordenador'
      assert_response :success
    end
  end

  test 'should search work without WOEID param nor logged user' do
    get :search
    assert_response :redirect
    assert_redirected_to location_ask_path
  end
end<commit_msg>Drop weird wording in some tests<commit_after># frozen_string_literal: true
require 'test_helper'
require 'support/web_mocking'

class SearchControllerTest < ActionController::TestCase
  include WebMocking
  include Devise::Test::ControllerHelpers

  setup do
    @ad = FactoryGirl.create(:ad)
    @user = FactoryGirl.create(:user)
  end

  test 'search works with a WOEID param' do
    mocking_yahoo_woeid_info(@ad.woeid_code) do
      get :search, q: 'ordenador', woeid: @ad.woeid_code
      assert_response :success
    end
  end

  test 'search works with a WOEID param - no results' do
    mocking_yahoo_woeid_info(@ad.woeid_code) do
      get :search, q: 'notfound', woeid: @ad.woeid_code
      assert_response :success
    end
  end

  test 'search works with a logged in user with a WOEID code' do
    mocking_yahoo_woeid_info(@user.woeid) do
      sign_in @user
      get :search, q: 'ordenador'
      assert_response :success
    end
  end

  test 'search works without WOEID param nor logged user' do
    get :search
    assert_response :redirect
    assert_redirected_to location_ask_path
  end
end
{'fraction_non_alphanumeric': 0.07101123595505618, 'fraction_numerical': 0.0, 'mean_word_length': 3.6569037656903767, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6428206', 'n_tokens_mistral': 753, 'n_tokens_neox': 725, 'n_words': 220}