Commit dd9fce48191ca935fd0595811c78e091eff88046

Authored by Gust
1 parent 4521fc48
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Add identifier search by name and multifilter test

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
lib/software_info.rb
... ... @@ -30,8 +30,8 @@ class SoftwareInfo &lt; ActiveRecord::Base
30 30 values = []
31 31  
32 32 unless name.blank?
33   - like_sql << "name ILIKE ? AND "
34   - values << "%#{name}%"
  33 + like_sql << "name ILIKE ? OR identifier ILIKE ? AND "
  34 + values << "%#{name}%" << "%#{name}%"
35 35 end
36 36  
37 37 unless database_description_id.blank?
... ...
test/functional/search_controller_test.rb
... ... @@ -34,6 +34,14 @@ class SearchControllerTest &lt; ActionController::TestCase
34 34  
35 35 end
36 36  
  37 + should "search for people by identifier" do
  38 + p1 = create_user("user 1", "DF", "Gama", "user_1@user.com").person
  39 +
  40 + get :people, :query => "user-1"
  41 +
  42 + assert_includes assigns(:searches)[:people][:results], p1
  43 + end
  44 +
37 45 should "search for people by name" do
38 46 p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person
39 47  
... ... @@ -66,6 +74,22 @@ class SearchControllerTest &lt; ActionController::TestCase
66 74 assert_includes assigns(:searches)[:people][:results], p1
67 75 end
68 76  
  77 + should "search for people by email and state" do
  78 + p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person
  79 +
  80 + get :people, :email => "user_1@user.com", :state => "DF"
  81 +
  82 + assert_includes assigns(:searches)[:people][:results], p1
  83 + end
  84 +
  85 + should "search for software by identifier" do
  86 + software = create_software("beautiful os")
  87 +
  88 + params = {"type"=>"Software", "query"=>"", "name"=>"beautiful-os", "database_description"=>{"id"=>""}, "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", "commit"=>"Search"}
  89 + get :communities, params
  90 +
  91 + assert_includes assigns(:searches)[:communities][:results], software.community
  92 + end
69 93  
70 94 should "search for software by name" do
71 95 software = create_software("beautiful")
... ... @@ -216,6 +240,23 @@ class SearchControllerTest &lt; ActionController::TestCase
216 240  
217 241 assert_includes assigns(:searches)[:communities][:results], software.community
218 242 end
  243 +
  244 + should "search by e_arq and e_ping" do
  245 + software = create_software("beautiful")
  246 + software.e_arq = true
  247 + software.e_ping = true
  248 + software.save!
  249 +
  250 + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""},
  251 + "programming_language"=>{"id"=>""},
  252 + "operating_system"=>{"id"=>""},
  253 + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"",
  254 + "commit"=>"Search"}
  255 + get :communities, params
  256 +
  257 + assert_includes assigns(:searches)[:communities][:results], software.community
  258 + end
  259 +
219 260 protected
220 261  
221 262 def create_user name, state, city, email
... ...