Commit d5595b30ec3016d2b2c13cd95d15984c5c9f2760
Committed by
Fabio Teixeira
1 parent
2183feb5
Exists in
master
and in
5 other branches
Fix tests
- Functional and units tests Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
2 changed files
with
15 additions
and
73 deletions
Show diff stats
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 < ActionController::TestCase | @@ -38,18 +38,21 @@ class SearchControllerTest < 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 < ActionController::TestCase | @@ -57,31 +60,6 @@ class SearchControllerTest < 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 < ActionController::TestCase | @@ -104,52 +82,14 @@ class SearchControllerTest < 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( |