Commit 70a9066353a1cb9a0a556e552c3f5aa11bdb4521

Authored by Parley
Committed by Fabio Teixeira
1 parent f5668ee4
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

Fix validation of software info.

Signed-off-by: Parley Martins <parley@outlook.com>
lib/software_info.rb
... ... @@ -15,6 +15,8 @@ class SoftwareInfo &lt; ActiveRecord::Base
15 15 has_one :software_categories
16 16  
17 17 validates_length_of :finality, :maximum => 100
  18 + validates_length_of :objectives, :maximum => 4000
  19 + validates_length_of :features, :maximum => 4000
18 20  
19 21 validate :validate_acronym
20 22  
... ... @@ -104,10 +106,6 @@ class SoftwareInfo &lt; ActiveRecord::Base
104 106 true
105 107 end
106 108  
107   - def validate_operating_platform
108   - self.errors.add(:operating_platform, _("can't be blank")) if self.operating_platform.blank? && self.errors.messages[:operating_platform].nil?
109   - end
110   -
111 109 def validate_acronym
112 110 self.acronym = "" if self.acronym.nil?
113 111 if self.acronym.length > 10 && self.errors.messages[:acronym].nil?
... ...
test/unit/software_info_validation_test.rb
... ... @@ -43,9 +43,9 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
43 43 assert_equal true, @software_info.save
44 44 end
45 45  
46   - should 'Not save SoftwareInfo if operating_platform is blank' do
  46 + should 'Save SoftwareInfo if operating_platform is blank' do
47 47 @software_info.operating_platform = ''
48   - assert_equal false, @software_info.save
  48 + assert_equal true, @software_info.save
49 49 end
50 50  
51 51 should 'Save SoftwareInfo without demonstration_url be filled' do
... ... @@ -64,36 +64,34 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
64 64 assert_equal false, @software_info.save
65 65 end
66 66  
67   - should "Not save SoftwareInfo if acronym has whitespaces" do
  67 + should "Save SoftwareInfo if acronym has whitespaces" do
68 68 @software_info.acronym = "AC DC"
69 69 assert_equal false, @software_info.save
70 70 end
71 71  
72   - should "Not save if objectives are empty" do
  72 + should "Save if objectives are empty" do
73 73 @software_info.objectives = ""
74 74  
75   - assert_equal false, @software_info.save
76   - assert_equal true, @software_info.errors.full_messages.include?(_("Objectives can't be blank"))
  75 + assert_equal true, @software_info.save
77 76 end
78 77  
79   - should "Not save if features are empty" do
  78 + should "Save if features are empty" do
80 79 @software_info.features = ""
81 80  
82   - assert_equal false, @software_info.save
83   - assert_equal true, @software_info.errors.full_messages.include?(_("Features can't be blank"))
  81 + assert_equal true, @software_info.save
84 82 end
85 83  
86 84 should "Not save if features are longer than 4000" do
87 85 @software_info.features = "a"*4001
88 86  
89 87 assert_equal false, @software_info.save
90   - assert_equal true, @software_info.errors.full_messages.include?(_("Features Software features is too long (maximum is 4000 characters)"))
  88 + assert_equal true, @software_info.errors.full_messages.include?(_("Features is too long (maximum is 4000 characters)"))
91 89 end
92 90  
93 91 should "Not save if objectives are longer than 4000" do
94 92 @software_info.objectives = "a"*4001
95 93  
96 94 assert_equal false, @software_info.save
97   - assert_equal true, @software_info.errors.full_messages.include?(_("Objectives Software features is too long (maximum is 4000 characters)"))
  95 + assert_equal true, @software_info.errors.full_messages.include?(_("Objectives is too long (maximum is 4000 characters)"))
98 96 end
99 97 end
... ...