Commit d4ebc3c3e9a9d526af7ffb05b10e0efe0f5e9207
1 parent
bbf5a17b
Exists in
master
and in
5 other branches
Cucumber and Functional Tests
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
5 changed files
with
94 additions
and
60 deletions
Show diff stats
controllers/mpog_software_plugin_myprofile_controller.rb
| ... | ... | @@ -85,7 +85,7 @@ class MpogSoftwarePluginMyprofileController < MyProfileController |
| 85 | 85 | @software_categories = @software_info.software_categories |
| 86 | 86 | @software_categories = SoftwareCategories.new if @software_categories.blank? |
| 87 | 87 | |
| 88 | - @show_public_software_field = show_public_software_field | |
| 88 | + @disabled_public_software_field = disabled_public_software_field | |
| 89 | 89 | |
| 90 | 90 | if request.post? |
| 91 | 91 | params[:software][:public_software] ||= false |
| ... | ... | @@ -141,8 +141,8 @@ class MpogSoftwarePluginMyprofileController < MyProfileController |
| 141 | 141 | end |
| 142 | 142 | end |
| 143 | 143 | |
| 144 | - def show_public_software_field | |
| 145 | - environment.admins.include?(current_user.person) | |
| 144 | + def disabled_public_software_field | |
| 145 | + !environment.admins.include?(current_user.person) | |
| 146 | 146 | end |
| 147 | 147 | |
| 148 | 148 | def community_must_be_approved | ... | ... |
features/public_software_validation.feature
| 1 | -Feature: edit adherent fields | |
| 1 | +Feature: edit adherent fields | |
| 2 | 2 | As a user |
| 3 | - I want to edit adherent fields | |
| 3 | + I want to edit adherent fields | |
| 4 | 4 | to mantain my public software up to date. |
| 5 | 5 | |
| 6 | 6 | Background: |
| ... | ... | @@ -20,26 +20,35 @@ Feature: edit adherent fields |
| 20 | 20 | And I fill in "software_info_finality" with "basic software finality" |
| 21 | 21 | And I press "Create" |
| 22 | 22 | |
| 23 | - Scenario: Don't show public software checkbox to no enviroment admin | |
| 23 | + Scenario: Disable public software checkbox to non admin users | |
| 24 | 24 | Given I am logged in as "joaosilva" |
| 25 | 25 | And I go to /myprofile/basic-software/plugin/mpog_software/edit_software |
| 26 | 26 | And I follow "Specifications" |
| 27 | - Then I should not see "Is a public software" | |
| 27 | + Then I should see "Public software" within ".public_software_disabled" | |
| 28 | 28 | |
| 29 | - Scenario: Show public software checkbox no enviroment admin | |
| 29 | + Scenario: Enable public software checkbox to admin users | |
| 30 | 30 | Given I am logged in as mpog_admin |
| 31 | 31 | And I go to /myprofile/basic-software/plugin/mpog_software/edit_software |
| 32 | 32 | And I follow "Specifications" |
| 33 | - Then I should see "Is a public software" | |
| 33 | + Then I should see "Public software" within ".public_software_enabled" | |
| 34 | 34 | |
| 35 | + @selenium | |
| 35 | 36 | Scenario: Show adherent fields when checkbox are checked |
| 36 | 37 | Given I am logged in as mpog_admin |
| 37 | 38 | And I go to /myprofile/basic-software/plugin/mpog_software/edit_software |
| 38 | 39 | And I follow "Specifications" |
| 40 | + And I uncheck "software[public_software]" | |
| 39 | 41 | And I check "software[public_software]" |
| 40 | - And I press "Save" | |
| 42 | + Then I should see "Adherent to e-ping ?" | |
| 43 | + | |
| 44 | + @selenium | |
| 45 | + Scenario: Don't show adherent fields when checkbox are not checked | |
| 46 | + Given I am logged in as mpog_admin | |
| 41 | 47 | And I go to /myprofile/basic-software/plugin/mpog_software/edit_software |
| 42 | 48 | And I follow "Specifications" |
| 43 | - Then I should see "Adherent to e-ping ?" | |
| 49 | + And I check "software[public_software]" | |
| 50 | + And I uncheck "software[public_software]" | |
| 51 | + Then I should not see "Adherent to e-ping ?" | |
| 52 | + | |
| 44 | 53 | |
| 45 | 54 | ... | ... |
public/mpog-software-validations.js
| ... | ... | @@ -92,7 +92,7 @@ |
| 92 | 92 | .text(link); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - function hide_infos(){ | |
| 95 | + function hide_infos() { | |
| 96 | 96 | jQuery(".language-info").hide(); |
| 97 | 97 | jQuery(".database-info").hide(); |
| 98 | 98 | jQuery(".libraries-info").hide(); |
| ... | ... | @@ -103,6 +103,13 @@ |
| 103 | 103 | jQuery(".operating-system-button-hide").hide(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | + function hide_show_public_software_fields() { | |
| 107 | + if (jQuery("#software_public_software").prop("checked")) | |
| 108 | + jQuery(".public-software-fields").show(); | |
| 109 | + else | |
| 110 | + jQuery(".public-software-fields").hide(); | |
| 111 | + } | |
| 112 | + | |
| 106 | 113 | jQuery(document).ready(function(){ |
| 107 | 114 | var dynamic_tables = ["dynamic-databases", "dynamic-languages", "dynamic-libraries","dynamic-operating_systems"]; |
| 108 | 115 | |
| ... | ... | @@ -183,5 +190,7 @@ |
| 183 | 190 | jQuery(".libraries-button-show").hide(); |
| 184 | 191 | jQuery(".libraries-button-hide").show(); |
| 185 | 192 | }); |
| 193 | + hide_show_public_software_fields(); | |
| 194 | + jQuery("#software_public_software").click(hide_show_public_software_fields); | |
| 186 | 195 | }); |
| 187 | 196 | })(); | ... | ... |
test/functional/mpog_software_plugin_myprofile_controller_test.rb
| ... | ... | @@ -89,4 +89,15 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase |
| 89 | 89 | assert_equal SoftwareInfo.last.acronym, "test" |
| 90 | 90 | end |
| 91 | 91 | |
| 92 | + should 'upgrade a generic software to a public software' do | |
| 93 | + fields_software = software_fields | |
| 94 | + fields = software_edit_specific_fields | |
| 95 | + | |
| 96 | + fields[4]['public_software'] = true | |
| 97 | + software = create_software fields_software | |
| 98 | + post :edit_software, :profile => software.community.identifier, :library => fields[0], :language => fields[1], | |
| 99 | + :database => fields[2], :operating_system => fields[3], :software => fields[4], :software_categories => fields[5], :license => fields[6] | |
| 100 | + assert_equal true, SoftwareInfo.last.public_software? | |
| 101 | + end | |
| 102 | + | |
| 92 | 103 | end | ... | ... |
views/mpog_software_plugin_myprofile/_public_software_info.html.erb
| ... | ... | @@ -43,56 +43,61 @@ |
| 43 | 43 | <%= text_field_tag("software[demonstration_url]", @software_info.demonstration_url) %> |
| 44 | 44 | </div> |
| 45 | 45 | |
| 46 | +<br> | |
| 47 | + | |
| 46 | 48 | <div id = "public_software"> |
| 47 | - <% if @show_public_software_field %> | |
| 49 | + <% if @disabled_public_software_field == true %> | |
| 50 | + <%= check_box_tag("software[public_software]", "true", @software_info.public_software?, :disabled => "disabled") %> | |
| 51 | + <%= label_tag _("Public Software"), _("Public software"), :class => "public_software_disabled" %> | |
| 52 | + <% else %> | |
| 48 | 53 | <%= check_box_tag("software[public_software]", "true", @software_info.public_software?) %> |
| 49 | - <%= label_tag _("Public Software"), _("Is a public software") %> | |
| 54 | + <%= label_tag _("Public Software"), _("Public software"), :class => "public_software_enabled" %> | |
| 50 | 55 | <% end %> |
| 51 | - <% if @software_info.public_software? %> | |
| 52 | - <h4> <%= _("Public Software") %> </h4> | |
| 53 | - <div class="formfieldline"> | |
| 54 | - <%= label_tag _("Adherent to e-PING ?") %> | |
| 55 | - | |
| 56 | - <%= label_tag "e_ping_true", "Yes" %> | |
| 57 | - <%= radio_button_tag("software[e_ping]", true, @software_info.e_ping)%> | |
| 58 | - <%= label_tag "e_ping_false", "No"%> | |
| 59 | - <%= radio_button_tag("software[e_ping]", false, !@software_info.e_ping)%> | |
| 60 | - </div> | |
| 61 | - | |
| 62 | - <div class="formfieldline"> | |
| 63 | - <%= label_tag _("Adherent to e-MAG ?") %> | |
| 64 | - | |
| 65 | - <%= label_tag "e_mag_true", "Yes"%> | |
| 66 | - <%= radio_button_tag("software[e_mag]", true, @software_info.e_mag)%> | |
| 67 | - <%= label_tag "e_mag_false", "No"%> | |
| 68 | - <%= radio_button_tag("software[e_mag]", false, !@software_info.e_mag)%> | |
| 69 | - </div> | |
| 70 | - | |
| 71 | - <div class="formfieldline"> | |
| 72 | - <%= label_tag _("Adherent to ICP-Brasil ?") %> | |
| 73 | - | |
| 74 | - <%= label_tag "icp_brasil_true", "Yes"%> | |
| 75 | - <%= radio_button_tag("software[icp_brasil]", true, @software_info.icp_brasil)%> | |
| 76 | - <%= label_tag "icp_brasil_false", "No"%> | |
| 77 | - <%= radio_button_tag("software[icp_brasil]", false, !@software_info.icp_brasil)%> | |
| 78 | - </div> | |
| 79 | - | |
| 80 | - <div class="formfieldline"> | |
| 81 | - <%= label_tag _("Adherent to e-ARQ ?") %> | |
| 82 | - | |
| 83 | - <%= label_tag "e_arq_true", "Yes"%> | |
| 84 | - <%= radio_button_tag("software[e_arq]", true, @software_info.e_arq)%> | |
| 85 | - <%= label_tag "e_arq_false", "No"%> | |
| 86 | - <%= radio_button_tag("software[e_arq]", false, !@software_info.e_arq)%> | |
| 87 | - </div> | |
| 88 | - | |
| 89 | - <div class="formfieldline"> | |
| 90 | - <%= label_tag _("Internacionalizable ?") %> | |
| 91 | - | |
| 92 | - <%= label_tag "intern_true", "Yes" %> | |
| 93 | - <%= radio_button_tag("software[intern]", true, @software_info.intern)%> | |
| 94 | - <%= label_tag "intern_false", "No"%> | |
| 95 | - <%= radio_button_tag("software[intern]", false, !@software_info.intern)%> | |
| 56 | + <div class="public-software-fields"> | |
| 57 | + <h4> <%= _("Public Software") %> </h4> | |
| 58 | + <div class="formfieldline"> | |
| 59 | + <%= label_tag _("Adherent to e-PING ?") %> | |
| 60 | + | |
| 61 | + <%= label_tag "e_ping_true", "Yes" %> | |
| 62 | + <%= radio_button_tag("software[e_ping]", true, @software_info.e_ping)%> | |
| 63 | + <%= label_tag "e_ping_false", "No"%> | |
| 64 | + <%= radio_button_tag("software[e_ping]", false, !@software_info.e_ping)%> | |
| 65 | + </div> | |
| 66 | + | |
| 67 | + <div class="formfieldline"> | |
| 68 | + <%= label_tag _("Adherent to e-MAG ?") %> | |
| 69 | + | |
| 70 | + <%= label_tag "e_mag_true", "Yes"%> | |
| 71 | + <%= radio_button_tag("software[e_mag]", true, @software_info.e_mag)%> | |
| 72 | + <%= label_tag "e_mag_false", "No"%> | |
| 73 | + <%= radio_button_tag("software[e_mag]", false, !@software_info.e_mag)%> | |
| 74 | + </div> | |
| 75 | + | |
| 76 | + <div class="formfieldline"> | |
| 77 | + <%= label_tag _("Adherent to ICP-Brasil ?") %> | |
| 78 | + | |
| 79 | + <%= label_tag "icp_brasil_true", "Yes"%> | |
| 80 | + <%= radio_button_tag("software[icp_brasil]", true, @software_info.icp_brasil)%> | |
| 81 | + <%= label_tag "icp_brasil_false", "No"%> | |
| 82 | + <%= radio_button_tag("software[icp_brasil]", false, !@software_info.icp_brasil)%> | |
| 83 | + </div> | |
| 84 | + | |
| 85 | + <div class="formfieldline"> | |
| 86 | + <%= label_tag _("Adherent to e-ARQ ?") %> | |
| 87 | + | |
| 88 | + <%= label_tag "e_arq_true", "Yes"%> | |
| 89 | + <%= radio_button_tag("software[e_arq]", true, @software_info.e_arq)%> | |
| 90 | + <%= label_tag "e_arq_false", "No"%> | |
| 91 | + <%= radio_button_tag("software[e_arq]", false, !@software_info.e_arq)%> | |
| 92 | + </div> | |
| 93 | + | |
| 94 | + <div class="formfieldline"> | |
| 95 | + <%= label_tag _("Internacionalizable ?") %> | |
| 96 | + | |
| 97 | + <%= label_tag "intern_true", "Yes" %> | |
| 98 | + <%= radio_button_tag("software[intern]", true, @software_info.intern)%> | |
| 99 | + <%= label_tag "intern_false", "No"%> | |
| 100 | + <%= radio_button_tag("software[intern]", false, !@software_info.intern)%> | |
| 101 | + </div> | |
| 96 | 102 | </div> |
| 97 | -<% end %> | |
| 98 | 103 | </div> | ... | ... |