##// 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 :member_roles,
33 :member_roles,
34 :roles,
34 :roles,
35 :enumerations
35 :enumerations
36
36
37 def setup
37 def setup
38 @repository = Project.find(1).repository
38 @repository = Project.find(1).repository
39 end
39 end
40
40
41 def test_create
41 def test_create
42 repository = Repository::Subversion.new(:project => Project.find(3))
42 repository = Repository::Subversion.new(:project => Project.find(3))
43 assert !repository.save
43 assert !repository.save
@@ -49,7 +49,7 class RepositoryTest < ActiveSupport::TestCase
49 project = Project.find(3)
49 project = Project.find(3)
50 assert_equal repository, project.repository
50 assert_equal repository, project.repository
51 end
51 end
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", :include => :changeset)
@@ -59,7 +59,7 class RepositoryTest < ActiveSupport::TestCase
59 end
59 end
60 end
60 end
61 end
61 end
62
62
63 def test_should_not_create_with_disabled_scm
63 def test_should_not_create_with_disabled_scm
64 # disable Subversion
64 # disable Subversion
65 with_settings :enabled_scm => ['Darcs', 'Git'] do
65 with_settings :enabled_scm => ['Darcs', 'Git'] do
@@ -68,7 +68,7 class RepositoryTest < ActiveSupport::TestCase
68 assert_equal I18n.translate('activerecord.errors.messages.invalid'), repository.errors.on(:type)
68 assert_equal I18n.translate('activerecord.errors.messages.invalid'), repository.errors.on(:type)
69 end
69 end
70 end
70 end
71
71
72 def test_scan_changesets_for_issue_ids
72 def test_scan_changesets_for_issue_ids
73 Setting.default_language = 'en'
73 Setting.default_language = 'en'
74 Setting.notified_events = ['issue_added','issue_updated']
74 Setting.notified_events = ['issue_added','issue_updated']
@@ -110,7 +110,7 class RepositoryTest < ActiveSupport::TestCase
110 # ignoring commits referencing an issue of another project
110 # ignoring commits referencing an issue of another project
111 assert_equal [], Issue.find(4).changesets
111 assert_equal [], Issue.find(4).changesets
112 end
112 end
113
113
114 def test_for_changeset_comments_strip
114 def test_for_changeset_comments_strip
115 repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' )
115 repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' )
116 comment = <<-COMMENT
116 comment = <<-COMMENT
@@ -140,23 +140,47 class RepositoryTest < ActiveSupport::TestCase
140
140
141 def test_manual_user_mapping
141 def test_manual_user_mapping
142 assert_no_difference "Changeset.count(:conditions => 'user_id <> 2')" do
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 assert_nil c.user
150 assert_nil c.user
145 @repository.committer_ids = {'foo' => '2'}
151 @repository.committer_ids = {'foo' => '2'}
146 assert_equal User.find(2), c.reload.user
152 assert_equal User.find(2), c.reload.user
147 # committer is now mapped
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 assert_equal User.find(2), c.user
161 assert_equal User.find(2), c.user
150 end
162 end
151 end
163 end
152
164
153 def test_auto_user_mapping_by_username
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 assert_equal User.find(2), c.user
173 assert_equal User.find(2), c.user
156 end
174 end
157
175
158 def test_auto_user_mapping_by_email
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 assert_equal User.find(2), c.user
184 assert_equal User.find(2), c.user
161 end
185 end
162 end
186 end
General Comments 0
You need to be logged in to leave comments. Login now