diff --git a/controllers/software_communities_plugin_myprofile_controller.rb b/controllers/software_communities_plugin_myprofile_controller.rb index 256539a..3929c67 100644 --- a/controllers/software_communities_plugin_myprofile_controller.rb +++ b/controllers/software_communities_plugin_myprofile_controller.rb @@ -17,6 +17,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController LicenseInfo.find(params[:license][:license_infos_id]) end + @software_info.community = @community + @software_info.license_info = @license_info + control_software_creation update_new_software_errors end @@ -58,7 +61,11 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController def add_software_erros @errors = [] - @errors |= @community.errors.full_messages if @community + if @community + error = @community.errors.delete(:identifier) + @errors |= [_("Domain %s") % error.first ] if error + @errors |= @community.errors.full_messages + end @errors |= @software_info.errors.full_messages if @software_info @errors |= @license_info.errors.full_messages if @license_info end diff --git a/test/functional/software_communities_plugin_myprofile_controller_test.rb b/test/functional/software_communities_plugin_myprofile_controller_test.rb index bb72b8a..f4e97cc 100644 --- a/test/functional/software_communities_plugin_myprofile_controller_test.rb +++ b/test/functional/software_communities_plugin_myprofile_controller_test.rb @@ -151,4 +151,39 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC assert_equal SoftwareInfo.last.license_info.version, another_license_version assert_equal SoftwareInfo.last.license_info.link, another_license_link end + + should "show error messages on create software_info" do + post( + :new_software, + :community => {}, + :software_info => {}, + :license => {}, + :profile => @person.identifier + ) + assert_includes @response.body, "Domain can't be blank" + assert_includes @response.body, "Name can't be blank" + assert_includes @response.body, "Finality can't be blank" + assert_includes @response.body, "Version can't be blank" + end + + should "show domain not available error" do + @environment.add_admin(@person) + + post( + :new_software, + :community => {:name =>"New Software", :identifier => "new-software"}, + :software_info => {:finality => "something", :repository_link => ""}, + :license =>{:license_infos_id => LicenseInfo.last.id}, + :profile => @person.identifier + ) + post( + :new_software, + :community => {:name =>"New Software", :identifier => "new-software"}, + :software_info => {:finality => "something", :repository_link => ""}, + :license =>{:license_infos_id => LicenseInfo.last.id}, + :profile => @person.identifier + ) + + assert_includes @response.body, "Domain is not available" + end end -- libgit2 0.21.2