diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb
index fa790a2..5257102 100644
--- a/controllers/mpog_software_plugin_myprofile_controller.rb
+++ b/controllers/mpog_software_plugin_myprofile_controller.rb
@@ -85,7 +85,7 @@ class MpogSoftwarePluginMyprofileController < MyProfileController
@software_categories = @software_info.software_categories
@software_categories = SoftwareCategories.new if @software_categories.blank?
- @show_public_software_field = show_public_software_field
+ @disabled_public_software_field = disabled_public_software_field
if request.post?
params[:software][:public_software] ||= false
@@ -141,8 +141,8 @@ class MpogSoftwarePluginMyprofileController < MyProfileController
end
end
- def show_public_software_field
- environment.admins.include?(current_user.person)
+ def disabled_public_software_field
+ !environment.admins.include?(current_user.person)
end
def community_must_be_approved
diff --git a/features/public_software_validation.feature b/features/public_software_validation.feature
index bf18baa..6484809 100644
--- a/features/public_software_validation.feature
+++ b/features/public_software_validation.feature
@@ -1,6 +1,6 @@
-Feature: edit adherent fields
+Feature: edit adherent fields
As a user
- I want to edit adherent fields
+ I want to edit adherent fields
to mantain my public software up to date.
Background:
@@ -20,26 +20,35 @@ Feature: edit adherent fields
And I fill in "software_info_finality" with "basic software finality"
And I press "Create"
- Scenario: Don't show public software checkbox to no enviroment admin
+ Scenario: Disable public software checkbox to non admin users
Given I am logged in as "joaosilva"
And I go to /myprofile/basic-software/plugin/mpog_software/edit_software
And I follow "Specifications"
- Then I should not see "Is a public software"
+ Then I should see "Public software" within ".public_software_disabled"
- Scenario: Show public software checkbox no enviroment admin
+ Scenario: Enable public software checkbox to admin users
Given I am logged in as mpog_admin
And I go to /myprofile/basic-software/plugin/mpog_software/edit_software
And I follow "Specifications"
- Then I should see "Is a public software"
+ Then I should see "Public software" within ".public_software_enabled"
+ @selenium
Scenario: Show adherent fields when checkbox are checked
Given I am logged in as mpog_admin
And I go to /myprofile/basic-software/plugin/mpog_software/edit_software
And I follow "Specifications"
+ And I uncheck "software[public_software]"
And I check "software[public_software]"
- And I press "Save"
+ Then I should see "Adherent to e-ping ?"
+
+ @selenium
+ Scenario: Don't show adherent fields when checkbox are not checked
+ Given I am logged in as mpog_admin
And I go to /myprofile/basic-software/plugin/mpog_software/edit_software
And I follow "Specifications"
- Then I should see "Adherent to e-ping ?"
+ And I check "software[public_software]"
+ And I uncheck "software[public_software]"
+ Then I should not see "Adherent to e-ping ?"
+
diff --git a/public/mpog-software-validations.js b/public/mpog-software-validations.js
index 47df568..f3e1367 100644
--- a/public/mpog-software-validations.js
+++ b/public/mpog-software-validations.js
@@ -92,7 +92,7 @@
.text(link);
}
- function hide_infos(){
+ function hide_infos() {
jQuery(".language-info").hide();
jQuery(".database-info").hide();
jQuery(".libraries-info").hide();
@@ -103,6 +103,13 @@
jQuery(".operating-system-button-hide").hide();
}
+ function hide_show_public_software_fields() {
+ if (jQuery("#software_public_software").prop("checked"))
+ jQuery(".public-software-fields").show();
+ else
+ jQuery(".public-software-fields").hide();
+ }
+
jQuery(document).ready(function(){
var dynamic_tables = ["dynamic-databases", "dynamic-languages", "dynamic-libraries","dynamic-operating_systems"];
@@ -183,5 +190,7 @@
jQuery(".libraries-button-show").hide();
jQuery(".libraries-button-hide").show();
});
+ hide_show_public_software_fields();
+ jQuery("#software_public_software").click(hide_show_public_software_fields);
});
})();
diff --git a/test/functional/mpog_software_plugin_myprofile_controller_test.rb b/test/functional/mpog_software_plugin_myprofile_controller_test.rb
index 4c30e82..be26557 100644
--- a/test/functional/mpog_software_plugin_myprofile_controller_test.rb
+++ b/test/functional/mpog_software_plugin_myprofile_controller_test.rb
@@ -89,4 +89,15 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase
assert_equal SoftwareInfo.last.acronym, "test"
end
+ should 'upgrade a generic software to a public software' do
+ fields_software = software_fields
+ fields = software_edit_specific_fields
+
+ fields[4]['public_software'] = true
+ software = create_software fields_software
+ post :edit_software, :profile => software.community.identifier, :library => fields[0], :language => fields[1],
+ :database => fields[2], :operating_system => fields[3], :software => fields[4], :software_categories => fields[5], :license => fields[6]
+ assert_equal true, SoftwareInfo.last.public_software?
+ end
+
end
diff --git a/views/mpog_software_plugin_myprofile/_public_software_info.html.erb b/views/mpog_software_plugin_myprofile/_public_software_info.html.erb
index 28caeb8..c382a5e 100644
--- a/views/mpog_software_plugin_myprofile/_public_software_info.html.erb
+++ b/views/mpog_software_plugin_myprofile/_public_software_info.html.erb
@@ -43,56 +43,61 @@
<%= text_field_tag("software[demonstration_url]", @software_info.demonstration_url) %>
+
+