##// END OF EJS Templates
scm: code clean up test/unit/repository_test.rb....
Toshi MARUYAMA -
r5075:d590a5583bbf
parent child
Show More
@@ -33,11 +33,11 class RepositoryTest < ActiveSupport::TestCase
33 33 :member_roles,
34 34 :roles,
35 35 :enumerations
36
36
37 37 def setup
38 38 @repository = Project.find(1).repository
39 39 end
40
40
41 41 def test_create
42 42 repository = Repository::Subversion.new(:project => Project.find(3))
43 43 assert !repository.save
@@ -49,7 +49,7 class RepositoryTest < ActiveSupport::TestCase
49 49 project = Project.find(3)
50 50 assert_equal repository, project.repository
51 51 end
52
52
53 53 def test_destroy
54 54 changesets = Changeset.count(:all, :conditions => "repository_id = 10")
55 55 changes = Change.count(:all, :conditions => "repository_id = 10", :include => :changeset)
@@ -59,7 +59,7 class RepositoryTest < ActiveSupport::TestCase
59 59 end
60 60 end
61 61 end
62
62
63 63 def test_should_not_create_with_disabled_scm
64 64 # disable Subversion
65 65 with_settings :enabled_scm => ['Darcs', 'Git'] do
@@ -68,7 +68,7 class RepositoryTest < ActiveSupport::TestCase
68 68 assert_equal I18n.translate('activerecord.errors.messages.invalid'), repository.errors.on(:type)
69 69 end
70 70 end
71
71
72 72 def test_scan_changesets_for_issue_ids
73 73 Setting.default_language = 'en'
74 74 Setting.notified_events = ['issue_added','issue_updated']
@@ -110,7 +110,7 class RepositoryTest < ActiveSupport::TestCase
110 110 # ignoring commits referencing an issue of another project
111 111 assert_equal [], Issue.find(4).changesets
112 112 end
113
113
114 114 def test_for_changeset_comments_strip
115 115 repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' )
116 116 comment = <<-COMMENT
@@ -140,23 +140,47 class RepositoryTest < ActiveSupport::TestCase
140 140
141 141 def test_manual_user_mapping
142 142 assert_no_difference "Changeset.count(:conditions => 'user_id <> 2')" do
143 c = Changeset.create!(:repository => @repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
143 c = Changeset.create!(
144 :repository => @repository,
145 :committer => 'foo',
146 :committed_on => Time.now,
147 :revision => 100,
148 :comments => 'Committed by foo.'
149 )
144 150 assert_nil c.user
145 151 @repository.committer_ids = {'foo' => '2'}
146 152 assert_equal User.find(2), c.reload.user
147 153 # committer is now mapped
148 c = Changeset.create!(:repository => @repository, :committer => 'foo', :committed_on => Time.now, :revision => 101, :comments => 'Another commit by foo.')
154 c = Changeset.create!(
155 :repository => @repository,
156 :committer => 'foo',
157 :committed_on => Time.now,
158 :revision => 101,
159 :comments => 'Another commit by foo.'
160 )
149 161 assert_equal User.find(2), c.user
150 162 end
151 163 end
152
164
153 165 def test_auto_user_mapping_by_username
154 c = Changeset.create!(:repository => @repository, :committer => 'jsmith', :committed_on => Time.now, :revision => 100, :comments => 'Committed by john.')
166 c = Changeset.create!(
167 :repository => @repository,
168 :committer => 'jsmith',
169 :committed_on => Time.now,
170 :revision => 100,
171 :comments => 'Committed by john.'
172 )
155 173 assert_equal User.find(2), c.user
156 174 end
157
175
158 176 def test_auto_user_mapping_by_email
159 c = Changeset.create!(:repository => @repository, :committer => 'john <jsmith@somenet.foo>', :committed_on => Time.now, :revision => 100, :comments => 'Committed by john.')
177 c = Changeset.create!(
178 :repository => @repository,
179 :committer => 'john <jsmith@somenet.foo>',
180 :committed_on => Time.now,
181 :revision => 100,
182 :comments => 'Committed by john.'
183 )
160 184 assert_equal User.find(2), c.user
161 185 end
162 186 end
General Comments 0
You need to be logged in to leave comments. Login now