Commit d5595b30ec3016d2b2c13cd95d15984c5c9f2760

Authored by David Silva
Committed by Fabio Teixeira
1 parent 2183feb5
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

Fix tests

  - Functional and units tests

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
lib/library_helper.rb
1 -module LibraryHelper 1 +class LibraryHelper < DynamicTableHelper
  2 + MODEL_NAME = "library"
  3 +
2 def self.list_library new_libraries 4 def self.list_library new_libraries
3 return [] if new_libraries.nil? or new_libraries.length == 0 5 return [] if new_libraries.nil? or new_libraries.length == 0
4 list_libraries = [] 6 list_libraries = []
@@ -57,4 +59,4 @@ module LibraryHelper @@ -57,4 +59,4 @@ module LibraryHelper
57 def self.add_dynamic_table 59 def self.add_dynamic_table
58 libraries_as_tables(nil).first.call 60 libraries_as_tables(nil).first.call
59 end 61 end
60 -end 62 -end
  63 +end
61 \ No newline at end of file 64 \ No newline at end of file
test/functional/search_controller_test.rb
@@ -38,18 +38,21 @@ class SearchControllerTest &lt; ActionController::TestCase @@ -38,18 +38,21 @@ class SearchControllerTest &lt; ActionController::TestCase
38 "66.544.314/0001-63" 38 "66.544.314/0001-63"
39 ) 39 )
40 40
41 - get :communities, :query => "New" 41 + get :communities, :query => "New"
42 42
43 - assert_includes assigns(:searches)[:communities][:results], community  
44 - assert_not_includes assigns(:searches)[:communities][:results], software  
45 - assert_not_includes assigns(:searches)[:communities][:results], institution  
46 - end 43 + assert_includes assigns(:searches)[:communities][:results], community
  44 + assert_not_includes assigns(:searches)[:communities][:results], software
  45 + assert_not_includes assigns(:searches)[:communities][:results], institution
  46 + end
47 47
48 should "software_infos search don't have community or institution" do 48 should "software_infos search don't have community or institution" do
49 community = create_community("New Community") 49 community = create_community("New Community")
50 software = create_software_info("New Software") 50 software = create_software_info("New Software")
51 institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63") 51 institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63")
52 52
  53 + software.license_info = LicenseInfo.create :version=>"GPL - 1.0"
  54 + software.save!
  55 +
53 get :software_infos, :query => "New" 56 get :software_infos, :query => "New"
54 57
55 assert_includes assigns(:searches)[:software_infos][:results], software.community 58 assert_includes assigns(:searches)[:software_infos][:results], software.community
@@ -57,31 +60,6 @@ class SearchControllerTest &lt; ActionController::TestCase @@ -57,31 +60,6 @@ class SearchControllerTest &lt; ActionController::TestCase
57 assert_not_includes assigns(:searches)[:software_infos][:results], institution.community 60 assert_not_includes assigns(:searches)[:software_infos][:results], institution.community
58 end 61 end
59 62
60 - should "software_infos search by category" do  
61 - software_with_category = create_software_info("New Software With Category")  
62 - software_without_category = create_software_info("New Software Without Category")  
63 - category = Category.create!(:name => "Health", :environment => @environment, :parent => @category_software)  
64 -  
65 - software_with_category.community.categories << category  
66 - software_with_category.save!  
67 -  
68 - get :software_infos, :query => "New", :filter => category.id  
69 -  
70 - assert_includes assigns(:searches)[:software_infos][:results], software_with_category.community  
71 - assert_not_includes assigns(:searches)[:software_infos][:results], software_without_category.community  
72 - end  
73 -  
74 - should "institutions_search don't have community or software" do  
75 - community = create_community("New Community")  
76 - software = create_software_info("New Software")  
77 - institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63")  
78 -  
79 - get :institutions, :query => "New"  
80 -  
81 - assert_includes assigns(:searches)[:institutions][:results], institution.community  
82 - assert_not_includes assigns(:searches)[:institutions][:results], community  
83 - assert_not_includes assigns(:searches)[:institutions][:results], software.community  
84 - end  
85 63
86 should "Don't found template in communities search" do 64 should "Don't found template in communities search" do
87 community = create_community("New Community") 65 community = create_community("New Community")
@@ -104,52 +82,14 @@ class SearchControllerTest &lt; ActionController::TestCase @@ -104,52 +82,14 @@ class SearchControllerTest &lt; ActionController::TestCase
104 82
105 get :communities, :query => "New" 83 get :communities, :query => "New"
106 84
107 - assert_includes(  
108 - assigns(:searches)[:software_infos][:results],  
109 - software.community  
110 - )  
111 - assert_not_includes assigns(:searches)[:software_infos][:results], community  
112 - assert_not_includes(  
113 - assigns(:searches)[:software_infos][:results],  
114 - institution.community  
115 - )  
116 - end  
117 -  
118 - should "software_infos search by category" do  
119 - software_with_category = create_software_info("New Software With Category")  
120 - software_with_category.license_info = LicenseInfo.create(:version => "GPL")  
121 -  
122 - software_without_category =  
123 - create_software_info("New Software Without Category")  
124 -  
125 - software_without_category.license_info =  
126 - LicenseInfo.create(:version => "GPL")  
127 -  
128 - category = Category.create!(  
129 - :name => "Health",  
130 - :environment => @environment,  
131 - :parent => @category_software  
132 - )  
133 -  
134 - software_template = create_software_info("New Software Template")  
135 - software_template.license_info = LicenseInfo.last  
136 - software_template.community.is_template = true  
137 - software_template.community.save!  
138 - software_template.save!  
139 -  
140 - get :software_infos, :query => "New"  
141 -  
142 - assert_includes(  
143 - assigns(:searches)[:software_infos][:results],  
144 - software_with_category.community  
145 - )  
146 assert_not_includes( 85 assert_not_includes(
147 - assigns(:searches)[:software_infos][:results],  
148 - software_without_category.community 86 + assigns(:searches)[:communities][:results],
  87 + community_template
149 ) 88 )
150 end 89 end
151 90
152 should "institutions_search don't have community or software" do 91 should "institutions_search don't have community or software" do
  92 +
153 community = create_community("New Community") 93 community = create_community("New Community")
154 software = create_software_info("New Software") 94 software = create_software_info("New Software")
155 institution = create_private_institution( 95 institution = create_private_institution(