Defect #19260 » repo_identifiers.diff
| app/models/repository.rb | ||
|---|---|---|
| 38 | 38 | |
| 39 | 39 |
validates_length_of :password, :maximum => 255, :allow_nil => true |
| 40 | 40 |
validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true |
| 41 |
validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
|
| 41 |
# validates_presence_of :identifier, :unless => Proc.new { |r| r.is_default? || r.set_as_default? }
|
|
| 42 | 42 |
validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true |
| 43 | 43 |
validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision) |
| 44 | 44 |
# donwcase letters, digits, dashes, underscores but not digits only |
| test/unit/repository_git_test.rb | ||
|---|---|---|
| 53 | 53 |
end |
| 54 | 54 |
end |
| 55 | 55 | |
| 56 |
def test_nondefault_repo_with_blank_identifier_destruction |
|
| 57 |
repo1 = Repository::Git.new( |
|
| 58 |
:project => @project, |
|
| 59 |
:url => REPOSITORY_PATH, |
|
| 60 |
:identifier => '', |
|
| 61 |
:is_default => true |
|
| 62 |
) |
|
| 63 |
assert repo1.save |
|
| 64 |
repo1.fetch_changesets |
|
| 65 | ||
| 66 |
repo2 = Repository::Git.new( |
|
| 67 |
:project => @project, |
|
| 68 |
:url => REPOSITORY_PATH, |
|
| 69 |
:identifier => 'repo2', |
|
| 70 |
:is_default => true |
|
| 71 |
) |
|
| 72 |
assert repo2.save |
|
| 73 |
repo2.fetch_changesets |
|
| 74 | ||
| 75 |
repo1.reload |
|
| 76 |
repo2.reload |
|
| 77 |
assert !repo1.is_default? |
|
| 78 |
assert repo2.is_default? |
|
| 79 | ||
| 80 |
assert_difference 'Repository.count', -1 do |
|
| 81 |
repo1.destroy |
|
| 82 |
end |
|
| 83 |
end |
|
| 84 | ||
| 56 | 85 |
def test_blank_path_to_repository_error_message |
| 57 | 86 |
set_language_if_valid 'en' |
| 58 | 87 |
repo = Repository::Git.new( |