diff --git a/public/software-catalog.js b/public/software-catalog.js index 81e467a..60cfcdd 100644 --- a/public/software-catalog.js +++ b/public/software-catalog.js @@ -106,6 +106,8 @@ selected_categories_ids.push(element.value); }); + open_loading("Loading"); + $.ajax({ url: AJAX_URL.software_infos, type: "GET", @@ -113,19 +115,27 @@ query: query_text, selected_categories: selected_categories_ids }, - success: callback + success: callback, + error: function(){ + close_loading(); + } }); } function update_search_page_on_ajax(response) { + close_loading(); + response = $(response); var search_list = $("#search-results"); var selected_categories_field = $("#filter-categories-select-catalog"); + var pagination = $(".pagination"); - var result_list = $(response).find("#search-results").html(); - var result_categories = $(response).find("#filter-categories-select-catalog").html(); + var result_list = response.find("#search-results").html(); + var result_categories = response.find("#filter-categories-select-catalog").html(); + var result_pagination = response.find(".pagination").html(); search_list.html(result_list); selected_categories_field.html(result_categories); + pagination.html(result_pagination); show_head_message(); } diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 9408b68..6cf733c 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -20,10 +20,7 @@ class SearchControllerTest < ActionController::TestCase @request.stubs(:ssl?).returns(:false) @response = ActionController::TestResponse.new - @category_software = Category.create!( - :name => _("Software"), - :environment => @environment - ) + create_software_categories end should "communities searches don't have software or institution" do @@ -45,7 +42,7 @@ class SearchControllerTest < ActionController::TestCase assert_not_includes assigns(:searches)[:communities][:results], institution end - should "software_infos search don't have community or institution" do + should "software_infos search don't have community or institution" do community = create_community("New Community") software = create_software_info("New Software") institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63") @@ -58,7 +55,7 @@ class SearchControllerTest < ActionController::TestCase assert_includes assigns(:searches)[:software_infos][:results], software.community assert_not_includes assigns(:searches)[:software_infos][:results], community assert_not_includes assigns(:searches)[:software_infos][:results], institution.community - end + end should "Don't found template in communities search" do @@ -89,7 +86,6 @@ class SearchControllerTest < ActionController::TestCase end should "institutions_search don't have community or software" do - community = create_community("New Community") software = create_software_info("New Software") institution = create_private_institution( @@ -112,6 +108,47 @@ class SearchControllerTest < ActionController::TestCase assigns(:searches)[:institutions][:results], software.community ) + end + + should "software_infos search by category" do + software_one = create_software_info("Software One") + software_two = create_software_info("Software Two") + + software_one.community.categories << Category.first + software_two.community.categories << Category.last + + software_one.license_info = LicenseInfo.create :version=>"GPL - 1.0" + software_two.license_info = LicenseInfo.create :version=>"GPL - 1.0" + + software_one.save! + software_two.save! + + get( + :software_infos, + :query => "", + :selected_categories => [Category.first.id] + ) + + assert_includes assigns(:searches)[:software_infos][:results], software_one.community + assert_not_includes assigns(:searches)[:software_infos][:results], software_two.community + end + + private + def create_software_categories + category_software = Category.create!( + :name => "Software", + :environment => @environment + ) + Category.create( + :name => "Category One", + :environment => @environment, + :parent => category_software + ) + Category.create( + :name => "Category Two", + :environment => @environment, + :parent => category_software + ) end end diff --git a/views/search/_mpog_search_form.html.erb b/views/search/_mpog_search_form.html.erb index 7c15b24..60dc607 100644 --- a/views/search/_mpog_search_form.html.erb +++ b/views/search/_mpog_search_form.html.erb @@ -13,7 +13,7 @@ <%= text_field_tag 'query', @query, :id => 'search-input', :size => 50, :placeholder=>_("Type words about the software_info you're looking for") %> - <%= submit_button(:search, _('Search'), :class => "button with-text icon-search submit") %> + <%= submit_button(:search, _('Search')) %> <%= render :partial => 'search_form_extra_fields' %> -- libgit2 0.21.2