Fixes repository user mapping submission when a repository username is blank (#2339, Conflicting types for parameter containers).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2137 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3bb2fccaf1
commit
7cea286c23
|
@ -51,8 +51,9 @@ class RepositoriesController < ApplicationController
|
||||||
@users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty?
|
@users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty?
|
||||||
@users.compact!
|
@users.compact!
|
||||||
@users.sort!
|
@users.sort!
|
||||||
if request.post?
|
if request.post? && params[:committers].is_a?(Hash)
|
||||||
@repository.committer_ids = params[:committers]
|
# Build a hash with repository usernames as keys and corresponding user ids as values
|
||||||
|
@repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'committers', :id => @project
|
redirect_to :action => 'committers', :id => @project
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,11 +15,16 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<% i = 0 -%>
|
||||||
<% @committers.each do |committer, user_id| -%>
|
<% @committers.each do |committer, user_id| -%>
|
||||||
<tr class="<%= cycle 'odd', 'even' %>">
|
<tr class="<%= cycle 'odd', 'even' %>">
|
||||||
<td><%=h committer %></td>
|
<td><%=h committer %></td>
|
||||||
<td><%= select_tag "committers[#{committer}]", content_tag('option', "-- #{l :actionview_instancetag_blank_option} --", :value => '') + options_from_collection_for_select(@users, 'id', 'name', user_id.to_i) %></td>
|
<td>
|
||||||
|
<%= hidden_field_tag "committers[#{i}][]", committer %>
|
||||||
|
<%= select_tag "committers[#{i}][]", content_tag('option', "-- #{l :actionview_instancetag_blank_option} --", :value => '') + options_from_collection_for_select(@users, 'id', 'name', user_id.to_i) %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% i += 1 -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -73,12 +73,12 @@ class RepositoriesControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_tag :td, :content => 'dlopper',
|
assert_tag :td, :content => 'dlopper',
|
||||||
:sibling => { :tag => 'td',
|
:sibling => { :tag => 'td',
|
||||||
:child => { :tag => 'select', :attributes => { :name => 'committers[dlopper]' },
|
:child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} },
|
||||||
:child => { :tag => 'option', :content => 'Dave Lopper',
|
:child => { :tag => 'option', :content => 'Dave Lopper',
|
||||||
:attributes => { :value => '3', :selected => 'selected' }}}}
|
:attributes => { :value => '3', :selected => 'selected' }}}}
|
||||||
assert_tag :td, :content => 'foo',
|
assert_tag :td, :content => 'foo',
|
||||||
:sibling => { :tag => 'td',
|
:sibling => { :tag => 'td',
|
||||||
:child => { :tag => 'select', :attributes => { :name => 'committers[foo]' }}}
|
:child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}}
|
||||||
assert_no_tag :td, :content => 'foo',
|
assert_no_tag :td, :content => 'foo',
|
||||||
:sibling => { :tag => 'td',
|
:sibling => { :tag => 'td',
|
||||||
:descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
|
:descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
|
||||||
|
@ -90,7 +90,7 @@ class RepositoriesControllerTest < Test::Unit::TestCase
|
||||||
c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
|
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
|
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
|
||||||
post :committers, :id => 1, :committers => { 'foo' => '2', 'dlopper' => '3'}
|
post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
|
||||||
assert_redirected_to '/repositories/committers/ecookbook'
|
assert_redirected_to '/repositories/committers/ecookbook'
|
||||||
assert_equal User.find(2), c.reload.user
|
assert_equal User.find(2), c.reload.user
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue