summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-03-25 01:51:31 +0000
committerGo MAEDA <maeda@farend.jp>2023-03-25 01:51:31 +0000
commitc1c9a5039784a7d97e104c4ffd84695ff8a25823 (patch)
treebe87a012c4ff31ef837fa7bd17773a31294a2f3e
parent32d2b1c42f76c07e13bcf748b2071a29cf350606 (diff)
downloadredmine-c1c9a5039784a7d97e104c4ffd84695ff8a25823.tar.gz
redmine-c1c9a5039784a7d97e104c4ffd84695ff8a25823.zip
Fix RuboCop offense Style/InverseMethods: Use `invalid?` instead of inverting `valid?` (#37248).
git-svn-id: https://svn.redmine.org/redmine/trunk@22153 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--test/unit/auth_source_ldap_test.rb2
-rw-r--r--test/unit/custom_field_test.rb4
-rw-r--r--test/unit/repository_cvs_test.rb2
-rw-r--r--test/unit/repository_subversion_test.rb6
-rw-r--r--test/unit/time_entry_test.rb4
-rw-r--r--test/unit/user_test.rb2
-rw-r--r--test/unit/version_test.rb10
-rw-r--r--test/unit/watcher_test.rb2
8 files changed, 16 insertions, 16 deletions
diff --git a/test/unit/auth_source_ldap_test.rb b/test/unit/auth_source_ldap_test.rb
index 958c46e97..9c37746bf 100644
--- a/test/unit/auth_source_ldap_test.rb
+++ b/test/unit/auth_source_ldap_test.rb
@@ -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)"
diff --git a/test/unit/custom_field_test.rb b/test/unit/custom_field_test.rb
index 5bdd79038..95f3cccc7 100644
--- a/test/unit/custom_field_test.rb
+++ b/test/unit/custom_field_test.rb
@@ -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
diff --git a/test/unit/repository_cvs_test.rb b/test/unit/repository_cvs_test.rb
index 543ed210e..b7052e3ca 100644
--- a/test/unit/repository_cvs_test.rb
+++ b/test/unit/repository_cvs_test.rb
@@ -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'
diff --git a/test/unit/repository_subversion_test.rb b/test/unit/repository_subversion_test.rb
index a5645e5f4..2328ab6d1 100644
--- a/test/unit/repository_subversion_test.rb
+++ b/test/unit/repository_subversion_test.rb
@@ -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'
diff --git a/test/unit/time_entry_test.rb b/test/unit/time_entry_test.rb
index 601453669..7f992e970 100644
--- a/test/unit/time_entry_test.rb
+++ b/test/unit/time_entry_test.rb
@@ -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
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 577a7f972..bb108549b 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -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?
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb
index d51684bc0..c7ea0f473 100644
--- a/test/unit/version_test.rb
+++ b/test/unit/version_test.rb
@@ -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
diff --git a/test/unit/watcher_test.rb b/test/unit/watcher_test.rb
index 50eeee1c0..1e95be2f6 100644
--- a/test/unit/watcher_test.rb
+++ b/test/unit/watcher_test.rb
@@ -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