comparison test/unit/changeset_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents 5f33065ddc4b
children 622f24f53b42 261b3d9a4903
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # encoding: utf-8 1 # encoding: utf-8
2 # 2 #
3 # Redmine - project management software 3 # Redmine - project management software
4 # Copyright (C) 2006-2011 Jean-Philippe Lang 4 # Copyright (C) 2006-2012 Jean-Philippe Lang
5 # 5 #
6 # This program is free software; you can redistribute it and/or 6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License 7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2 8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version. 9 # of the License, or (at your option) any later version.
25 :changesets, :changes, 25 :changesets, :changes,
26 :enumerations, 26 :enumerations,
27 :custom_fields, :custom_values, 27 :custom_fields, :custom_values,
28 :users, :members, :member_roles, :trackers, 28 :users, :members, :member_roles, :trackers,
29 :enabled_modules, :roles 29 :enabled_modules, :roles
30
31 def setup
32 end
33 30
34 def test_ref_keywords_any 31 def test_ref_keywords_any
35 ActionMailer::Base.deliveries.clear 32 ActionMailer::Base.deliveries.clear
36 Setting.commit_fix_status_id = IssueStatus.find( 33 Setting.commit_fix_status_id = IssueStatus.find(
37 :first, :conditions => ["is_closed = ?", true]).id 34 :first, :conditions => ["is_closed = ?", true]).id
177 assert_equal [5], c.issue_ids.sort 174 assert_equal [5], c.issue_ids.sort
178 assert c.issues.first.project != c.project 175 assert c.issues.first.project != c.project
179 end 176 end
180 177
181 def test_commit_closing_a_subproject_issue 178 def test_commit_closing_a_subproject_issue
182 with_settings :commit_fix_status_id => 5, :commit_fix_keywords => 'closes' do 179 with_settings :commit_fix_status_id => 5, :commit_fix_keywords => 'closes',
180 :default_language => 'en' do
183 issue = Issue.find(5) 181 issue = Issue.find(5)
184 assert !issue.closed? 182 assert !issue.closed?
185 assert_difference 'Journal.count' do 183 assert_difference 'Journal.count' do
186 c = Changeset.new(:repository => Project.find(1).repository, 184 c = Changeset.new(:repository => Project.find(1).repository,
187 :committed_on => Time.now, 185 :committed_on => Time.now,
208 assert c.save 206 assert c.save
209 assert_equal [2], c.issue_ids.sort 207 assert_equal [2], c.issue_ids.sort
210 assert c.issues.first.project != c.project 208 assert c.issues.first.project != c.project
211 end 209 end
212 210
211 def test_commit_referencing_a_project_with_commit_cross_project_ref_disabled
212 r = Repository::Subversion.create!(
213 :project => Project.find(3),
214 :url => 'svn://localhost/test')
215
216 with_settings :commit_cross_project_ref => '0' do
217 c = Changeset.new(:repository => r,
218 :committed_on => Time.now,
219 :comments => 'refs #4, an issue of a different project',
220 :revision => '12345')
221 assert c.save
222 assert_equal [], c.issue_ids
223 end
224 end
225
226 def test_commit_referencing_a_project_with_commit_cross_project_ref_enabled
227 r = Repository::Subversion.create!(
228 :project => Project.find(3),
229 :url => 'svn://localhost/test')
230
231 with_settings :commit_cross_project_ref => '1' do
232 c = Changeset.new(:repository => r,
233 :committed_on => Time.now,
234 :comments => 'refs #4, an issue of a different project',
235 :revision => '12345')
236 assert c.save
237 assert_equal [4], c.issue_ids
238 end
239 end
240
213 def test_text_tag_revision 241 def test_text_tag_revision
214 c = Changeset.new(:revision => '520') 242 c = Changeset.new(:revision => '520')
215 assert_equal 'r520', c.text_tag 243 assert_equal 'r520', c.text_tag
216 end 244 end
217 245
221 end 249 end
222 250
223 def test_text_tag_revision_with_different_project 251 def test_text_tag_revision_with_different_project
224 c = Changeset.new(:revision => '520', :repository => Project.find(1).repository) 252 c = Changeset.new(:revision => '520', :repository => Project.find(1).repository)
225 assert_equal 'ecookbook:r520', c.text_tag(Project.find(2)) 253 assert_equal 'ecookbook:r520', c.text_tag(Project.find(2))
254 end
255
256 def test_text_tag_revision_with_repository_identifier
257 r = Repository::Subversion.create!(
258 :project_id => 1,
259 :url => 'svn://localhost/test',
260 :identifier => 'documents')
261
262 c = Changeset.new(:revision => '520', :repository => r)
263 assert_equal 'documents|r520', c.text_tag
264 assert_equal 'ecookbook:documents|r520', c.text_tag(Project.find(2))
226 end 265 end
227 266
228 def test_text_tag_hash 267 def test_text_tag_hash
229 c = Changeset.new( 268 c = Changeset.new(
230 :scmid => '7234cb2750b63f47bff735edc50a1c0a433c2518', 269 :scmid => '7234cb2750b63f47bff735edc50a1c0a433c2518',