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)"
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
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
: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'
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'
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'
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
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?
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
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