Commit 552b8ad5138ad3fcf98becebe9f9906b8cdec719
Committed by
Daniela Feitosa
1 parent
7233d84e
Exists in
master
and in
36 other branches
Adds permission filter to edit_software action
Also fixes software_communities tests - Fixes cucumber and selenium tests - Check permission on functional tests of edit software Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
8 changed files
with
62 additions
and
30 deletions
Show diff stats
src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb
1 | class SoftwareCommunitiesPluginMyprofileController < MyProfileController | 1 | class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
2 | append_view_path File.join(File.dirname(__FILE__) + '/../views') | 2 | append_view_path File.join(File.dirname(__FILE__) + '/../views') |
3 | 3 | ||
4 | + protect 'edit_software', :profile, :except => [:destroy_profile] | ||
5 | + | ||
4 | def index | 6 | def index |
5 | end | 7 | end |
6 | 8 |
src/noosfero-spb/software_communities/features/categories_and_tags_block.feature
@@ -23,8 +23,7 @@ Feature: go to software search when click on category | @@ -23,8 +23,7 @@ Feature: go to software search when click on category | ||
23 | | Software Three | false | Education | some finality | | 23 | | Software Three | false | Education | some finality | |
24 | 24 | ||
25 | Scenario: Search softwares by education category | 25 | Scenario: Search softwares by education category |
26 | - Given I am logged in as mpog_admin | ||
27 | - And I go to software-three's control panel | 26 | + Given I go to software-three's control panel |
28 | And I follow "Edit sideboxes" | 27 | And I follow "Edit sideboxes" |
29 | And I follow "Add a block" | 28 | And I follow "Add a block" |
30 | And I choose "Categories and Tags" | 29 | And I choose "Categories and Tags" |
src/noosfero-spb/software_communities/features/public_software_validation.feature
@@ -10,25 +10,25 @@ Feature: edit adherent fields | @@ -10,25 +10,25 @@ Feature: edit adherent fields | ||
10 | | joaosilva | Joao Silva | joaosilva@example.com | | 10 | | joaosilva | Joao Silva | joaosilva@example.com | |
11 | | mariasilva | Maria Silva | mariasilva@example.com | | 11 | | mariasilva | Maria Silva | mariasilva@example.com | |
12 | And the following softwares | 12 | And the following softwares |
13 | - | name | public_software | finality | | ||
14 | - | basic software | true | basic software finality | | 13 | + | name | public_software | finality | owner | |
14 | + | basic software | true | basic software finality | joaosilva | | ||
15 | And SoftwareInfo has initial default values on database | 15 | And SoftwareInfo has initial default values on database |
16 | And I am logged in as mpog_admin | 16 | And I am logged in as mpog_admin |
17 | And I go to /admin/plugins | 17 | And I go to /admin/plugins |
18 | And I check "SoftwareCommunitiesPlugin" | 18 | And I check "SoftwareCommunitiesPlugin" |
19 | Then I press "Save changes" | 19 | Then I press "Save changes" |
20 | 20 | ||
21 | - Scenario: Disable public software checkbox to non admin users | 21 | + Scenario: Disable public software checkbox to non environment admin users |
22 | Given I am logged in as "joaosilva" | 22 | Given I am logged in as "joaosilva" |
23 | And I go to /myprofile/basic-software/plugin/software_communities/edit_software | 23 | And I go to /myprofile/basic-software/plugin/software_communities/edit_software |
24 | And I follow "Specifications" | 24 | And I follow "Specifications" |
25 | - Then I should see "Public software" within ".public_software_disabled" | 25 | + Then the "#software_public_software" button should be disabled |
26 | 26 | ||
27 | Scenario: Enable public software checkbox to admin users | 27 | Scenario: Enable public software checkbox to admin users |
28 | Given I am logged in as mpog_admin | 28 | Given I am logged in as mpog_admin |
29 | And I go to /myprofile/basic-software/plugin/software_communities/edit_software | 29 | And I go to /myprofile/basic-software/plugin/software_communities/edit_software |
30 | And I follow "Specifications" | 30 | And I follow "Specifications" |
31 | - Then I should see "Public software" within ".public_software_enabled" | 31 | + Then the "#software_public_software" button should be enabled |
32 | 32 | ||
33 | @selenium | 33 | @selenium |
34 | Scenario: Show adherent fields when checkbox are checked | 34 | Scenario: Show adherent fields when checkbox are checked |
src/noosfero-spb/software_communities/features/software_block.feature
@@ -15,8 +15,7 @@ Feature: edit adherent fields | @@ -15,8 +15,7 @@ Feature: edit adherent fields | ||
15 | | Generic Software | false | some finality | | 15 | | Generic Software | false | some finality | |
16 | 16 | ||
17 | Scenario: Add software block | 17 | Scenario: Add software block |
18 | - Given I am logged in as mpog_admin | ||
19 | - And I follow "Control panel" | 18 | + Given I follow "Control panel" |
20 | And I follow "Edit sideboxes" | 19 | And I follow "Edit sideboxes" |
21 | When I follow "Add a block" | 20 | When I follow "Add a block" |
22 | And I choose "Softwares" | 21 | And I choose "Softwares" |
@@ -24,9 +23,7 @@ Feature: edit adherent fields | @@ -24,9 +23,7 @@ Feature: edit adherent fields | ||
24 | Then I should see "softwares" | 23 | Then I should see "softwares" |
25 | 24 | ||
26 | Scenario: Change software block to generic software block | 25 | Scenario: Change software block to generic software block |
27 | - Given I am logged in as mpog_admin | ||
28 | - And I go to /myprofile/mpog_admin | ||
29 | - And I follow "Control panel" | 26 | + Given I follow "Control panel" |
30 | And I follow "Edit sideboxes" | 27 | And I follow "Edit sideboxes" |
31 | When I follow "Add a block" | 28 | When I follow "Add a block" |
32 | And I choose "Softwares" | 29 | And I choose "Softwares" |
@@ -37,8 +34,7 @@ Feature: edit adherent fields | @@ -37,8 +34,7 @@ Feature: edit adherent fields | ||
37 | Then I should see "generic software" | 34 | Then I should see "generic software" |
38 | 35 | ||
39 | Scenario: Change software block to generic software block | 36 | Scenario: Change software block to generic software block |
40 | - Given I am logged in as mpog_admin | ||
41 | - And I follow "Control panel" | 37 | + Given I follow "Control panel" |
42 | And I follow "Edit sideboxes" | 38 | And I follow "Edit sideboxes" |
43 | When I follow "Add a block" | 39 | When I follow "Add a block" |
44 | And I choose "Softwares" | 40 | And I choose "Softwares" |
src/noosfero-spb/software_communities/features/software_catalog.feature
@@ -46,7 +46,7 @@ Feature: Search software | @@ -46,7 +46,7 @@ Feature: Search software | ||
46 | Scenario: Show software ordered by name when "Name A-Z" is selected | 46 | Scenario: Show software ordered by name when "Name A-Z" is selected |
47 | Given I go to /search/software_infos | 47 | Given I go to /search/software_infos |
48 | And I select "Name A-Z" from "sort" | 48 | And I select "Name A-Z" from "sort" |
49 | - And I press "Filter" | 49 | + And I sleep for 3 seconds |
50 | Then I should see "Software One" before "Software Two" | 50 | Then I should see "Software One" before "Software Two" |
51 | 51 | ||
52 | @selenium | 52 | @selenium |
@@ -59,7 +59,7 @@ Feature: Search software | @@ -59,7 +59,7 @@ Feature: Search software | ||
59 | @selenium | 59 | @selenium |
60 | Scenario: Show only "Software Two" when searching for "Education" category | 60 | Scenario: Show only "Software Two" when searching for "Education" category |
61 | Given I go to /search/software_infos | 61 | Given I go to /search/software_infos |
62 | - And I click on anything with selector "#filter-option-catalog-software" | 62 | + And I click on anything with selector "filter-option-catalog-software" |
63 | And I check "Education" | 63 | And I check "Education" |
64 | Then I should see "Software Two" | 64 | Then I should see "Software Two" |
65 | And I should not see "Software One" | 65 | And I should not see "Software One" |
@@ -67,7 +67,7 @@ Feature: Search software | @@ -67,7 +67,7 @@ Feature: Search software | ||
67 | @selenium | 67 | @selenium |
68 | Scenario: Show both Software "One" and "Two" when searching for "Health" category | 68 | Scenario: Show both Software "One" and "Two" when searching for "Health" category |
69 | Given I go to /search/software_infos | 69 | Given I go to /search/software_infos |
70 | - And I click on anything with selector "#filter-option-catalog-software" | 70 | + And I click on anything with selector "filter-option-catalog-software" |
71 | And I check "Health" | 71 | And I check "Health" |
72 | Then I should see "Software One" | 72 | Then I should see "Software One" |
73 | And I should see "Software Two" | 73 | And I should see "Software Two" |
@@ -75,8 +75,7 @@ Feature: Search software | @@ -75,8 +75,7 @@ Feature: Search software | ||
75 | @selenium | 75 | @selenium |
76 | Scenario: Show not "public_software" when "Include in results" is checked | 76 | Scenario: Show not "public_software" when "Include in results" is checked |
77 | Given I go to /search/software_infos | 77 | Given I go to /search/software_infos |
78 | - And I click on anything with selector "#filter-option-catalog-software" | ||
79 | - And I check "include_non_public" | 78 | + And I choose "all_radio_button" |
80 | Then I should see "Software One" | 79 | Then I should see "Software One" |
81 | And I should see "Software Two" | 80 | And I should see "Software Two" |
82 | And I should see "Software Three" | 81 | And I should see "Software Three" |
@@ -107,6 +106,5 @@ Feature: Search software | @@ -107,6 +106,5 @@ Feature: Search software | ||
107 | When I select "Favorites" from "sort" | 106 | When I select "Favorites" from "sort" |
108 | And I sleep for 3 seconds | 107 | And I sleep for 3 seconds |
109 | Then I should see "Software Two" before "Software One" | 108 | Then I should see "Software Two" before "Software One" |
110 | - And there should be 1 div with class "small-star-positive" | ||
111 | - And there should be 4 divs with class "small-star-negative" | ||
112 | - | 109 | + And I should see "1" of this selector "div.medium-star-positive" |
110 | + And I should see "4" of this selector "div.medium-star-negative" |
src/noosfero-spb/software_communities/features/step_definitions/software_communities_steps.rb
@@ -175,7 +175,8 @@ end | @@ -175,7 +175,8 @@ end | ||
175 | Given /^the following softwares$/ do |table| | 175 | Given /^the following softwares$/ do |table| |
176 | table.hashes.each do |item| | 176 | table.hashes.each do |item| |
177 | software_info = SoftwareInfo.new | 177 | software_info = SoftwareInfo.new |
178 | - software_info.community = Community.create(:name=>item[:name]) | 178 | + community = Community.create(:name=>item[:name]) |
179 | + software_info.community = community | ||
179 | 180 | ||
180 | software_info.finality = item[:finality] if item[:finality] | 181 | software_info.finality = item[:finality] if item[:finality] |
181 | software_info.acronym = item[:acronym] if item[:acronym] | 182 | software_info.acronym = item[:acronym] if item[:acronym] |
@@ -211,10 +212,15 @@ Given /^the following softwares$/ do |table| | @@ -211,10 +212,15 @@ Given /^the following softwares$/ do |table| | ||
211 | 212 | ||
212 | categories.each do |category_name| | 213 | categories.each do |category_name| |
213 | category = Category.find_by_name category_name | 214 | category = Category.find_by_name category_name |
214 | - software_info.community.categories << category | 215 | + community.categories << category |
215 | end | 216 | end |
216 | end | 217 | end |
217 | 218 | ||
219 | + if item[:owner] | ||
220 | + owner = item[:owner] | ||
221 | + community.add_admin Profile[owner] | ||
222 | + end | ||
223 | + | ||
218 | software_info.save! | 224 | software_info.save! |
219 | end | 225 | end |
220 | end | 226 | end |
src/noosfero-spb/software_communities/features/use_report.feature
@@ -34,10 +34,10 @@ Feature: Use report | @@ -34,10 +34,10 @@ Feature: Use report | ||
34 | Scenario: Test Additional Fields JavaScript | 34 | Scenario: Test Additional Fields JavaScript |
35 | Given I go to /profile/noosfero/plugin/organization_ratings/new_rating | 35 | Given I go to /profile/noosfero/plugin/organization_ratings/new_rating |
36 | Then I should not see "Number of Beneficiaries" | 36 | Then I should not see "Number of Beneficiaries" |
37 | - And I should not see "Saved Resources" | 37 | + And I should not see "Saved resources" |
38 | When I click on anything with selector "comments-additional-information" | 38 | When I click on anything with selector "comments-additional-information" |
39 | Then I should see "Number of Beneficiaries" | 39 | Then I should see "Number of Beneficiaries" |
40 | - And I should see "Saved Resources" | 40 | + And I should see "Saved resources" |
41 | 41 | ||
42 | @selenium | 42 | @selenium |
43 | Scenario: Validate Use Report fields format | 43 | Scenario: Validate Use Report fields format |
@@ -49,8 +49,8 @@ Feature: Use report | @@ -49,8 +49,8 @@ Feature: Use report | ||
49 | And I am on Noosfero's homepage | 49 | And I am on Noosfero's homepage |
50 | And I follow "Rate Community" | 50 | And I follow "Rate Community" |
51 | When I click on anything with selector "comments-additional-information" | 51 | When I click on anything with selector "comments-additional-information" |
52 | - And I fill in "organization_rating_people_benefited" with "123123" | ||
53 | - And I fill in "organization_rating_saved_value" with "7654321" | 52 | + And I fill in "people_benefited_tmp" with "123123" |
53 | + And I fill in "saved_value_tmp" with "7654321" | ||
54 | And I press "Save" | 54 | And I press "Save" |
55 | - Then I should see "Benefited People: 123.123" | ||
56 | - And I should see "Saved Resources: $ 76,543.21" | 55 | + Then I should see "Benefited People: 123,123" |
56 | + And I should see "Saved Resources: $76,543.21" |
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb
@@ -62,6 +62,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | @@ -62,6 +62,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | ||
62 | fields = software_edit_basic_fields | 62 | fields = software_edit_basic_fields |
63 | 63 | ||
64 | software = create_software fields_software | 64 | software = create_software fields_software |
65 | + | ||
66 | + software.community.add_admin(@person) | ||
67 | + software.save! | ||
68 | + | ||
65 | post( | 69 | post( |
66 | :edit_software, | 70 | :edit_software, |
67 | :profile => software.community.identifier, | 71 | :profile => software.community.identifier, |
@@ -80,6 +84,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | @@ -80,6 +84,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | ||
80 | fields = software_edit_specific_fields | 84 | fields = software_edit_specific_fields |
81 | 85 | ||
82 | software = create_software fields_software | 86 | software = create_software fields_software |
87 | + | ||
88 | + software.community.add_admin(@person) | ||
89 | + software.save! | ||
90 | + | ||
83 | post( | 91 | post( |
84 | :edit_software, | 92 | :edit_software, |
85 | :profile => software.community.identifier, | 93 | :profile => software.community.identifier, |
@@ -93,6 +101,29 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | @@ -93,6 +101,29 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC | ||
93 | assert_equal SoftwareInfo.last.acronym, "test" | 101 | assert_equal SoftwareInfo.last.acronym, "test" |
94 | end | 102 | end |
95 | 103 | ||
104 | + should 'non admin cant edit a new software' do | ||
105 | + fields_software = software_fields | ||
106 | + fields = software_edit_specific_fields | ||
107 | + | ||
108 | + software = create_software fields_software | ||
109 | + | ||
110 | + software.community.add_admin(@person) | ||
111 | + software.save! | ||
112 | + | ||
113 | + post( | ||
114 | + :edit_software, | ||
115 | + :profile => software.community.identifier, | ||
116 | + :library => fields[0], | ||
117 | + :language => fields[1], | ||
118 | + :database => fields[2], | ||
119 | + :operating_system => fields[3], | ||
120 | + :software => fields[4], | ||
121 | + :license => fields[5] | ||
122 | + ) | ||
123 | + | ||
124 | + assert_response 302 | ||
125 | + end | ||
126 | + | ||
96 | should 'only admin upgrade a generic software to a public software' do | 127 | should 'only admin upgrade a generic software to a public software' do |
97 | admin_person = create_user('admin').person | 128 | admin_person = create_user('admin').person |
98 | @environment.add_admin(admin_person) | 129 | @environment.add_admin(admin_person) |