Commit 18e4c60b75f4e123207a75b946717d246b3cb49f
Committed by
Gabriela Navarro
1 parent
f6d72f7e
Exists in
master
and in
5 other branches
Add public_software filter, sort and page limit on ajax
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
7 changed files
with
62 additions
and
15 deletions
Show diff stats
features/software_catalog.feature
| ... | ... | @@ -17,36 +17,56 @@ Feature: Search software |
| 17 | 17 | | Software | Health | true | |
| 18 | 18 | | Software | Education | true | |
| 19 | 19 | And the following softwares |
| 20 | - | name | public_software | categories | | |
| 21 | - | Software One | true | Health | | |
| 22 | - | Software Two | false | Health, Education | | |
| 20 | + | name | public_software | categories | | |
| 21 | + | Software One | true | Health | | |
| 22 | + | Software Two | true | Health, Education | | |
| 23 | + | Software Three | false | Education | | |
| 23 | 24 | |
| 24 | 25 | |
| 25 | - Scenario: Show all softwares when open search page | |
| 26 | + Scenario: Show all "public_software" softwares when open search page | |
| 26 | 27 | Given I go to /search/software_infos |
| 27 | 28 | Then I should see "Software One" |
| 28 | 29 | Then I should see "Software Two" |
| 29 | 30 | |
| 30 | - Scenario: Show all softwares when search software | |
| 31 | + Scenario: Show all "public_software" softwares when search software | |
| 31 | 32 | Given I go to /search/software_infos |
| 32 | 33 | And I fill in "search-input" with "Software" |
| 33 | 34 | Then I should see "Software One" |
| 34 | 35 | Then I should see "Software Two" |
| 35 | 36 | |
| 36 | - Scenario: Show softwares one when search software one | |
| 37 | + Scenario: Show software "One" when searching for "Software One" | |
| 37 | 38 | Given I go to /search/software_infos |
| 38 | 39 | And I fill in "search-input" with "Software One" |
| 39 | - And I press "Search" | |
| 40 | + And I press "Filter" | |
| 40 | 41 | Then I should see "Software One" |
| 41 | 42 | Then I should not see "Software Two" |
| 42 | 43 | |
| 44 | + Scenario: Show software ordered by name when "Name A-Z" is selected | |
| 45 | + Given I go to /search/software_infos | |
| 46 | + And I select "Name A-Z" from "sort" | |
| 47 | + And I press "Filter" | |
| 48 | + Then I should see "Software One" before "Software Two" | |
| 49 | + | |
| 50 | + Scenario: Show software in reverse order by name when "Name Z-A" is selected | |
| 51 | + Given I go to /search/software_infos | |
| 52 | + And I select "Name Z-A" from "sort" | |
| 53 | + And I press "Filter" | |
| 54 | + Then I should see "Software Two" before "Software One" | |
| 55 | + | |
| 56 | + Scenario: Show softwares with selected category in filter | |
| 57 | + Given I go to /search/software_infos | |
| 58 | + And I follow "Education" | |
| 59 | + Then I should see "Software Two" | |
| 60 | + And I should not see "Software One" | |
| 61 | + | |
| 62 | + | |
| 43 | 63 | @selenium |
| 44 | 64 | Scenario: Show only "Software Two" when searching for "Education" category |
| 45 | 65 | Given I go to /search/software_infos |
| 46 | 66 | And I click on anything with selector "#filter-option-catalog-software" |
| 47 | 67 | And I check "Education" |
| 48 | 68 | Then I should see "Software Two" |
| 49 | - Then I should not see "Software One" | |
| 69 | + And I should not see "Software One" | |
| 50 | 70 | |
| 51 | 71 | @selenium |
| 52 | 72 | Scenario: Show both Software "One" and "Two" when searching for "Health" category |
| ... | ... | @@ -54,4 +74,13 @@ Feature: Search software |
| 54 | 74 | And I click on anything with selector "#filter-option-catalog-software" |
| 55 | 75 | And I check "Health" |
| 56 | 76 | Then I should see "Software One" |
| 57 | - Then I should see "Software Two" | |
| 77 | + And I should see "Software Two" | |
| 78 | + | |
| 79 | + @selenium | |
| 80 | + Scenario: Show not "public_software" when "Include in results" is checked | |
| 81 | + Given I go to /search/software_infos | |
| 82 | + And I click on anything with selector "#filter-option-catalog-software" | |
| 83 | + And I check "include_non_public" | |
| 84 | + Then I should see "Software One" | |
| 85 | + And I should see "Software Two" | |
| 86 | + And I should see "Software Three" | ... | ... |
features/step_definitions/mpog_steps.rb
| ... | ... | @@ -231,3 +231,7 @@ Given /^I am logged in as mpog_admin$/ do |
| 231 | 231 | fill_in("Password", :with => '123456') |
| 232 | 232 | click_button("Log in") |
| 233 | 233 | end |
| 234 | + | |
| 235 | +Given /^I should see "([^"]*)" before "([^"]*)"$/ do |before, after| | |
| 236 | + assert page.body.index("#{before}") < page.body.index("#{after}") | |
| 237 | +end | ... | ... |
lib/ext/search_controller.rb
| ... | ... | @@ -66,9 +66,11 @@ class SearchController |
| 66 | 66 | end |
| 67 | 67 | |
| 68 | 68 | filtered_community_list = [] |
| 69 | - filtered_software_list.each do |software| | |
| 70 | - filtered_community_list << software.community | |
| 71 | - end | |
| 69 | + filtered_software_list.each do |software| | |
| 70 | + if @include_non_public || software.public_software? | |
| 71 | + filtered_community_list << software.community | |
| 72 | + end | |
| 73 | + end | |
| 72 | 74 | |
| 73 | 75 | filtered_community_list.sort!{|a, b| a.name <=> b.name} |
| 74 | 76 | if params[:sort] && params[:sort] == "desc" |
| ... | ... | @@ -87,6 +89,7 @@ class SearchController |
| 87 | 89 | @selected_categories = params[:selected_categories] |
| 88 | 90 | @selected_categories ||= [] |
| 89 | 91 | @selected_categories = @selected_categories.map(&:to_i) |
| 92 | + @include_non_public = params[:include_non_public] == "true" | |
| 90 | 93 | |
| 91 | 94 | @message_selected_options = "" |
| 92 | 95 | unless @selected_categories.empty? | ... | ... |
public/software-catalog.js
test/helpers/plugin_test_helper.rb
views/search/_catalog_filter.html.erb
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | <% @categories_groupe_two.each do |category| %> |
| 24 | 24 | <label> |
| 25 | 25 | <%= check_box_tag("selected_categories[]", category.id, @selected_categories.include?(category.id), :class => "categories-catalog") %> |
| 26 | - <%= _("#{category.name}") %> | |
| 26 | + <%= _("#{category.name}") %> | |
| 27 | 27 | </label> <br> |
| 28 | 28 | <% end %> |
| 29 | 29 | <br /> |
| ... | ... | @@ -31,7 +31,10 @@ |
| 31 | 31 | </div> |
| 32 | 32 | |
| 33 | 33 | <div class="project-software"> <%= _("Software Projects:") %> |
| 34 | - <label><input type="checkbox" name="filter" value="Incluir nos resultados"> <%= _("Include in results") %> </label> | |
| 34 | + <label> | |
| 35 | + <%= check_box_tag("include_non_public", true, @include_non_public) %> | |
| 36 | + <%= _("Include in results") %> | |
| 37 | + </label> | |
| 35 | 38 | <span class"doubts-catalog-software" title="<%= _('Include software development projects that are not yet officially Brazilian Public Software.') %>">(?)</span> |
| 36 | 39 | </div> |
| 37 | 40 | <br /> | ... | ... |
views/search/_full_community.html.erb
| ... | ... | @@ -33,7 +33,12 @@ |
| 33 | 33 | <ul id="categories-list"> |
| 34 | 34 | <% community.categories.each do |category| %> |
| 35 | 35 | <li> |
| 36 | - <%= category.name %> | |
| 36 | + <%= link_to _("#{category.name}"), { | |
| 37 | + :controller => :search, | |
| 38 | + :action => :software_infos, | |
| 39 | + :selected_categories => [category.id], | |
| 40 | + :include_non_public => !community.software_info.public_software? | |
| 41 | + } %> | |
| 37 | 42 | </li> |
| 38 | 43 | <% end %> |
| 39 | 44 | </ul> | ... | ... |