Commit c8e26bfb0b004415e3ca4bd3c8ad92451d079286
Exists in
master
and in
36 other branches
Merge branch 'fix_edit_software_permission' into 'master'
Fix edit software permission - Adds permission filter to edit_software action - Fixes cucumber and selenium tests - Check permission on functional tests of edit software See merge request !136
Showing
9 changed files
with
67 additions
and
33 deletions
Show diff stats
src/noosfero-spb/software_communities/controllers/software_communities_plugin_myprofile_controller.rb
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 | 23 | | Software Three | false | Education | some finality | |
24 | 24 | |
25 | 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 | 27 | And I follow "Edit sideboxes" |
29 | 28 | And I follow "Add a block" |
30 | 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 | 10 | | joaosilva | Joao Silva | joaosilva@example.com | |
11 | 11 | | mariasilva | Maria Silva | mariasilva@example.com | |
12 | 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 | 15 | And SoftwareInfo has initial default values on database |
16 | 16 | And I am logged in as mpog_admin |
17 | 17 | And I go to /admin/plugins |
18 | 18 | And I check "SoftwareCommunitiesPlugin" |
19 | 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 | 22 | Given I am logged in as "joaosilva" |
23 | 23 | And I go to /myprofile/basic-software/plugin/software_communities/edit_software |
24 | 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 | 27 | Scenario: Enable public software checkbox to admin users |
28 | 28 | Given I am logged in as mpog_admin |
29 | 29 | And I go to /myprofile/basic-software/plugin/software_communities/edit_software |
30 | 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 | 33 | @selenium |
34 | 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 | 15 | | Generic Software | false | some finality | |
16 | 16 | |
17 | 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 | 19 | And I follow "Edit sideboxes" |
21 | 20 | When I follow "Add a block" |
22 | 21 | And I choose "Softwares" |
... | ... | @@ -24,9 +23,7 @@ Feature: edit adherent fields |
24 | 23 | Then I should see "softwares" |
25 | 24 | |
26 | 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 | 27 | And I follow "Edit sideboxes" |
31 | 28 | When I follow "Add a block" |
32 | 29 | And I choose "Softwares" |
... | ... | @@ -37,8 +34,7 @@ Feature: edit adherent fields |
37 | 34 | Then I should see "generic software" |
38 | 35 | |
39 | 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 | 38 | And I follow "Edit sideboxes" |
43 | 39 | When I follow "Add a block" |
44 | 40 | And I choose "Softwares" | ... | ... |
src/noosfero-spb/software_communities/features/software_catalog.feature
... | ... | @@ -46,7 +46,7 @@ Feature: Search software |
46 | 46 | Scenario: Show software ordered by name when "Name A-Z" is selected |
47 | 47 | Given I go to /search/software_infos |
48 | 48 | And I select "Name A-Z" from "sort" |
49 | - And I press "Filter" | |
49 | + And I sleep for 3 seconds | |
50 | 50 | Then I should see "Software One" before "Software Two" |
51 | 51 | |
52 | 52 | @selenium |
... | ... | @@ -59,7 +59,7 @@ Feature: Search software |
59 | 59 | @selenium |
60 | 60 | Scenario: Show only "Software Two" when searching for "Education" category |
61 | 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 | 63 | And I check "Education" |
64 | 64 | Then I should see "Software Two" |
65 | 65 | And I should not see "Software One" |
... | ... | @@ -67,7 +67,7 @@ Feature: Search software |
67 | 67 | @selenium |
68 | 68 | Scenario: Show both Software "One" and "Two" when searching for "Health" category |
69 | 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 | 71 | And I check "Health" |
72 | 72 | Then I should see "Software One" |
73 | 73 | And I should see "Software Two" |
... | ... | @@ -75,8 +75,7 @@ Feature: Search software |
75 | 75 | @selenium |
76 | 76 | Scenario: Show not "public_software" when "Include in results" is checked |
77 | 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 | 79 | Then I should see "Software One" |
81 | 80 | And I should see "Software Two" |
82 | 81 | And I should see "Software Three" |
... | ... | @@ -104,9 +103,8 @@ Feature: Search software |
104 | 103 | And I go to /profile/software-two/plugin/organization_ratings/new_rating |
105 | 104 | And I press "Enviar" |
106 | 105 | And I go to /search/software_infos |
107 | - When I select "Favorites" from "sort" | |
106 | + When I select "Rating" from "sort" | |
108 | 107 | And I sleep for 3 seconds |
109 | 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 | 175 | Given /^the following softwares$/ do |table| |
176 | 176 | table.hashes.each do |item| |
177 | 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 | 181 | software_info.finality = item[:finality] if item[:finality] |
181 | 182 | software_info.acronym = item[:acronym] if item[:acronym] |
... | ... | @@ -211,10 +212,15 @@ Given /^the following softwares$/ do |table| |
211 | 212 | |
212 | 213 | categories.each do |category_name| |
213 | 214 | category = Category.find_by_name category_name |
214 | - software_info.community.categories << category | |
215 | + community.categories << category | |
215 | 216 | end |
216 | 217 | end |
217 | 218 | |
219 | + if item[:owner] | |
220 | + owner = item[:owner] | |
221 | + community.add_admin Profile[owner] | |
222 | + end | |
223 | + | |
218 | 224 | software_info.save! |
219 | 225 | end |
220 | 226 | end | ... | ... |
src/noosfero-spb/software_communities/features/use_report.feature
... | ... | @@ -34,10 +34,10 @@ Feature: Use report |
34 | 34 | Scenario: Test Additional Fields JavaScript |
35 | 35 | Given I go to /profile/noosfero/plugin/organization_ratings/new_rating |
36 | 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 | 38 | When I click on anything with selector "comments-additional-information" |
39 | 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 | 42 | @selenium |
43 | 43 | Scenario: Validate Use Report fields format |
... | ... | @@ -49,8 +49,8 @@ Feature: Use report |
49 | 49 | And I am on Noosfero's homepage |
50 | 50 | And I follow "Rate Community" |
51 | 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 | 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 | 62 | fields = software_edit_basic_fields |
63 | 63 | |
64 | 64 | software = create_software fields_software |
65 | + | |
66 | + software.community.add_admin(@person) | |
67 | + software.save! | |
68 | + | |
65 | 69 | post( |
66 | 70 | :edit_software, |
67 | 71 | :profile => software.community.identifier, |
... | ... | @@ -80,6 +84,10 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
80 | 84 | fields = software_edit_specific_fields |
81 | 85 | |
82 | 86 | software = create_software fields_software |
87 | + | |
88 | + software.community.add_admin(@person) | |
89 | + software.save! | |
90 | + | |
83 | 91 | post( |
84 | 92 | :edit_software, |
85 | 93 | :profile => software.community.identifier, |
... | ... | @@ -93,6 +101,29 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC |
93 | 101 | assert_equal SoftwareInfo.last.acronym, "test" |
94 | 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 | 127 | should 'only admin upgrade a generic software to a public software' do |
97 | 128 | admin_person = create_user('admin').person |
98 | 129 | @environment.add_admin(admin_person) | ... | ... |
src/noosfero-spb/software_communities/views/search/_catalog_filter.html.erb
... | ... | @@ -6,8 +6,10 @@ |
6 | 6 | <ul> |
7 | 7 | <% @categories.each do |category| %> |
8 | 8 | <li> |
9 | - <%= check_box_tag("selected_categories_id[]", category.id, @selected_categories_id.include?(category.id), :class => "categories-catalog", @enabled_check_box[category] => "true") %> | |
10 | - <span><%= _("#{category.name}") %></span> | |
9 | + <label> | |
10 | + <%= check_box_tag("selected_categories_id[]", category.id, @selected_categories_id.include?(category.id), :class => "categories-catalog", @enabled_check_box[category] => "true") %> | |
11 | + <span><%= _("#{category.name}") %></span> | |
12 | + </label> | |
11 | 13 | </li> |
12 | 14 | <% end %> |
13 | 15 | </ul> | ... | ... |