Mercurial > hg > soundsoftware-site
comparison test/unit/repository_test.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
95 | 95 |
96 assert_equal repository1, Project.find(3).repository | 96 assert_equal repository1, Project.find(3).repository |
97 assert_equal [repository1, repository2], Project.find(3).repositories.sort | 97 assert_equal [repository1, repository2], Project.find(3).repositories.sort |
98 end | 98 end |
99 | 99 |
100 def test_default_repository_should_be_one | |
101 assert_equal 0, Project.find(3).repositories.count | |
102 repository1 = Repository::Subversion.new( | |
103 :project => Project.find(3), | |
104 :identifier => 'svn1', | |
105 :url => 'file:///svn1' | |
106 ) | |
107 assert repository1.save | |
108 assert repository1.is_default? | |
109 | |
110 repository2 = Repository::Subversion.new( | |
111 :project => Project.find(3), | |
112 :identifier => 'svn2', | |
113 :url => 'file:///svn2', | |
114 :is_default => true | |
115 ) | |
116 assert repository2.save | |
117 assert repository2.is_default? | |
118 repository1.reload | |
119 assert !repository1.is_default? | |
120 | |
121 assert_equal repository2, Project.find(3).repository | |
122 assert_equal [repository2, repository1], Project.find(3).repositories.sort | |
123 end | |
124 | |
100 def test_identifier_should_accept_letters_digits_dashes_and_underscores | 125 def test_identifier_should_accept_letters_digits_dashes_and_underscores |
101 r = Repository::Subversion.new( | 126 r = Repository::Subversion.new( |
102 :project_id => 3, | 127 :project_id => 3, |
103 :identifier => 'svn-123_45', | 128 :identifier => 'svn-123_45', |
104 :url => 'file:///svn' | 129 :url => 'file:///svn' |
105 ) | 130 ) |
106 assert r.save | 131 assert r.save |
107 end | 132 end |
108 | 133 |
109 def test_identifier_should_not_be_frozen_for_a_new_repository | 134 def test_identifier_should_not_be_frozen_for_a_new_repository |
110 assert_equal false, Repository.new.identifier_frozen? | 135 assert_equal false, Repository.new.identifier_frozen? |
111 end | 136 end |
112 | 137 |
113 def test_identifier_should_not_be_frozen_for_a_saved_repository_with_blank_identifier | 138 def test_identifier_should_not_be_frozen_for_a_saved_repository_with_blank_identifier |
114 Repository.update_all(["identifier = ''"], "id = 10") | 139 Repository.where(:id => 10).update_all(["identifier = ''"]) |
115 | |
116 assert_equal false, Repository.find(10).identifier_frozen? | 140 assert_equal false, Repository.find(10).identifier_frozen? |
117 end | 141 end |
118 | 142 |
119 def test_identifier_should_be_frozen_for_a_saved_repository_with_valid_identifier | 143 def test_identifier_should_be_frozen_for_a_saved_repository_with_valid_identifier |
120 Repository.update_all(["identifier = 'abc123'"], "id = 10") | 144 Repository.where(:id => 10).update_all(["identifier = 'abc123'"]) |
121 | |
122 assert_equal true, Repository.find(10).identifier_frozen? | 145 assert_equal true, Repository.find(10).identifier_frozen? |
123 end | 146 end |
124 | 147 |
125 def test_identifier_should_not_accept_change_if_frozen | 148 def test_identifier_should_not_accept_change_if_frozen |
126 r = Repository.new(:identifier => 'foo') | 149 r = Repository.new(:identifier => 'foo') |
150 end | 173 end |
151 end | 174 end |
152 | 175 |
153 def test_destroy_should_delete_parents_associations | 176 def test_destroy_should_delete_parents_associations |
154 changeset = Changeset.find(102) | 177 changeset = Changeset.find(102) |
155 changeset.parents = Changeset.find_all_by_id([100, 101]) | 178 changeset.parents = Changeset.where(:id => [100, 101]).all |
156 | 179 assert_difference 'Changeset.connection.select_all("select * from changeset_parents").count', -2 do |
157 assert_difference 'Changeset.connection.select_all("select * from changeset_parents").size', -2 do | |
158 Repository.find(10).destroy | 180 Repository.find(10).destroy |
159 end | 181 end |
160 end | 182 end |
161 | 183 |
162 def test_destroy_should_delete_issues_associations | 184 def test_destroy_should_delete_issues_associations |
163 changeset = Changeset.find(102) | 185 changeset = Changeset.find(102) |
164 changeset.issues = Issue.find_all_by_id([1, 2]) | 186 changeset.issues = Issue.where(:id => [1, 2]).all |
165 | 187 assert_difference 'Changeset.connection.select_all("select * from changesets_issues").count', -2 do |
166 assert_difference 'Changeset.connection.select_all("select * from changesets_issues").size', -2 do | |
167 Repository.find(10).destroy | 188 Repository.find(10).destroy |
168 end | 189 end |
169 end | 190 end |
170 | 191 |
171 def test_should_not_create_with_disabled_scm | 192 def test_should_not_create_with_disabled_scm |
179 end | 200 end |
180 end | 201 end |
181 | 202 |
182 def test_scan_changesets_for_issue_ids | 203 def test_scan_changesets_for_issue_ids |
183 Setting.default_language = 'en' | 204 Setting.default_language = 'en' |
184 | |
185 Setting.commit_ref_keywords = 'refs , references, IssueID' | 205 Setting.commit_ref_keywords = 'refs , references, IssueID' |
186 Setting.commit_update_keywords = [ | 206 Setting.commit_update_keywords = [ |
187 {'keywords' => 'fixes , closes', 'status_id' => IssueStatus.where(:is_closed => true).first.id, 'done_ratio' => '90'} | 207 {'keywords' => 'fixes , closes', |
208 'status_id' => IssueStatus.where(:is_closed => true).first.id, | |
209 'done_ratio' => '90'} | |
188 ] | 210 ] |
189 Setting.default_language = 'en' | 211 Setting.default_language = 'en' |
190 ActionMailer::Base.deliveries.clear | 212 ActionMailer::Base.deliveries.clear |
191 | 213 |
192 # make sure issue 1 is not already closed | 214 # make sure issue 1 is not already closed |