diff --git a/src/noosfero-spb/software_communities/features/use_report.feature b/src/noosfero-spb/software_communities/features/use_report.feature index bc67450..018b532 100644 --- a/src/noosfero-spb/software_communities/features/use_report.feature +++ b/src/noosfero-spb/software_communities/features/use_report.feature @@ -4,11 +4,13 @@ Feature: Use report to give my feedback about a software. Background: + Given "GovUserPlugin" plugin is enabled Given "SoftwareCommunitiesPlugin" plugin is enabled Given "OrganizationRatings" plugin is enabled And I am logged in as mpog_admin And I go to /admin/plugins And I check "SoftwareCommunitiesPlugin" + And I check "GovUserPlugin" And I press "Save changes" And the following softwares | name | public_software | finality | @@ -21,7 +23,7 @@ Feature: Use report And I choose "Organization Ratings" And I press "Add" Then I should see "Report your experiences" - + Scenario: Add Average Rating Block Given I go to Noosfero's control panel And I follow "Edit sideboxes" @@ -41,14 +43,19 @@ Feature: Use report @selenium Scenario: Validate Use Report fields format - Given I go to Noosfero's control panel - Given I follow "Edit sideboxes" + Given Institutions has initial default values on database + And the following public institutions + | name | acronym | country | state | city | cnpj | juridical_nature | governmental_power | governmental_sphere | corporate_name | + | Ministerio do Planejamento | MP | BR | Distrito Federal | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | Ministerio do Planejamento | + And I go to Noosfero's control panel + And I follow "Edit sideboxes" When I follow "Add a block" And I choose "Organization Ratings" And I press "Add" And I am on Noosfero's homepage And I follow "Rate Community" When I click on anything with selector "comments-additional-information" + And I type in "Minis" in autocomplete list "#input_institution" and I choose "Ministerio do Planejamento" And I fill in "people_benefited_tmp" with "123123" And I fill in "saved_value_tmp" with "7654321" And I press "Save" diff --git a/src/noosfero-spb/software_communities/lib/ext/search_controller.rb b/src/noosfero-spb/software_communities/lib/ext/search_controller.rb index 62b4f2c..43a266c 100644 --- a/src/noosfero-spb/software_communities/lib/ext/search_controller.rb +++ b/src/noosfero-spb/software_communities/lib/ext/search_controller.rb @@ -32,6 +32,7 @@ class SearchController results = filter_software_infos_list(&software_public_condition_block) @software_count = results.count results = results.paginate(:per_page => @per_page, :page => params[:page]) + @searches[@asset] = {:results => results} @search = results @@ -92,7 +93,7 @@ class SearchController filtered_software_list = SoftwareInfo.search_by_query(params[:query], environment) - if params[:only_softwares] + if params[:only_softwares] && params[:only_softwares].any?{ |word| !word.blank? } params[:only_softwares].collect!{ |software_name| software_name.to_slug } #FIX-ME: This query is not appropriate filtered_software_list = SoftwareInfo.all.select{ |s| params[:only_softwares].include?(s.identifier) } @@ -161,7 +162,7 @@ class SearchController def prepare_per_page return 15 if params[:software_display].nil? - if params[:software_display] == "all" + if params[:software_display].downcase == "all" SoftwareInfo.count else params[:software_display].to_i diff --git a/src/noosfero-spb/software_communities/public/views/search-software-catalog.js b/src/noosfero-spb/software_communities/public/views/search-software-catalog.js index 86db87a..6bf82da 100644 --- a/src/noosfero-spb/software_communities/public/views/search-software-catalog.js +++ b/src/noosfero-spb/software_communities/public/views/search-software-catalog.js @@ -52,6 +52,8 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot', 'SoftwareCat params.software_type = $("#public_software_radio_button").val(); } + params.only_softwares = $("#only_softwares_hidden").val().split(' '); + return params; } diff --git a/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb index 7046115..aaca7ce 100644 --- a/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/search_controller_test.rb @@ -218,6 +218,23 @@ class SearchControllerTest < ActionController::TestCase assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community end + should "software_infos search return only the software in params order by Z-A" do + software_one = create_software_info("Software One", :acronym => "SFO", :finality => "Help") + software_two = create_software_info("Java", :acronym => "SFT", :finality => "Task") + software_three = create_software_info("Software Three", :acronym => "SFW", :finality => "Java") + + get( + :software_infos, + :only_softwares => ["software-three", "java"], + :sort => "desc" + ) + + assert_equal assigns(:searches)[:software_infos][:results][0], software_three.community + assert_equal assigns(:searches)[:software_infos][:results][1], software_two.community + assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community + end + + should "software_infos search return only enabled softwares" do s1 = SoftwareInfo.first s2 = SoftwareInfo.last diff --git a/src/noosfero-spb/software_communities/views/search/_software_search_form.html.erb b/src/noosfero-spb/software_communities/views/search/_software_search_form.html.erb index b3f3e6b..0f5b046 100644 --- a/src/noosfero-spb/software_communities/views/search/_software_search_form.html.erb +++ b/src/noosfero-spb/software_communities/views/search/_software_search_form.html.erb @@ -28,38 +28,39 @@ <%= submit_button(:search, _('Filter')) %> - <%= render :partial => 'search_form_extra_fields' %> - <%= render :partial => 'catalog_filter' %> - <% end %> - + <%= render :partial => 'search_form_extra_fields' %> + <%= render :partial => 'catalog_filter' %> -