Commit dd9fce48191ca935fd0595811c78e091eff88046
1 parent
4521fc48
Exists in
master
and in
5 other branches
Add identifier search by name and multifilter test
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Showing
2 changed files
with
43 additions
and
2 deletions
Show diff stats
lib/software_info.rb
@@ -30,8 +30,8 @@ class SoftwareInfo < ActiveRecord::Base | @@ -30,8 +30,8 @@ class SoftwareInfo < ActiveRecord::Base | ||
30 | values = [] | 30 | values = [] |
31 | 31 | ||
32 | unless name.blank? | 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 | end | 35 | end |
36 | 36 | ||
37 | unless database_description_id.blank? | 37 | unless database_description_id.blank? |
test/functional/search_controller_test.rb
@@ -34,6 +34,14 @@ class SearchControllerTest < ActionController::TestCase | @@ -34,6 +34,14 @@ class SearchControllerTest < ActionController::TestCase | ||
34 | 34 | ||
35 | end | 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 | should "search for people by name" do | 45 | should "search for people by name" do |
38 | p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person | 46 | p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person |
39 | 47 | ||
@@ -66,6 +74,22 @@ class SearchControllerTest < ActionController::TestCase | @@ -66,6 +74,22 @@ class SearchControllerTest < ActionController::TestCase | ||
66 | assert_includes assigns(:searches)[:people][:results], p1 | 74 | assert_includes assigns(:searches)[:people][:results], p1 |
67 | end | 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 | should "search for software by name" do | 94 | should "search for software by name" do |
71 | software = create_software("beautiful") | 95 | software = create_software("beautiful") |
@@ -216,6 +240,23 @@ class SearchControllerTest < ActionController::TestCase | @@ -216,6 +240,23 @@ class SearchControllerTest < ActionController::TestCase | ||
216 | 240 | ||
217 | assert_includes assigns(:searches)[:communities][:results], software.community | 241 | assert_includes assigns(:searches)[:communities][:results], software.community |
218 | end | 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 | protected | 260 | protected |
220 | 261 | ||
221 | def create_user name, state, city, email | 262 | def create_user name, state, city, email |