Commit 128ab2dda869289e7509982ce884052e4665ff77

Authored by Luciano Prestes
Committed by David Silva
1 parent 5ab52234

Add functional tests for create software_info with Another license_info

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
controllers/mpog_software_plugin_myprofile_controller.rb
... ... @@ -153,11 +153,11 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
153 153 end
154 154 @software_info = SoftwareInfo.create_after_moderation(user,
155 155 params[:software_info].merge({
156   - :environment => environment,
157   - :name => params[:community][:name],
158   - :license_info => @license_info,
159   - :another_license_version => another_license_version,
160   - :another_license_link => another_license_link }))
  156 + :environment => environment,
  157 + :name => params[:community][:name],
  158 + :license_info => @license_info,
  159 + :another_license_version => another_license_version,
  160 + :another_license_link => another_license_link }))
161 161  
162 162 add_admin_to_community
163 163  
... ...
test/functional/mpog_software_plugin_myprofile_controller_test.rb
... ... @@ -219,4 +219,42 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase
219 219 assert_equal "Ministerio Publico da Uniao", institution.community.name
220 220 assert_equal "12.345.678/9012-45", institution.cnpj
221 221 end
222   -end
  222 +
  223 + should "create software_info with existing license_info" do
  224 + @environment.add_admin(@person)
  225 +
  226 + post(
  227 + :new_software,
  228 + :community => {:name =>"New Software"},
  229 + :software_info => {:finality => "", :repository_link => ""},
  230 + :license_info =>{:id => LicenseInfo.last.id},
  231 + :profile => @person.identifier
  232 + )
  233 +
  234 + assert_equal SoftwareInfo.last.license_info, LicenseInfo.last
  235 + end
  236 +
  237 + should "create software_info with 'Another' license_info" do
  238 + license_another = LicenseInfo.create(:version => "Another", :link => "#")
  239 + @environment.add_admin(@person)
  240 +
  241 + another_license_version = "Different License"
  242 + another_license_link = "http://diferent.link"
  243 +
  244 + post(
  245 + :new_software,
  246 + :community => { :name =>"New Software" },
  247 + :software_info => { :finality => "", :repository_link => "" },
  248 + :license_info =>{ :id => license_another.id },
  249 + :license => { :version => another_license_version,
  250 + :link => another_license_link },
  251 + :profile => @person.identifier
  252 + )
  253 +
  254 + assert_equal SoftwareInfo.last.license_info_id, license_another.id
  255 + assert_equal SoftwareInfo.last.license_info.id, nil
  256 + assert_equal SoftwareInfo.last.license_info.version, another_license_version
  257 + assert_equal SoftwareInfo.last.license_info.link, another_license_link
  258 + end
  259 +
  260 +end
223 261 \ No newline at end of file
... ...
test/unit/software_info_test.rb
... ... @@ -5,23 +5,22 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
5 5  
6 6 include PluginTestHelper
7 7  
8   - def setup
9   - @license_another = create_license_info("Another")
10   - end
11   -
12 8 should "Return original license_info when license is not 'Another'" do
13 9 @software_info = create_software_info("software_test")
14 10 @license_info = create_license_info("license_test")
15 11  
16 12 @software_info.license_info = @license_info
  13 + @software_info.save!
17 14  
18 15 assert_equal @software_info.license_info, @license_info
19 16 end
20 17  
21 18 should "Return license_info with nil id when license is 'Another'" do
22 19 @software_info = create_software_info("software_test")
  20 + @license_another = create_license_info("Another")
23 21  
24 22 @software_info.license_info = @license_another
  23 + @software_info.save!
25 24  
26 25 assert_equal @software_info.license_info_id, @license_another.id
27 26 assert_equal @software_info.license_info.id, nil
... ... @@ -29,6 +28,7 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
29 28  
30 29 should "Return fake license_info when call method another_license" do
31 30 @software_info = create_software_info("software_test")
  31 + @license_another = create_license_info("Another")
32 32  
33 33 another_license_version = "Another Version"
34 34 another_license_link = "#another_link"
... ...