diff --git a/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb b/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb index a2b3acb..569f34c 100644 --- a/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb +++ b/src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb @@ -1,6 +1,8 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController append_view_path File.join(File.dirname(__FILE__) + '/../views') + protect 'edit_software', :profile, :except => [:destroy_profile] + def index end diff --git a/src/noosfero-spb/software_communities/features/categories_and_tags_block.feature b/src/noosfero-spb/software_communities/features/categories_and_tags_block.feature index 116d8fc..b791809 100644 --- a/src/noosfero-spb/software_communities/features/categories_and_tags_block.feature +++ b/src/noosfero-spb/software_communities/features/categories_and_tags_block.feature @@ -23,8 +23,7 @@ Feature: go to software search when click on category | Software Three | false | Education | some finality | Scenario: Search softwares by education category - Given I am logged in as mpog_admin - And I go to software-three's control panel + Given I go to software-three's control panel And I follow "Edit sideboxes" And I follow "Add a block" And I choose "Categories and Tags" diff --git a/src/noosfero-spb/software_communities/features/public_software_validation.feature b/src/noosfero-spb/software_communities/features/public_software_validation.feature index 6f26b1d..4dd6f0b 100644 --- a/src/noosfero-spb/software_communities/features/public_software_validation.feature +++ b/src/noosfero-spb/software_communities/features/public_software_validation.feature @@ -10,25 +10,25 @@ Feature: edit adherent fields | joaosilva | Joao Silva | joaosilva@example.com | | mariasilva | Maria Silva | mariasilva@example.com | And the following softwares - | name | public_software | finality | - | basic software | true | basic software finality | + | name | public_software | finality | owner | + | basic software | true | basic software finality | joaosilva | And SoftwareInfo has initial default values on database And I am logged in as mpog_admin And I go to /admin/plugins And I check "SoftwareCommunitiesPlugin" Then I press "Save changes" - Scenario: Disable public software checkbox to non admin users + Scenario: Disable public software checkbox to non environment admin users Given I am logged in as "joaosilva" And I go to /myprofile/basic-software/plugin/software_communities/edit_software And I follow "Specifications" - Then I should see "Public software" within ".public_software_disabled" + Then the "#software_public_software" button should be disabled Scenario: Enable public software checkbox to admin users Given I am logged in as mpog_admin And I go to /myprofile/basic-software/plugin/software_communities/edit_software And I follow "Specifications" - Then I should see "Public software" within ".public_software_enabled" + Then the "#software_public_software" button should be enabled @selenium Scenario: Show adherent fields when checkbox are checked diff --git a/src/noosfero-spb/software_communities/features/software_block.feature b/src/noosfero-spb/software_communities/features/software_block.feature index ac511ca..da10d97 100644 --- a/src/noosfero-spb/software_communities/features/software_block.feature +++ b/src/noosfero-spb/software_communities/features/software_block.feature @@ -15,8 +15,7 @@ Feature: edit adherent fields | Generic Software | false | some finality | Scenario: Add software block - Given I am logged in as mpog_admin - And I follow "Control panel" + Given I follow "Control panel" And I follow "Edit sideboxes" When I follow "Add a block" And I choose "Softwares" @@ -24,9 +23,7 @@ Feature: edit adherent fields Then I should see "softwares" Scenario: Change software block to generic software block - Given I am logged in as mpog_admin - And I go to /myprofile/mpog_admin - And I follow "Control panel" + Given I follow "Control panel" And I follow "Edit sideboxes" When I follow "Add a block" And I choose "Softwares" @@ -37,8 +34,7 @@ Feature: edit adherent fields Then I should see "generic software" Scenario: Change software block to generic software block - Given I am logged in as mpog_admin - And I follow "Control panel" + Given I follow "Control panel" And I follow "Edit sideboxes" When I follow "Add a block" And I choose "Softwares" diff --git a/src/noosfero-spb/software_communities/features/software_catalog.feature b/src/noosfero-spb/software_communities/features/software_catalog.feature index 8bb6207..a8894b0 100644 --- a/src/noosfero-spb/software_communities/features/software_catalog.feature +++ b/src/noosfero-spb/software_communities/features/software_catalog.feature @@ -46,7 +46,7 @@ Feature: Search software 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" + And I sleep for 3 seconds Then I should see "Software One" before "Software Two" @selenium @@ -59,7 +59,7 @@ Feature: Search software @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 click on anything with selector "filter-option-catalog-software" And I check "Education" Then I should see "Software Two" And I should not see "Software One" @@ -67,7 +67,7 @@ Feature: Search software @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 click on anything with selector "filter-option-catalog-software" And I check "Health" Then I should see "Software One" And I should see "Software Two" @@ -75,8 +75,7 @@ Feature: Search software @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" + And I choose "all_radio_button" Then I should see "Software One" And I should see "Software Two" And I should see "Software Three" @@ -107,6 +106,5 @@ Feature: Search software When I select "Favorites" from "sort" And I sleep for 3 seconds Then I should see "Software Two" before "Software One" - And there should be 1 div with class "small-star-positive" - And there should be 4 divs with class "small-star-negative" - + And I should see "1" of this selector "div.medium-star-positive" + And I should see "4" of this selector "div.medium-star-negative" diff --git a/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb b/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb index 4fbd4c2..e6bd128 100644 --- a/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb +++ b/src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb @@ -175,7 +175,8 @@ end Given /^the following softwares$/ do |table| table.hashes.each do |item| software_info = SoftwareInfo.new - software_info.community = Community.create(:name=>item[:name]) + community = Community.create(:name=>item[:name]) + software_info.community = community software_info.finality = item[:finality] if item[:finality] software_info.acronym = item[:acronym] if item[:acronym] @@ -211,10 +212,15 @@ Given /^the following softwares$/ do |table| categories.each do |category_name| category = Category.find_by_name category_name - software_info.community.categories << category + community.categories << category end end + if item[:owner] + owner = item[:owner] + community.add_admin Profile[owner] + end + software_info.save! end end diff --git a/src/noosfero-spb/software_communities/features/use_report.feature b/src/noosfero-spb/software_communities/features/use_report.feature index 853cfd8..bc67450 100644 --- a/src/noosfero-spb/software_communities/features/use_report.feature +++ b/src/noosfero-spb/software_communities/features/use_report.feature @@ -34,10 +34,10 @@ Feature: Use report Scenario: Test Additional Fields JavaScript Given I go to /profile/noosfero/plugin/organization_ratings/new_rating Then I should not see "Number of Beneficiaries" - And I should not see "Saved Resources" + And I should not see "Saved resources" When I click on anything with selector "comments-additional-information" Then I should see "Number of Beneficiaries" - And I should see "Saved Resources" + And I should see "Saved resources" @selenium Scenario: Validate Use Report fields format @@ -49,8 +49,8 @@ Feature: Use report And I am on Noosfero's homepage And I follow "Rate Community" When I click on anything with selector "comments-additional-information" - And I fill in "organization_rating_people_benefited" with "123123" - And I fill in "organization_rating_saved_value" with "7654321" + And I fill in "people_benefited_tmp" with "123123" + And I fill in "saved_value_tmp" with "7654321" And I press "Save" - Then I should see "Benefited People: 123.123" - And I should see "Saved Resources: $ 76,543.21" + Then I should see "Benefited People: 123,123" + And I should see "Saved Resources: $76,543.21" diff --git a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb index 2af30f8..5aae9cf 100644 --- a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb @@ -62,6 +62,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC fields = software_edit_basic_fields software = create_software fields_software + + software.community.add_admin(@person) + software.save! + post( :edit_software, :profile => software.community.identifier, @@ -80,6 +84,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC fields = software_edit_specific_fields software = create_software fields_software + + software.community.add_admin(@person) + software.save! + post( :edit_software, :profile => software.community.identifier, @@ -93,6 +101,29 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC assert_equal SoftwareInfo.last.acronym, "test" end + should 'non admin cant edit a new software' do + fields_software = software_fields + fields = software_edit_specific_fields + + software = create_software fields_software + + software.community.add_admin(@person) + software.save! + + post( + :edit_software, + :profile => software.community.identifier, + :library => fields[0], + :language => fields[1], + :database => fields[2], + :operating_system => fields[3], + :software => fields[4], + :license => fields[5] + ) + + assert_response 302 + end + should 'only admin upgrade a generic software to a public software' do admin_person = create_user('admin').person @environment.add_admin(admin_person) -- libgit2 0.21.2