]> source.dussan.org Git - redmine.git/commitdiff
Fix RuboCop offense Style/InverseMethods: Use `invalid?` instead of inverting `valid...
authorGo MAEDA <maeda@farend.jp>
Sat, 25 Mar 2023 01:51:31 +0000 (01:51 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 25 Mar 2023 01:51:31 +0000 (01:51 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22153 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/auth_source_ldap_test.rb
test/unit/custom_field_test.rb
test/unit/repository_cvs_test.rb
test/unit/repository_subversion_test.rb
test/unit/time_entry_test.rb
test/unit/user_test.rb
test/unit/version_test.rb
test/unit/watcher_test.rb

index 958c46e97e7f063edaf6bd0f403f1f45293cd4df..9c37746bf27dbca69a50cdca805676892ddc84ad 100644 (file)
@@ -75,7 +75,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
 
     a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :attr_login => 'sn')
     a.filter = "(mail=*@redmine.org"
-    assert !a.valid?
+    assert a.invalid?
     assert_include "LDAP filter is invalid", a.errors.full_messages
 
     a.filter = "(mail=*@redmine.org)"
index 5bdd79038bbdc85110b1549a36d7bba951559518..95f3cccc7cc06de98f350062ba1388da7acc26b4 100644 (file)
@@ -55,7 +55,7 @@ class CustomFieldTest < ActiveSupport::TestCase
   def test_default_value_should_be_validated
     field = CustomField.new(:name => 'Test', :field_format => 'int')
     field.default_value = 'abc'
-    assert !field.valid?
+    assert field.invalid?
     field.default_value = '6'
     assert field.valid?
   end
@@ -69,7 +69,7 @@ class CustomFieldTest < ActiveSupport::TestCase
 
   def test_field_format_should_be_validated
     field = CustomField.new(:name => 'Test', :field_format => 'foo')
-    assert !field.valid?
+    assert field.invalid?
   end
 
   def test_field_format_validation_should_accept_formats_added_at_runtime
index 543ed210eaf562930931a40cf6f674096f147475..b7052e3ca279b41d2155d149a674451115f8ec21 100644 (file)
@@ -104,7 +104,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
         :url           => MODULE_NAME
       )
       repo.root_url = '/wrong_path'
-      assert !repo.valid?
+      assert repo.invalid?
       assert repo.errors[:root_url].present?
 
       repo.root_url = '/cvspath/foo'
index a5645e5f40063623345e90d7ed820741cbe7a972..2328ab6d1dc96889434fa8663e9f67a40c84ec15 100644 (file)
@@ -66,11 +66,11 @@ class RepositorySubversionTest < ActiveSupport::TestCase
     Redmine::Configuration.with 'scm_subversion_path_regexp' => 'file:///svnpath/[a-z]+' do
       repo = Repository::Subversion.new(:project => @project, :identifier => 'test')
       repo.url = 'http://foo'
-      assert !repo.valid?
+      assert repo.invalid?
       assert repo.errors[:url].present?
 
       repo.url = 'file:///svnpath/foo/bar'
-      assert !repo.valid?
+      assert repo.invalid?
       assert repo.errors[:url].present?
 
       repo.url = 'file:///svnpath/foo'
@@ -82,7 +82,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
     Redmine::Configuration.with 'scm_subversion_path_regexp' => 'file:///svnpath/%project%(\.[a-z]+)?' do
       repo = Repository::Subversion.new(:project => @project, :identifier => 'test')
       repo.url = 'file:///svnpath/invalid'
-      assert !repo.valid?
+      assert repo.invalid?
       assert repo.errors[:url].present?
 
       repo.url = 'file:///svnpath/subproject1'
index 60145366934440dee6c68f2f46952d6858384aea..7f992e97099f777242b6971f0bda40712eef45f8 100644 (file)
@@ -229,14 +229,14 @@ class TimeEntryTest < ActiveSupport::TestCase
     activity = TimeEntryActivity.create!(:name => 'Other project activity', :project_id => 2, :active => true)
 
     entry = TimeEntry.new(:spent_on => Date.today, :hours => 1.0, :user => User.find(1), :project_id => 1, :activity => activity)
-    assert !entry.valid?
+    assert entry.invalid?
     assert_include I18n.translate('activerecord.errors.messages.inclusion'), entry.errors[:activity_id]
   end
 
   def test_spent_on_with_2_digits_year_should_not_be_valid
     entry = TimeEntry.new(:project => Project.find(1), :user => User.find(1), :activity => TimeEntryActivity.first, :hours => 1)
     entry.spent_on = "09-02-04"
-    assert !entry.valid?
+    assert entry.invalid?
     assert_include I18n.translate('activerecord.errors.messages.not_a_date'), entry.errors[:spent_on]
   end
 
index 577a7f972d40741f89cbe6743c8fb456f88ab8bd..bb108549bcd1fd3a6616e787b4ba2a8bd315d10a 100644 (file)
@@ -129,7 +129,7 @@ class UserTest < ActiveSupport::TestCase
   def test_login_length_validation
     user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
     user.login = "x" * (User::LOGIN_LENGTH_LIMIT+1)
-    assert !user.valid?
+    assert user.invalid?
 
     user.login = "x" * (User::LOGIN_LENGTH_LIMIT)
     assert user.valid?
index d51684bc03dfd914ed5ee46554670ef2950d03e4..c7ea0f4733287c853c05b63b43c39e9609a2ba4e 100644 (file)
@@ -56,15 +56,15 @@ class VersionTest < ActiveSupport::TestCase
   def test_invalid_effective_date_validation
     v = Version.new(:project => Project.find(1), :name => '1.1',
                     :effective_date => '99999-01-01')
-    assert !v.valid?
+    assert v.invalid?
     v.effective_date = '2012-11-33'
-    assert !v.valid?
+    assert v.invalid?
     v.effective_date = '2012-31-11'
-    assert !v.valid?
+    assert v.invalid?
     v.effective_date = '-2012-31-11'
-    assert !v.valid?
+    assert v.invalid?
     v.effective_date = 'ABC'
-    assert !v.valid?
+    assert v.invalid?
     assert_include I18n.translate('activerecord.errors.messages.not_a_date'),
                    v.errors[:effective_date]
   end
index 50eeee1c0844c5697881e3bedea1b8d6de185d96..1e95be2f6252e5008cd41fa722cc82a62f65a782 100644 (file)
@@ -91,7 +91,7 @@ class WatcherTest < ActiveSupport::TestCase
   def test_watcher_users_should_not_validate_user
     User.where(:id => 1).update_all("firstname = ''")
     @user.reload
-    assert !@user.valid?
+    assert @user.invalid?
 
     issue = Issue.new(:project => Project.find(1), :tracker_id => 1, :subject => "test", :author => User.find(2))
     issue.watcher_users << @user