##// END OF EJS Templates
scm: code clean up unit repository test....
Toshi MARUYAMA -
r5589:a05a2e0c4d0d
parent child
Show More
@@ -52,7 +52,8 class RepositoryTest < ActiveSupport::TestCase
52 52
53 53 def test_destroy
54 54 changesets = Changeset.count(:all, :conditions => "repository_id = 10")
55 changes = Change.count(:all, :conditions => "repository_id = 10", :include => :changeset)
55 changes = Change.count(:all, :conditions => "repository_id = 10",
56 :include => :changeset)
56 57 assert_difference 'Changeset.count', -changesets do
57 58 assert_difference 'Change.count', -changes do
58 59 Repository.find(10).destroy
@@ -63,9 +64,11 class RepositoryTest < ActiveSupport::TestCase
63 64 def test_should_not_create_with_disabled_scm
64 65 # disable Subversion
65 66 with_settings :enabled_scm => ['Darcs', 'Git'] do
66 repository = Repository::Subversion.new(:project => Project.find(3), :url => "svn://localhost")
67 repository = Repository::Subversion.new(
68 :project => Project.find(3), :url => "svn://localhost")
67 69 assert !repository.save
68 assert_equal I18n.translate('activerecord.errors.messages.invalid'), repository.errors.on(:type)
70 assert_equal I18n.translate('activerecord.errors.messages.invalid'),
71 repository.errors.on(:type)
69 72 end
70 73 end
71 74
@@ -74,7 +77,9 class RepositoryTest < ActiveSupport::TestCase
74 77 Setting.notified_events = ['issue_added','issue_updated']
75 78
76 79 # choosing a status to apply to fix issues
77 Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
80 Setting.commit_fix_status_id = IssueStatus.find(
81 :first,
82 :conditions => ["is_closed = ?", true]).id
78 83 Setting.commit_fix_done_ratio = "90"
79 84 Setting.commit_ref_keywords = 'refs , references, IssueID'
80 85 Setting.commit_fix_keywords = 'fixes , closes'
@@ -104,26 +109,33 class RepositoryTest < ActiveSupport::TestCase
104 109 assert_equal 2, ActionMailer::Base.deliveries.size
105 110 mail = ActionMailer::Base.deliveries.first
106 111 assert_kind_of TMail::Mail, mail
107 assert mail.subject.starts_with?("[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]")
108 assert mail.body.include?("Status changed from #{old_status} to #{fixed_issue.status}")
112 assert mail.subject.starts_with?(
113 "[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]")
114 assert mail.body.include?(
115 "Status changed from #{old_status} to #{fixed_issue.status}")
109 116
110 117 # ignoring commits referencing an issue of another project
111 118 assert_equal [], Issue.find(4).changesets
112 119 end
113 120
114 121 def test_for_changeset_comments_strip
115 repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' )
122 repository = Repository::Mercurial.create(
123 :project => Project.find( 4 ),
124 :url => '/foo/bar/baz' )
116 125 comment = <<-COMMENT
117 126 This is a loooooooooooooooooooooooooooong comment
118 127
119 128
120 129 COMMENT
121 130 changeset = Changeset.new(
122 :comments => comment, :commit_date => Time.now, :revision => 0, :scmid => 'f39b7922fb3c',
123 :committer => 'foo <foo@example.com>', :committed_on => Time.now, :repository => repository )
131 :comments => comment, :commit_date => Time.now,
132 :revision => 0, :scmid => 'f39b7922fb3c',
133 :committer => 'foo <foo@example.com>',
134 :committed_on => Time.now, :repository => repository )
124 135 assert( changeset.save )
125 136 assert_not_equal( comment, changeset.comments )
126 assert_equal( 'This is a loooooooooooooooooooooooooooong comment', changeset.comments )
137 assert_equal( 'This is a loooooooooooooooooooooooooooong comment',
138 changeset.comments )
127 139 end
128 140
129 141 def test_for_urls_strip
@@ -134,7 +146,8 class RepositoryTest < ActiveSupport::TestCase
134 146 :log_encoding => 'UTF-8')
135 147 assert repository.save
136 148 repository.reload
137 assert_equal ':pserver:login:password@host:/path/to/the/repository', repository.url
149 assert_equal ':pserver:login:password@host:/path/to/the/repository',
150 repository.url
138 151 assert_equal 'foo', repository.root_url
139 152 end
140 153
General Comments 0
You need to be logged in to leave comments. Login now