diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb index 009beae..0317c93 100644 --- a/controllers/mpog_software_plugin_myprofile_controller.rb +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -153,11 +153,11 @@ class MpogSoftwarePluginMyprofileController < MyProfileController end @software_info = SoftwareInfo.create_after_moderation(user, params[:software_info].merge({ - :environment => environment, - :name => params[:community][:name], - :license_info => @license_info, - :another_license_version => another_license_version, - :another_license_link => another_license_link })) + :environment => environment, + :name => params[:community][:name], + :license_info => @license_info, + :another_license_version => another_license_version, + :another_license_link => another_license_link })) add_admin_to_community diff --git a/test/functional/mpog_software_plugin_myprofile_controller_test.rb b/test/functional/mpog_software_plugin_myprofile_controller_test.rb index 5bb9989..227b0b2 100644 --- a/test/functional/mpog_software_plugin_myprofile_controller_test.rb +++ b/test/functional/mpog_software_plugin_myprofile_controller_test.rb @@ -219,4 +219,42 @@ class MpogSoftwarePluginMyprofileControllerTest < ActionController::TestCase assert_equal "Ministerio Publico da Uniao", institution.community.name assert_equal "12.345.678/9012-45", institution.cnpj end -end + + should "create software_info with existing license_info" do + @environment.add_admin(@person) + + post( + :new_software, + :community => {:name =>"New Software"}, + :software_info => {:finality => "", :repository_link => ""}, + :license_info =>{:id => LicenseInfo.last.id}, + :profile => @person.identifier + ) + + assert_equal SoftwareInfo.last.license_info, LicenseInfo.last + end + + should "create software_info with 'Another' license_info" do + license_another = LicenseInfo.create(:version => "Another", :link => "#") + @environment.add_admin(@person) + + another_license_version = "Different License" + another_license_link = "http://diferent.link" + + post( + :new_software, + :community => { :name =>"New Software" }, + :software_info => { :finality => "", :repository_link => "" }, + :license_info =>{ :id => license_another.id }, + :license => { :version => another_license_version, + :link => another_license_link }, + :profile => @person.identifier + ) + + assert_equal SoftwareInfo.last.license_info_id, license_another.id + assert_equal SoftwareInfo.last.license_info.id, nil + assert_equal SoftwareInfo.last.license_info.version, another_license_version + assert_equal SoftwareInfo.last.license_info.link, another_license_link + end + +end \ No newline at end of file diff --git a/test/unit/software_info_test.rb b/test/unit/software_info_test.rb index b6fc5ce..930436c 100644 --- a/test/unit/software_info_test.rb +++ b/test/unit/software_info_test.rb @@ -5,23 +5,22 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase include PluginTestHelper - def setup - @license_another = create_license_info("Another") - end - should "Return original license_info when license is not 'Another'" do @software_info = create_software_info("software_test") @license_info = create_license_info("license_test") @software_info.license_info = @license_info + @software_info.save! assert_equal @software_info.license_info, @license_info end should "Return license_info with nil id when license is 'Another'" do @software_info = create_software_info("software_test") + @license_another = create_license_info("Another") @software_info.license_info = @license_another + @software_info.save! assert_equal @software_info.license_info_id, @license_another.id assert_equal @software_info.license_info.id, nil @@ -29,6 +28,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase should "Return fake license_info when call method another_license" do @software_info = create_software_info("software_test") + @license_another = create_license_info("Another") another_license_version = "Another Version" another_license_link = "#another_link" -- libgit2 0.21.2