Maps repository users to Redmine users (#1383).

Users with same username or email are automatically mapped. Mapping can be manually adjusted in repository settings. Multiple usernames can be mapped to the same Redmine user.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2006 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-11-10 18:59:06 +00:00
parent f6b2be81b9
commit 79c33bbc83
50 changed files with 228 additions and 24 deletions

View File

@@ -7,6 +7,7 @@ changesets_001:
comments: My very first commit
repository_id: 10
committer: dlopper
user_id: 3
changesets_002:
commit_date: 2007-04-12
committed_on: 2007-04-12 15:14:44 +02:00
@@ -15,6 +16,7 @@ changesets_002:
comments: 'This commit fixes #1, #2 and references #1 & #3'
repository_id: 10
committer: dlopper
user_id: 3
changesets_003:
commit_date: 2007-04-12
committed_on: 2007-04-12 15:14:44 +02:00
@@ -25,6 +27,7 @@ changesets_003:
IssueID 666 3
repository_id: 10
committer: dlopper
user_id: 3
changesets_004:
commit_date: 2007-04-12
committed_on: 2007-04-12 15:14:44 +02:00
@@ -35,4 +38,5 @@ changesets_004:
IssueID 4 2
repository_id: 10
committer: dlopper
user_id: 3

View File

@@ -43,6 +43,7 @@ roles_001:
- :view_files
- :manage_files
- :browse_repository
- :manage_repository
- :view_changesets
position: 1

View File

@@ -61,4 +61,38 @@ class RepositoriesControllerTest < Test::Unit::TestCase
assert_response :success
assert_equal 'image/svg+xml', @response.content_type
end
def test_committers
@request.session[:user_id] = 2
# add a commit with an unknown user
Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
get :committers, :id => 1
assert_response :success
assert_template 'committers'
assert_tag :td, :content => 'dlopper',
:sibling => { :tag => 'td',
:child => { :tag => 'select', :attributes => { :name => 'committers[dlopper]' },
:child => { :tag => 'option', :content => 'Dave Lopper',
:attributes => { :value => '3', :selected => 'selected' }}}}
assert_tag :td, :content => 'foo',
:sibling => { :tag => 'td',
:child => { :tag => 'select', :attributes => { :name => 'committers[foo]' }}}
assert_no_tag :td, :content => 'foo',
:sibling => { :tag => 'td',
:descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
end
def test_map_committers
@request.session[:user_id] = 2
# add a commit with an unknown user
c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
post :committers, :id => 1, :committers => { 'foo' => '2', 'dlopper' => '3'}
assert_redirected_to '/repositories/committers/ecookbook'
assert_equal User.find(2), c.reload.user
end
end
end

View File

@@ -40,6 +40,7 @@ class RepositoryGitTest < Test::Unit::TestCase
commit = @repository.changesets.find(:first, :order => 'committed_on ASC')
assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
assert_equal "jsmith <jsmith@foo.bar>", commit.committer
assert_equal User.find_by_login('jsmith'), commit.user
# TODO: add a commit with commit time <> author time to the test repository
assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on
assert_equal "2007-12-14".to_date, commit.commit_date

View File

@@ -127,4 +127,26 @@ class RepositoryTest < Test::Unit::TestCase
assert_equal ':pserver:login:password@host:/path/to/the/repository', repository.url
assert_equal 'foo', repository.root_url
end
def test_manual_user_mapping
assert_no_difference "Changeset.count(:conditions => 'user_id <> 2')" do
c = Changeset.create!(:repository => @repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
assert_nil c.user
@repository.committer_ids = {'foo' => '2'}
assert_equal User.find(2), c.reload.user
# committer is now mapped
c = Changeset.create!(:repository => @repository, :committer => 'foo', :committed_on => Time.now, :revision => 101, :comments => 'Another commit by foo.')
assert_equal User.find(2), c.user
end
end
def test_auto_user_mapping_by_username
c = Changeset.create!(:repository => @repository, :committer => 'jsmith', :committed_on => Time.now, :revision => 100, :comments => 'Committed by john.')
assert_equal User.find(2), c.user
end
def test_auto_user_mapping_by_email
c = Changeset.create!(:repository => @repository, :committer => 'john <jsmith@somenet.foo>', :committed_on => Time.now, :revision => 100, :comments => 'Committed by john.')
assert_equal User.find(2), c.user
end
end