Commit 5ab5223463cf5f2b2b75d62b61e068f13dad05e1

Authored by Luciano Prestes
Committed by David Silva
1 parent e15e7582
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 unit tests to methods license_info and another_license of SoftwareInfo

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
test/helpers/plugin_test_helper.rb
... ... @@ -78,4 +78,11 @@ module PluginTestHelper
78 78 user
79 79 end
80 80  
  81 + def create_license_info version, link = ""
  82 + license = LicenseInfo.create(:version => version)
  83 + license.link = link
  84 + license.save
  85 +
  86 + license
  87 + end
81 88 end
... ...
test/unit/software_info_test.rb 0 → 100644
... ... @@ -0,0 +1,44 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  3 +
  4 +class SoftwareInfoValidationTest < ActiveSupport::TestCase
  5 +
  6 + include PluginTestHelper
  7 +
  8 + def setup
  9 + @license_another = create_license_info("Another")
  10 + end
  11 +
  12 + should "Return original license_info when license is not 'Another'" do
  13 + @software_info = create_software_info("software_test")
  14 + @license_info = create_license_info("license_test")
  15 +
  16 + @software_info.license_info = @license_info
  17 +
  18 + assert_equal @software_info.license_info, @license_info
  19 + end
  20 +
  21 + should "Return license_info with nil id when license is 'Another'" do
  22 + @software_info = create_software_info("software_test")
  23 +
  24 + @software_info.license_info = @license_another
  25 +
  26 + assert_equal @software_info.license_info_id, @license_another.id
  27 + assert_equal @software_info.license_info.id, nil
  28 + end
  29 +
  30 + should "Return fake license_info when call method another_license" do
  31 + @software_info = create_software_info("software_test")
  32 +
  33 + another_license_version = "Another Version"
  34 + another_license_link = "#another_link"
  35 +
  36 + @software_info.another_license(another_license_version, another_license_link)
  37 +
  38 + assert_equal @software_info.license_info_id, @license_another.id
  39 + assert_equal @software_info.license_info.id, nil
  40 + assert_equal @software_info.license_info.version, another_license_version
  41 + assert_equal @software_info.license_info.link, another_license_link
  42 + end
  43 +
  44 +end
0 45 \ No newline at end of file
... ...