@@ -38,7 +38,6 class Repository < ActiveRecord::Base | |||||
38 |
|
38 | |||
39 | validates_length_of :password, :maximum => 255, :allow_nil => true |
|
39 | validates_length_of :password, :maximum => 255, :allow_nil => true | |
40 | validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true |
|
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? } |
|
|||
42 | validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true |
|
41 | validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true | |
43 | validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision) |
|
42 | validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision) | |
44 | # donwcase letters, digits, dashes, underscores but not digits only |
|
43 | # donwcase letters, digits, dashes, underscores but not digits only |
@@ -53,6 +53,35 class RepositoryGitTest < ActiveSupport::TestCase | |||||
53 | end |
|
53 | end | |
54 | end |
|
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 | def test_blank_path_to_repository_error_message |
|
85 | def test_blank_path_to_repository_error_message | |
57 | set_language_if_valid 'en' |
|
86 | set_language_if_valid 'en' | |
58 | repo = Repository::Git.new( |
|
87 | repo = Repository::Git.new( |
General Comments 0
You need to be logged in to leave comments.
Login now