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,36 +17,56 @@ Feature: Search software | ||
17 | | Software | Health | true | | 17 | | Software | Health | true | |
18 | | Software | Education | true | | 18 | | Software | Education | true | |
19 | And the following softwares | 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 | Given I go to /search/software_infos | 27 | Given I go to /search/software_infos |
27 | Then I should see "Software One" | 28 | Then I should see "Software One" |
28 | Then I should see "Software Two" | 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 | Given I go to /search/software_infos | 32 | Given I go to /search/software_infos |
32 | And I fill in "search-input" with "Software" | 33 | And I fill in "search-input" with "Software" |
33 | Then I should see "Software One" | 34 | Then I should see "Software One" |
34 | Then I should see "Software Two" | 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 | Given I go to /search/software_infos | 38 | Given I go to /search/software_infos |
38 | And I fill in "search-input" with "Software One" | 39 | And I fill in "search-input" with "Software One" |
39 | - And I press "Search" | 40 | + And I press "Filter" |
40 | Then I should see "Software One" | 41 | Then I should see "Software One" |
41 | Then I should not see "Software Two" | 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 | @selenium | 63 | @selenium |
44 | Scenario: Show only "Software Two" when searching for "Education" category | 64 | Scenario: Show only "Software Two" when searching for "Education" category |
45 | Given I go to /search/software_infos | 65 | Given I go to /search/software_infos |
46 | And I click on anything with selector "#filter-option-catalog-software" | 66 | And I click on anything with selector "#filter-option-catalog-software" |
47 | And I check "Education" | 67 | And I check "Education" |
48 | Then I should see "Software Two" | 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 | @selenium | 71 | @selenium |
52 | Scenario: Show both Software "One" and "Two" when searching for "Health" category | 72 | Scenario: Show both Software "One" and "Two" when searching for "Health" category |
@@ -54,4 +74,13 @@ Feature: Search software | @@ -54,4 +74,13 @@ Feature: Search software | ||
54 | And I click on anything with selector "#filter-option-catalog-software" | 74 | And I click on anything with selector "#filter-option-catalog-software" |
55 | And I check "Health" | 75 | And I check "Health" |
56 | Then I should see "Software One" | 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,3 +231,7 @@ Given /^I am logged in as mpog_admin$/ do | ||
231 | fill_in("Password", :with => '123456') | 231 | fill_in("Password", :with => '123456') |
232 | click_button("Log in") | 232 | click_button("Log in") |
233 | end | 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,9 +66,11 @@ class SearchController | ||
66 | end | 66 | end |
67 | 67 | ||
68 | filtered_community_list = [] | 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 | filtered_community_list.sort!{|a, b| a.name <=> b.name} | 75 | filtered_community_list.sort!{|a, b| a.name <=> b.name} |
74 | if params[:sort] && params[:sort] == "desc" | 76 | if params[:sort] && params[:sort] == "desc" |
@@ -87,6 +89,7 @@ class SearchController | @@ -87,6 +89,7 @@ class SearchController | ||
87 | @selected_categories = params[:selected_categories] | 89 | @selected_categories = params[:selected_categories] |
88 | @selected_categories ||= [] | 90 | @selected_categories ||= [] |
89 | @selected_categories = @selected_categories.map(&:to_i) | 91 | @selected_categories = @selected_categories.map(&:to_i) |
92 | + @include_non_public = params[:include_non_public] == "true" | ||
90 | 93 | ||
91 | @message_selected_options = "" | 94 | @message_selected_options = "" |
92 | unless @selected_categories.empty? | 95 | unless @selected_categories.empty? |
public/software-catalog.js
@@ -88,6 +88,8 @@ | @@ -88,6 +88,8 @@ | ||
88 | params.software_display = $("#software_display").val(); | 88 | params.software_display = $("#software_display").val(); |
89 | params.sort = $("#sort").val(); | 89 | params.sort = $("#sort").val(); |
90 | 90 | ||
91 | + params.include_non_public = $("#include_non_public").is(":checked"); | ||
92 | + | ||
91 | return params; | 93 | return params; |
92 | } | 94 | } |
93 | 95 |
test/helpers/plugin_test_helper.rb
@@ -17,6 +17,7 @@ module PluginTestHelper | @@ -17,6 +17,7 @@ module PluginTestHelper | ||
17 | community = create_community(name) | 17 | community = create_community(name) |
18 | software_info = SoftwareInfo.new | 18 | software_info = SoftwareInfo.new |
19 | software_info.community = community | 19 | software_info.community = community |
20 | + software_info.public_software = true | ||
20 | software_info.save | 21 | software_info.save |
21 | software_info | 22 | software_info |
22 | end | 23 | end |
views/search/_catalog_filter.html.erb
@@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
23 | <% @categories_groupe_two.each do |category| %> | 23 | <% @categories_groupe_two.each do |category| %> |
24 | <label> | 24 | <label> |
25 | <%= check_box_tag("selected_categories[]", category.id, @selected_categories.include?(category.id), :class => "categories-catalog") %> | 25 | <%= check_box_tag("selected_categories[]", category.id, @selected_categories.include?(category.id), :class => "categories-catalog") %> |
26 | - <%= _("#{category.name}") %> | 26 | + <%= _("#{category.name}") %> |
27 | </label> <br> | 27 | </label> <br> |
28 | <% end %> | 28 | <% end %> |
29 | <br /> | 29 | <br /> |
@@ -31,7 +31,10 @@ | @@ -31,7 +31,10 @@ | ||
31 | </div> | 31 | </div> |
32 | 32 | ||
33 | <div class="project-software"> <%= _("Software Projects:") %> | 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 | <span class"doubts-catalog-software" title="<%= _('Include software development projects that are not yet officially Brazilian Public Software.') %>">(?)</span> | 38 | <span class"doubts-catalog-software" title="<%= _('Include software development projects that are not yet officially Brazilian Public Software.') %>">(?)</span> |
36 | </div> | 39 | </div> |
37 | <br /> | 40 | <br /> |
views/search/_full_community.html.erb
@@ -33,7 +33,12 @@ | @@ -33,7 +33,12 @@ | ||
33 | <ul id="categories-list"> | 33 | <ul id="categories-list"> |
34 | <% community.categories.each do |category| %> | 34 | <% community.categories.each do |category| %> |
35 | <li> | 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 | </li> | 42 | </li> |
38 | <% end %> | 43 | <% end %> |
39 | </ul> | 44 | </ul> |