diff --git a/src/noosfero-spb/software_communities/lib/software_info.rb b/src/noosfero-spb/software_communities/lib/software_info.rb index a9816f2..dcbb1e2 100644 --- a/src/noosfero-spb/software_communities/lib/software_info.rb +++ b/src/noosfero-spb/software_communities/lib/software_info.rb @@ -84,7 +84,7 @@ class SoftwareInfo < ActiveRecord::Base validates_length_of :finality, :maximum => 4000 validates_length_of :objectives, :maximum => 4000 validates_length_of :features, :maximum => 4000 - validates_presence_of :finality, :community + validates_presence_of :finality, :community, :license_info validate :validate_acronym @@ -139,7 +139,7 @@ class SoftwareInfo < ActiveRecord::Base license = LicenseInfo.find_by_id self.license_info_id license_another = LicenseInfo.find_by_version("Another") - if license_another && license.id == license_another.id + if license_another && license && license.id == license_another.id LicenseInfo.new( :version => self.another_license_version, :link => self.another_license_link diff --git a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb index 5aae9cf..7b17c80 100644 --- a/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb +++ b/src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb @@ -251,6 +251,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest < ActionController::TestC :new_software, :community => { :name => "New Software", :identifier => "new-software" }, :software_info => { :finality => "something", :repository_link => "" }, + :license_info => { :version => license_another.version }, :license => { :license_infos_id => license_another.id, :version => another_license_version, :link=> another_license_link diff --git a/src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb b/src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb index d7458ce..0f89976 100644 --- a/src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb +++ b/src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb @@ -9,9 +9,12 @@ module PluginTestHelper end def create_software_info name, finality = "something", acronym = "" + license = create_license_info("GPL") community = create_community(name) + software_info = SoftwareInfo.new software_info.community = community + software_info.license_info = license software_info.finality = finality software_info.acronym = acronym software_info.public_software = true @@ -55,7 +58,7 @@ module PluginTestHelper end def create_license_info version, link = "" - license = LicenseInfo.create(:version => version) + license = LicenseInfo.find_or_create_by_version(version) license.link = link license.save -- libgit2 0.21.2