You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repository_test.rb 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # redMine - project management software
  2. # Copyright (C) 2006-2007 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.dirname(__FILE__) + '/../test_helper'
  18. class RepositoryTest < Test::Unit::TestCase
  19. fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes
  20. def setup
  21. @repository = Project.find(1).repository
  22. end
  23. def test_create
  24. repository = Repository::Subversion.new(:project => Project.find(3))
  25. assert !repository.save
  26. repository.url = "svn://localhost"
  27. assert repository.save
  28. repository.reload
  29. project = Project.find(3)
  30. assert_equal repository, project.repository
  31. end
  32. def test_scan_changesets_for_issue_ids
  33. # choosing a status to apply to fix issues
  34. Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
  35. Setting.commit_fix_done_ratio = "90"
  36. Setting.commit_ref_keywords = 'refs , references, IssueID'
  37. Setting.commit_fix_keywords = 'fixes , closes'
  38. # make sure issue 1 is not already closed
  39. assert !Issue.find(1).status.is_closed?
  40. Repository.scan_changesets_for_issue_ids
  41. assert_equal [101, 102], Issue.find(3).changeset_ids
  42. # fixed issues
  43. fixed_issue = Issue.find(1)
  44. assert fixed_issue.status.is_closed?
  45. assert_equal 90, fixed_issue.done_ratio
  46. assert_equal [101], fixed_issue.changeset_ids
  47. # ignoring commits referencing an issue of another project
  48. assert_equal [], Issue.find(4).changesets
  49. end
  50. def test_for_changeset_comments_strip
  51. repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' )
  52. comment = <<-COMMENT
  53. This is a loooooooooooooooooooooooooooong comment
  54. COMMENT
  55. changeset = Changeset.new(
  56. :comments => comment, :commit_date => Time.now, :revision => 0, :scmid => 'f39b7922fb3c',
  57. :committer => 'foo <foo@example.com>', :committed_on => Time.now, :repository => repository )
  58. assert( changeset.save )
  59. assert_not_equal( comment, changeset.comments )
  60. assert_equal( 'This is a loooooooooooooooooooooooooooong comment', changeset.comments )
  61. end
  62. end