Commit 128ab2dda869289e7509982ce884052e4665ff77

Authored by Luciano Prestes
Committed by David Silva
1 parent 5ab52234
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

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"
... ...