Commit 70a9066353a1cb9a0a556e552c3f5aa11bdb4521
Committed by
Fabio Teixeira
1 parent
f5668ee4
Exists in
master
and in
5 other branches
Fix validation of software info.
Signed-off-by: Parley Martins <parley@outlook.com>
Showing
2 changed files
with
11 additions
and
15 deletions
Show diff stats
lib/software_info.rb
| ... | ... | @@ -15,6 +15,8 @@ class SoftwareInfo < 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 < 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 < 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 < 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 | ... | ... |