##// 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 def test_destroy
53 def test_destroy
54 changesets = Changeset.count(:all, :conditions => "repository_id = 10")
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 assert_difference 'Changeset.count', -changesets do
57 assert_difference 'Changeset.count', -changesets do
57 assert_difference 'Change.count', -changes do
58 assert_difference 'Change.count', -changes do
58 Repository.find(10).destroy
59 Repository.find(10).destroy
@@ -63,9 +64,11 class RepositoryTest < ActiveSupport::TestCase
63 def test_should_not_create_with_disabled_scm
64 def test_should_not_create_with_disabled_scm
64 # disable Subversion
65 # disable Subversion
65 with_settings :enabled_scm => ['Darcs', 'Git'] do
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 assert !repository.save
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 end
72 end
70 end
73 end
71
74
@@ -74,7 +77,9 class RepositoryTest < ActiveSupport::TestCase
74 Setting.notified_events = ['issue_added','issue_updated']
77 Setting.notified_events = ['issue_added','issue_updated']
75
78
76 # choosing a status to apply to fix issues
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 Setting.commit_fix_done_ratio = "90"
83 Setting.commit_fix_done_ratio = "90"
79 Setting.commit_ref_keywords = 'refs , references, IssueID'
84 Setting.commit_ref_keywords = 'refs , references, IssueID'
80 Setting.commit_fix_keywords = 'fixes , closes'
85 Setting.commit_fix_keywords = 'fixes , closes'
@@ -104,26 +109,33 class RepositoryTest < ActiveSupport::TestCase
104 assert_equal 2, ActionMailer::Base.deliveries.size
109 assert_equal 2, ActionMailer::Base.deliveries.size
105 mail = ActionMailer::Base.deliveries.first
110 mail = ActionMailer::Base.deliveries.first
106 assert_kind_of TMail::Mail, mail
111 assert_kind_of TMail::Mail, mail
107 assert mail.subject.starts_with?("[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]")
112 assert mail.subject.starts_with?(
108 assert mail.body.include?("Status changed from #{old_status} to #{fixed_issue.status}")
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 # ignoring commits referencing an issue of another project
117 # ignoring commits referencing an issue of another project
111 assert_equal [], Issue.find(4).changesets
118 assert_equal [], Issue.find(4).changesets
112 end
119 end
113
120
114 def test_for_changeset_comments_strip
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 comment = <<-COMMENT
125 comment = <<-COMMENT
117 This is a loooooooooooooooooooooooooooong comment
126 This is a loooooooooooooooooooooooooooong comment
118
127
119
128
120 COMMENT
129 COMMENT
121 changeset = Changeset.new(
130 changeset = Changeset.new(
122 :comments => comment, :commit_date => Time.now, :revision => 0, :scmid => 'f39b7922fb3c',
131 :comments => comment, :commit_date => Time.now,
123 :committer => 'foo <foo@example.com>', :committed_on => Time.now, :repository => repository )
132 :revision => 0, :scmid => 'f39b7922fb3c',
133 :committer => 'foo <foo@example.com>',
134 :committed_on => Time.now, :repository => repository )
124 assert( changeset.save )
135 assert( changeset.save )
125 assert_not_equal( comment, changeset.comments )
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 end
139 end
128
140
129 def test_for_urls_strip
141 def test_for_urls_strip
@@ -134,7 +146,8 class RepositoryTest < ActiveSupport::TestCase
134 :log_encoding => 'UTF-8')
146 :log_encoding => 'UTF-8')
135 assert repository.save
147 assert repository.save
136 repository.reload
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 assert_equal 'foo', repository.root_url
151 assert_equal 'foo', repository.root_url
139 end
152 end
140
153
General Comments 0
You need to be logged in to leave comments. Login now