diff --git a/features/software_catalog.feature b/features/software_catalog.feature
index 0def111..d40ac69 100644
--- a/features/software_catalog.feature
+++ b/features/software_catalog.feature
@@ -17,36 +17,56 @@ Feature: Search software
| Software | Health | true |
| Software | Education | true |
And the following softwares
- | name | public_software | categories |
- | Software One | true | Health |
- | Software Two | false | Health, Education |
+ | name | public_software | categories |
+ | Software One | true | Health |
+ | Software Two | true | Health, Education |
+ | Software Three | false | Education |
- Scenario: Show all softwares when open search page
+ Scenario: Show all "public_software" softwares when open search page
Given I go to /search/software_infos
Then I should see "Software One"
Then I should see "Software Two"
- Scenario: Show all softwares when search software
+ Scenario: Show all "public_software" softwares when search software
Given I go to /search/software_infos
And I fill in "search-input" with "Software"
Then I should see "Software One"
Then I should see "Software Two"
- Scenario: Show softwares one when search software one
+ Scenario: Show software "One" when searching for "Software One"
Given I go to /search/software_infos
And I fill in "search-input" with "Software One"
- And I press "Search"
+ And I press "Filter"
Then I should see "Software One"
Then I should not see "Software Two"
+ Scenario: Show software ordered by name when "Name A-Z" is selected
+ Given I go to /search/software_infos
+ And I select "Name A-Z" from "sort"
+ And I press "Filter"
+ Then I should see "Software One" before "Software Two"
+
+ Scenario: Show software in reverse order by name when "Name Z-A" is selected
+ Given I go to /search/software_infos
+ And I select "Name Z-A" from "sort"
+ And I press "Filter"
+ Then I should see "Software Two" before "Software One"
+
+ Scenario: Show softwares with selected category in filter
+ Given I go to /search/software_infos
+ And I follow "Education"
+ Then I should see "Software Two"
+ And I should not see "Software One"
+
+
@selenium
Scenario: Show only "Software Two" when searching for "Education" category
Given I go to /search/software_infos
And I click on anything with selector "#filter-option-catalog-software"
And I check "Education"
Then I should see "Software Two"
- Then I should not see "Software One"
+ And I should not see "Software One"
@selenium
Scenario: Show both Software "One" and "Two" when searching for "Health" category
@@ -54,4 +74,13 @@ Feature: Search software
And I click on anything with selector "#filter-option-catalog-software"
And I check "Health"
Then I should see "Software One"
- Then I should see "Software Two"
+ And I should see "Software Two"
+
+ @selenium
+ Scenario: Show not "public_software" when "Include in results" is checked
+ Given I go to /search/software_infos
+ And I click on anything with selector "#filter-option-catalog-software"
+ And I check "include_non_public"
+ Then I should see "Software One"
+ And I should see "Software Two"
+ And I should see "Software Three"
diff --git a/features/step_definitions/mpog_steps.rb b/features/step_definitions/mpog_steps.rb
index 9648984..d6b4a1f 100644
--- a/features/step_definitions/mpog_steps.rb
+++ b/features/step_definitions/mpog_steps.rb
@@ -231,3 +231,7 @@ Given /^I am logged in as mpog_admin$/ do
fill_in("Password", :with => '123456')
click_button("Log in")
end
+
+Given /^I should see "([^"]*)" before "([^"]*)"$/ do |before, after|
+ assert page.body.index("#{before}") < page.body.index("#{after}")
+end
diff --git a/lib/ext/search_controller.rb b/lib/ext/search_controller.rb
index 2664869..223e07c 100644
--- a/lib/ext/search_controller.rb
+++ b/lib/ext/search_controller.rb
@@ -66,9 +66,11 @@ class SearchController
end
filtered_community_list = []
- filtered_software_list.each do |software|
- filtered_community_list << software.community
- end
+ filtered_software_list.each do |software|
+ if @include_non_public || software.public_software?
+ filtered_community_list << software.community
+ end
+ end
filtered_community_list.sort!{|a, b| a.name <=> b.name}
if params[:sort] && params[:sort] == "desc"
@@ -87,6 +89,7 @@ class SearchController
@selected_categories = params[:selected_categories]
@selected_categories ||= []
@selected_categories = @selected_categories.map(&:to_i)
+ @include_non_public = params[:include_non_public] == "true"
@message_selected_options = ""
unless @selected_categories.empty?
diff --git a/public/software-catalog.js b/public/software-catalog.js
index ef6bdbe..bbc72f1 100644
--- a/public/software-catalog.js
+++ b/public/software-catalog.js
@@ -88,6 +88,8 @@
params.software_display = $("#software_display").val();
params.sort = $("#sort").val();
+ params.include_non_public = $("#include_non_public").is(":checked");
+
return params;
}
diff --git a/test/helpers/plugin_test_helper.rb b/test/helpers/plugin_test_helper.rb
index a3f0063..d0f0b6b 100644
--- a/test/helpers/plugin_test_helper.rb
+++ b/test/helpers/plugin_test_helper.rb
@@ -17,6 +17,7 @@ module PluginTestHelper
community = create_community(name)
software_info = SoftwareInfo.new
software_info.community = community
+ software_info.public_software = true
software_info.save
software_info
end
diff --git a/views/search/_catalog_filter.html.erb b/views/search/_catalog_filter.html.erb
index 0974c8c..3989699 100644
--- a/views/search/_catalog_filter.html.erb
+++ b/views/search/_catalog_filter.html.erb
@@ -23,7 +23,7 @@
<% @categories_groupe_two.each do |category| %>
<% end %>
@@ -31,7 +31,10 @@