Commit 4e1e83c6b106d59b6c40ced21182302929f5c731

Authored by Luciano Prestes
1 parent 615be5d8
Exists in fix_no_license

Add validates presence of license on software_info

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Signed-off-by: Omar Junior <omarroinuj@gmail.com>
src/noosfero-spb/software_communities/lib/software_info.rb
@@ -84,7 +84,7 @@ class SoftwareInfo &lt; ActiveRecord::Base @@ -84,7 +84,7 @@ class SoftwareInfo &lt; ActiveRecord::Base
84 validates_length_of :finality, :maximum => 4000 84 validates_length_of :finality, :maximum => 4000
85 validates_length_of :objectives, :maximum => 4000 85 validates_length_of :objectives, :maximum => 4000
86 validates_length_of :features, :maximum => 4000 86 validates_length_of :features, :maximum => 4000
87 - validates_presence_of :finality, :community 87 + validates_presence_of :finality, :community, :license_info
88 88
89 validate :validate_acronym 89 validate :validate_acronym
90 90
@@ -139,7 +139,7 @@ class SoftwareInfo &lt; ActiveRecord::Base @@ -139,7 +139,7 @@ class SoftwareInfo &lt; ActiveRecord::Base
139 license = LicenseInfo.find_by_id self.license_info_id 139 license = LicenseInfo.find_by_id self.license_info_id
140 license_another = LicenseInfo.find_by_version("Another") 140 license_another = LicenseInfo.find_by_version("Another")
141 141
142 - if license_another && license.id == license_another.id 142 + if license_another && license && license.id == license_another.id
143 LicenseInfo.new( 143 LicenseInfo.new(
144 :version => self.another_license_version, 144 :version => self.another_license_version,
145 :link => self.another_license_link 145 :link => self.another_license_link
src/noosfero-spb/software_communities/test/functional/software_communities_plugin_myprofile_controller_test.rb
@@ -251,6 +251,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC @@ -251,6 +251,7 @@ class SoftwareCommunitiesPluginMyprofileControllerTest &lt; ActionController::TestC
251 :new_software, 251 :new_software,
252 :community => { :name => "New Software", :identifier => "new-software" }, 252 :community => { :name => "New Software", :identifier => "new-software" },
253 :software_info => { :finality => "something", :repository_link => "" }, 253 :software_info => { :finality => "something", :repository_link => "" },
  254 + :license_info => { :version => license_another.version },
254 :license => { :license_infos_id => license_another.id, 255 :license => { :license_infos_id => license_another.id,
255 :version => another_license_version, 256 :version => another_license_version,
256 :link=> another_license_link 257 :link=> another_license_link
src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb
@@ -9,9 +9,12 @@ module PluginTestHelper @@ -9,9 +9,12 @@ module PluginTestHelper
9 end 9 end
10 10
11 def create_software_info name, finality = "something", acronym = "" 11 def create_software_info name, finality = "something", acronym = ""
  12 + license = create_license_info("GPL")
12 community = create_community(name) 13 community = create_community(name)
  14 +
13 software_info = SoftwareInfo.new 15 software_info = SoftwareInfo.new
14 software_info.community = community 16 software_info.community = community
  17 + software_info.license_info = license
15 software_info.finality = finality 18 software_info.finality = finality
16 software_info.acronym = acronym 19 software_info.acronym = acronym
17 software_info.public_software = true 20 software_info.public_software = true
@@ -55,7 +58,7 @@ module PluginTestHelper @@ -55,7 +58,7 @@ module PluginTestHelper
55 end 58 end
56 59
57 def create_license_info version, link = "" 60 def create_license_info version, link = ""
58 - license = LicenseInfo.create(:version => version) 61 + license = LicenseInfo.find_or_create_by_version(version)
59 license.link = link 62 license.link = link
60 license.save 63 license.save
61 64