@@ -38,7 +38,7 class Repository < ActiveRecord::Base | |||
|
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_uniqueness_of :identifier, :scope => :project_id |
|
|
41 | validates_uniqueness_of :identifier, :scope => :project_id | |
|
42 | 42 | validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision) |
|
43 | 43 | # donwcase letters, digits, dashes, underscores but not digits only |
|
44 | 44 | validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true |
@@ -76,6 +76,24 class RepositoryTest < ActiveSupport::TestCase | |||
|
76 | 76 | assert_equal repository, project.repository |
|
77 | 77 | end |
|
78 | 78 | |
|
79 | def test_2_repositories_with_same_identifier_in_different_projects_should_be_valid | |
|
80 | Repository::Subversion.create!(:project_id => 2, :identifier => 'foo', :url => 'file:///foo') | |
|
81 | r = Repository::Subversion.new(:project_id => 3, :identifier => 'foo', :url => 'file:///bar') | |
|
82 | assert r.save | |
|
83 | end | |
|
84 | ||
|
85 | def test_2_repositories_with_same_identifier_should_not_be_valid | |
|
86 | Repository::Subversion.create!(:project_id => 3, :identifier => 'foo', :url => 'file:///foo') | |
|
87 | r = Repository::Subversion.new(:project_id => 3, :identifier => 'foo', :url => 'file:///bar') | |
|
88 | assert !r.save | |
|
89 | end | |
|
90 | ||
|
91 | def test_2_repositories_with_blank_identifier_should_not_be_valid | |
|
92 | Repository::Subversion.create!(:project_id => 3, :identifier => '', :url => 'file:///foo') | |
|
93 | r = Repository::Subversion.new(:project_id => 3, :identifier => '', :url => 'file:///bar') | |
|
94 | assert !r.save | |
|
95 | end | |
|
96 | ||
|
79 | 97 | def test_first_repository_should_be_set_as_default |
|
80 | 98 | repository1 = Repository::Subversion.new( |
|
81 | 99 | :project => Project.find(3), |
General Comments 0
You need to be logged in to leave comments.
Login now