mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 09:46:02 +01:00
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
This commit is contained in:
@@ -75,7 +75,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :attr_login => 'sn')
|
a = AuthSourceLdap.new(:name => 'My LDAP', :host => 'ldap.example.net', :port => 389, :attr_login => 'sn')
|
||||||
a.filter = "(mail=*@redmine.org"
|
a.filter = "(mail=*@redmine.org"
|
||||||
assert !a.valid?
|
assert a.invalid?
|
||||||
assert_include "LDAP filter is invalid", a.errors.full_messages
|
assert_include "LDAP filter is invalid", a.errors.full_messages
|
||||||
|
|
||||||
a.filter = "(mail=*@redmine.org)"
|
a.filter = "(mail=*@redmine.org)"
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class CustomFieldTest < ActiveSupport::TestCase
|
|||||||
def test_default_value_should_be_validated
|
def test_default_value_should_be_validated
|
||||||
field = CustomField.new(:name => 'Test', :field_format => 'int')
|
field = CustomField.new(:name => 'Test', :field_format => 'int')
|
||||||
field.default_value = 'abc'
|
field.default_value = 'abc'
|
||||||
assert !field.valid?
|
assert field.invalid?
|
||||||
field.default_value = '6'
|
field.default_value = '6'
|
||||||
assert field.valid?
|
assert field.valid?
|
||||||
end
|
end
|
||||||
@@ -69,7 +69,7 @@ class CustomFieldTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_field_format_should_be_validated
|
def test_field_format_should_be_validated
|
||||||
field = CustomField.new(:name => 'Test', :field_format => 'foo')
|
field = CustomField.new(:name => 'Test', :field_format => 'foo')
|
||||||
assert !field.valid?
|
assert field.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_field_format_validation_should_accept_formats_added_at_runtime
|
def test_field_format_validation_should_accept_formats_added_at_runtime
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
|
|||||||
:url => MODULE_NAME
|
:url => MODULE_NAME
|
||||||
)
|
)
|
||||||
repo.root_url = '/wrong_path'
|
repo.root_url = '/wrong_path'
|
||||||
assert !repo.valid?
|
assert repo.invalid?
|
||||||
assert repo.errors[:root_url].present?
|
assert repo.errors[:root_url].present?
|
||||||
|
|
||||||
repo.root_url = '/cvspath/foo'
|
repo.root_url = '/cvspath/foo'
|
||||||
|
|||||||
@@ -66,11 +66,11 @@ class RepositorySubversionTest < ActiveSupport::TestCase
|
|||||||
Redmine::Configuration.with 'scm_subversion_path_regexp' => 'file:///svnpath/[a-z]+' do
|
Redmine::Configuration.with 'scm_subversion_path_regexp' => 'file:///svnpath/[a-z]+' do
|
||||||
repo = Repository::Subversion.new(:project => @project, :identifier => 'test')
|
repo = Repository::Subversion.new(:project => @project, :identifier => 'test')
|
||||||
repo.url = 'http://foo'
|
repo.url = 'http://foo'
|
||||||
assert !repo.valid?
|
assert repo.invalid?
|
||||||
assert repo.errors[:url].present?
|
assert repo.errors[:url].present?
|
||||||
|
|
||||||
repo.url = 'file:///svnpath/foo/bar'
|
repo.url = 'file:///svnpath/foo/bar'
|
||||||
assert !repo.valid?
|
assert repo.invalid?
|
||||||
assert repo.errors[:url].present?
|
assert repo.errors[:url].present?
|
||||||
|
|
||||||
repo.url = 'file:///svnpath/foo'
|
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
|
Redmine::Configuration.with 'scm_subversion_path_regexp' => 'file:///svnpath/%project%(\.[a-z]+)?' do
|
||||||
repo = Repository::Subversion.new(:project => @project, :identifier => 'test')
|
repo = Repository::Subversion.new(:project => @project, :identifier => 'test')
|
||||||
repo.url = 'file:///svnpath/invalid'
|
repo.url = 'file:///svnpath/invalid'
|
||||||
assert !repo.valid?
|
assert repo.invalid?
|
||||||
assert repo.errors[:url].present?
|
assert repo.errors[:url].present?
|
||||||
|
|
||||||
repo.url = 'file:///svnpath/subproject1'
|
repo.url = 'file:///svnpath/subproject1'
|
||||||
|
|||||||
@@ -229,14 +229,14 @@ class TimeEntryTest < ActiveSupport::TestCase
|
|||||||
activity = TimeEntryActivity.create!(:name => 'Other project activity', :project_id => 2, :active => true)
|
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)
|
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]
|
assert_include I18n.translate('activerecord.errors.messages.inclusion'), entry.errors[:activity_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spent_on_with_2_digits_year_should_not_be_valid
|
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 = TimeEntry.new(:project => Project.find(1), :user => User.find(1), :activity => TimeEntryActivity.first, :hours => 1)
|
||||||
entry.spent_on = "09-02-04"
|
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]
|
assert_include I18n.translate('activerecord.errors.messages.not_a_date'), entry.errors[:spent_on]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
def test_login_length_validation
|
def test_login_length_validation
|
||||||
user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
||||||
user.login = "x" * (User::LOGIN_LENGTH_LIMIT+1)
|
user.login = "x" * (User::LOGIN_LENGTH_LIMIT+1)
|
||||||
assert !user.valid?
|
assert user.invalid?
|
||||||
|
|
||||||
user.login = "x" * (User::LOGIN_LENGTH_LIMIT)
|
user.login = "x" * (User::LOGIN_LENGTH_LIMIT)
|
||||||
assert user.valid?
|
assert user.valid?
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ class VersionTest < ActiveSupport::TestCase
|
|||||||
def test_invalid_effective_date_validation
|
def test_invalid_effective_date_validation
|
||||||
v = Version.new(:project => Project.find(1), :name => '1.1',
|
v = Version.new(:project => Project.find(1), :name => '1.1',
|
||||||
:effective_date => '99999-01-01')
|
:effective_date => '99999-01-01')
|
||||||
assert !v.valid?
|
assert v.invalid?
|
||||||
v.effective_date = '2012-11-33'
|
v.effective_date = '2012-11-33'
|
||||||
assert !v.valid?
|
assert v.invalid?
|
||||||
v.effective_date = '2012-31-11'
|
v.effective_date = '2012-31-11'
|
||||||
assert !v.valid?
|
assert v.invalid?
|
||||||
v.effective_date = '-2012-31-11'
|
v.effective_date = '-2012-31-11'
|
||||||
assert !v.valid?
|
assert v.invalid?
|
||||||
v.effective_date = 'ABC'
|
v.effective_date = 'ABC'
|
||||||
assert !v.valid?
|
assert v.invalid?
|
||||||
assert_include I18n.translate('activerecord.errors.messages.not_a_date'),
|
assert_include I18n.translate('activerecord.errors.messages.not_a_date'),
|
||||||
v.errors[:effective_date]
|
v.errors[:effective_date]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class WatcherTest < ActiveSupport::TestCase
|
|||||||
def test_watcher_users_should_not_validate_user
|
def test_watcher_users_should_not_validate_user
|
||||||
User.where(:id => 1).update_all("firstname = ''")
|
User.where(:id => 1).update_all("firstname = ''")
|
||||||
@user.reload
|
@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 = Issue.new(:project => Project.find(1), :tracker_id => 1, :subject => "test", :author => User.find(2))
|
||||||
issue.watcher_users << @user
|
issue.watcher_users << @user
|
||||||
|
|||||||
Reference in New Issue
Block a user