Commit 3ae9703f17af8b4f2a05bdcd1706221bc2f7ba09
1 parent
4eb9f4aa
Exists in
master
and in
7 other branches
Fix bugs on software search
- Fix software search ordination by only_softwares with ajax - Fix search by click on 'Filter' to use the 'show' and the 'sort by' Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
Showing
5 changed files
with
62 additions
and
32 deletions
Show diff stats
src/noosfero-spb/software_communities/features/use_report.feature
| ... | ... | @@ -4,11 +4,13 @@ Feature: Use report |
| 4 | 4 | to give my feedback about a software. |
| 5 | 5 | |
| 6 | 6 | Background: |
| 7 | + Given "GovUserPlugin" plugin is enabled | |
| 7 | 8 | Given "SoftwareCommunitiesPlugin" plugin is enabled |
| 8 | 9 | Given "OrganizationRatings" plugin is enabled |
| 9 | 10 | And I am logged in as mpog_admin |
| 10 | 11 | And I go to /admin/plugins |
| 11 | 12 | And I check "SoftwareCommunitiesPlugin" |
| 13 | + And I check "GovUserPlugin" | |
| 12 | 14 | And I press "Save changes" |
| 13 | 15 | And the following softwares |
| 14 | 16 | | name | public_software | finality | |
| ... | ... | @@ -21,7 +23,7 @@ Feature: Use report |
| 21 | 23 | And I choose "Organization Ratings" |
| 22 | 24 | And I press "Add" |
| 23 | 25 | Then I should see "Report your experiences" |
| 24 | - | |
| 26 | + | |
| 25 | 27 | Scenario: Add Average Rating Block |
| 26 | 28 | Given I go to Noosfero's control panel |
| 27 | 29 | And I follow "Edit sideboxes" |
| ... | ... | @@ -41,14 +43,19 @@ Feature: Use report |
| 41 | 43 | |
| 42 | 44 | @selenium |
| 43 | 45 | Scenario: Validate Use Report fields format |
| 44 | - Given I go to Noosfero's control panel | |
| 45 | - Given I follow "Edit sideboxes" | |
| 46 | + Given Institutions has initial default values on database | |
| 47 | + And the following public institutions | |
| 48 | + | name | acronym | country | state | city | cnpj | juridical_nature | governmental_power | governmental_sphere | corporate_name | | |
| 49 | + | Ministerio do Planejamento | MP | BR | Distrito Federal | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | Ministerio do Planejamento | | |
| 50 | + And I go to Noosfero's control panel | |
| 51 | + And I follow "Edit sideboxes" | |
| 46 | 52 | When I follow "Add a block" |
| 47 | 53 | And I choose "Organization Ratings" |
| 48 | 54 | And I press "Add" |
| 49 | 55 | And I am on Noosfero's homepage |
| 50 | 56 | And I follow "Rate Community" |
| 51 | 57 | When I click on anything with selector "comments-additional-information" |
| 58 | + And I type in "Minis" in autocomplete list "#input_institution" and I choose "Ministerio do Planejamento" | |
| 52 | 59 | And I fill in "people_benefited_tmp" with "123123" |
| 53 | 60 | And I fill in "saved_value_tmp" with "7654321" |
| 54 | 61 | And I press "Save" | ... | ... |
src/noosfero-spb/software_communities/lib/ext/search_controller.rb
| ... | ... | @@ -32,6 +32,7 @@ class SearchController |
| 32 | 32 | results = filter_software_infos_list(&software_public_condition_block) |
| 33 | 33 | @software_count = results.count |
| 34 | 34 | results = results.paginate(:per_page => @per_page, :page => params[:page]) |
| 35 | + | |
| 35 | 36 | @searches[@asset] = {:results => results} |
| 36 | 37 | @search = results |
| 37 | 38 | |
| ... | ... | @@ -92,7 +93,7 @@ class SearchController |
| 92 | 93 | |
| 93 | 94 | filtered_software_list = SoftwareInfo.search_by_query(params[:query], environment) |
| 94 | 95 | |
| 95 | - if params[:only_softwares] | |
| 96 | + if params[:only_softwares] && params[:only_softwares].any?{ |word| !word.blank? } | |
| 96 | 97 | params[:only_softwares].collect!{ |software_name| software_name.to_slug } |
| 97 | 98 | #FIX-ME: This query is not appropriate |
| 98 | 99 | filtered_software_list = SoftwareInfo.all.select{ |s| params[:only_softwares].include?(s.identifier) } |
| ... | ... | @@ -161,7 +162,7 @@ class SearchController |
| 161 | 162 | def prepare_per_page |
| 162 | 163 | return 15 if params[:software_display].nil? |
| 163 | 164 | |
| 164 | - if params[:software_display] == "all" | |
| 165 | + if params[:software_display].downcase == "all" | |
| 165 | 166 | SoftwareInfo.count |
| 166 | 167 | else |
| 167 | 168 | params[:software_display].to_i | ... | ... |
src/noosfero-spb/software_communities/public/views/search-software-catalog.js
| ... | ... | @@ -52,6 +52,8 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot', 'SoftwareCat |
| 52 | 52 | params.software_type = $("#public_software_radio_button").val(); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | + params.only_softwares = $("#only_softwares_hidden").val().split(' '); | |
| 56 | + | |
| 55 | 57 | return params; |
| 56 | 58 | } |
| 57 | 59 | ... | ... |
src/noosfero-spb/software_communities/test/functional/search_controller_test.rb
| ... | ... | @@ -218,6 +218,23 @@ class SearchControllerTest < ActionController::TestCase |
| 218 | 218 | assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community |
| 219 | 219 | end |
| 220 | 220 | |
| 221 | + should "software_infos search return only the software in params order by Z-A" do | |
| 222 | + software_one = create_software_info("Software One", :acronym => "SFO", :finality => "Help") | |
| 223 | + software_two = create_software_info("Java", :acronym => "SFT", :finality => "Task") | |
| 224 | + software_three = create_software_info("Software Three", :acronym => "SFW", :finality => "Java") | |
| 225 | + | |
| 226 | + get( | |
| 227 | + :software_infos, | |
| 228 | + :only_softwares => ["software-three", "java"], | |
| 229 | + :sort => "desc" | |
| 230 | + ) | |
| 231 | + | |
| 232 | + assert_equal assigns(:searches)[:software_infos][:results][0], software_three.community | |
| 233 | + assert_equal assigns(:searches)[:software_infos][:results][1], software_two.community | |
| 234 | + assert_not_includes assigns(:searches)[:software_infos][:results], software_one.community | |
| 235 | + end | |
| 236 | + | |
| 237 | + | |
| 221 | 238 | should "software_infos search return only enabled softwares" do |
| 222 | 239 | s1 = SoftwareInfo.first |
| 223 | 240 | s2 = SoftwareInfo.last | ... | ... |
src/noosfero-spb/software_communities/views/search/_software_search_form.html.erb
| ... | ... | @@ -28,38 +28,39 @@ |
| 28 | 28 | |
| 29 | 29 | <%= submit_button(:search, _('Filter')) %> |
| 30 | 30 | </div> |
| 31 | - <%= render :partial => 'search_form_extra_fields' %> | |
| 32 | - <%= render :partial => 'catalog_filter' %> | |
| 33 | - <% end %> | |
| 34 | - </div> | |
| 31 | + <%= render :partial => 'search_form_extra_fields' %> | |
| 32 | + <%= render :partial => 'catalog_filter' %> | |
| 35 | 33 | |
| 36 | - <div id="catalog-display-options"> | |
| 37 | - <div id="catalog-display-options-count"> | |
| 38 | - <strong id="software-count"><%= "#{@software_count} Software(s)" %></strong> | |
| 39 | - </div> | |
| 40 | - | |
| 41 | - <div id="catalog-display-options-show-and-sort"> | |
| 42 | - <div id="catalog-display-options-show"> | |
| 43 | - <%= _('Show:') %> | |
| 44 | - <%= select_tag("software_display", | |
| 45 | - options_for_select(['15', '30', '90', 'All'], :selected=>params[:display]) | |
| 46 | - ) %> | |
| 47 | - </div> | |
| 34 | + <div id="catalog-display-options"> | |
| 35 | + <div id="catalog-display-options-count"> | |
| 36 | + <strong id="software-count"><%= "#{@software_count} Software(s)" %></strong> | |
| 37 | + </div> | |
| 48 | 38 | |
| 49 | - <div id="catalog-display-options-sort"> | |
| 50 | - <%= _('Sort by:') %> | |
| 51 | - <%= select_tag("sort", | |
| 52 | - options_for_select( | |
| 53 | - [ | |
| 54 | - [_("Name A-Z"), 'asc'], | |
| 55 | - [_("Name Z-A"), 'desc'], | |
| 56 | - [_("Relevance"), 'relevance'], | |
| 57 | - [_("Rating"), 'rating'] | |
| 58 | - ], :selected=>params[:sort]) | |
| 39 | + <div id="catalog-display-options-show-and-sort"> | |
| 40 | + <div id="catalog-display-options-show"> | |
| 41 | + <%= _('Show:') %> | |
| 42 | + <%= select_tag("software_display", | |
| 43 | + options_for_select(['15', '30', '90', 'All'], :selected=>params[:software_display]) | |
| 59 | 44 | ) %> |
| 45 | + </div> | |
| 46 | + | |
| 47 | + <div id="catalog-display-options-sort"> | |
| 48 | + <%= _('Sort by:') %> | |
| 49 | + <%= select_tag("sort", | |
| 50 | + options_for_select( | |
| 51 | + [ | |
| 52 | + [_("Name A-Z"), 'asc'], | |
| 53 | + [_("Name Z-A"), 'desc'], | |
| 54 | + [_("Relevance"), 'relevance'], | |
| 55 | + [_("Rating"), 'rating'] | |
| 56 | + ], :selected=>params[:sort]) | |
| 57 | + ) %> | |
| 58 | + </div> | |
| 59 | + </div> | |
| 60 | 60 | </div> |
| 61 | - </div> | |
| 61 | + <% end %> | |
| 62 | 62 | </div> |
| 63 | + | |
| 63 | 64 | </div> |
| 64 | 65 | |
| 65 | 66 | <% if @empty_query %> |
| ... | ... | @@ -68,3 +69,5 @@ |
| 68 | 69 | <div class="search-hint"><%= hint %></div> |
| 69 | 70 | <% end %> |
| 70 | 71 | <% end %> |
| 72 | + | |
| 73 | +<%= hidden_field_tag :only_softwares_hidden, params[:only_softwares] %> | ... | ... |