diff --git a/features/software_catalog.feature b/features/software_catalog.feature new file mode 100644 index 0000000..0def111 --- /dev/null +++ b/features/software_catalog.feature @@ -0,0 +1,57 @@ +Feature: Search software + As a user + I want to be able to search catalogued software + So that I find a software that fit my needs + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And I am logged in as mpog_admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + And I go to /account/logout + And the following categories + | name | display_in_menu | + | Software | true | + And the following categories + | parent | name | display_in_menu | + | Software | Health | true | + | Software | Education | true | + And the following softwares + | name | public_software | categories | + | Software One | true | Health | + | Software Two | false | Health, Education | + + + Scenario: Show all 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 + 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 + Given I go to /search/software_infos + And I fill in "search-input" with "Software One" + And I press "Search" + Then I should see "Software One" + Then I should not see "Software Two" + + @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" + + @selenium + Scenario: Show both Software "One" and "Two" when searching for "Health" category + Given I go to /search/software_infos + 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" diff --git a/features/step_definitions/mpog_steps.rb b/features/step_definitions/mpog_steps.rb index 2fbb304..9648984 100644 --- a/features/step_definitions/mpog_steps.rb +++ b/features/step_definitions/mpog_steps.rb @@ -155,6 +155,16 @@ Given /^the following softwares$/ do |table| software_info.operating_systems << operating_system end + if item[:categories] + categories = item[:categories].split(",") + categories.map! {|category| category.strip} + + categories.each do |category_name| + category = Category.find_by_name category_name + software_info.community.categories << category + end + end + software_info.save! end end -- libgit2 0.21.2