##// END OF EJS Templates
Fixes repository user mapping submission when a repository username is blank (#2339, Conflicting types for parameter containers)....
Jean-Philippe Lang -
r2135:7cea286c2344
parent child
Show More
@@ -51,8 +51,9 class RepositoriesController < ApplicationController
51 @users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty?
51 @users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty?
52 @users.compact!
52 @users.compact!
53 @users.sort!
53 @users.sort!
54 if request.post?
54 if request.post? && params[:committers].is_a?(Hash)
55 @repository.committer_ids = params[:committers]
55 # Build a hash with repository usernames as keys and corresponding user ids as values
56 @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
56 flash[:notice] = l(:notice_successful_update)
57 flash[:notice] = l(:notice_successful_update)
57 redirect_to :action => 'committers', :id => @project
58 redirect_to :action => 'committers', :id => @project
58 end
59 end
@@ -15,11 +15,16
15 </tr>
15 </tr>
16 </thead>
16 </thead>
17 <tbody>
17 <tbody>
18 <% i = 0 -%>
18 <% @committers.each do |committer, user_id| -%>
19 <% @committers.each do |committer, user_id| -%>
19 <tr class="<%= cycle 'odd', 'even' %>">
20 <tr class="<%= cycle 'odd', 'even' %>">
20 <td><%=h committer %></td>
21 <td><%=h committer %></td>
21 <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>
22 <td>
23 <%= hidden_field_tag "committers[#{i}][]", committer %>
24 <%= 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) %>
25 </td>
22 </tr>
26 </tr>
27 <% i += 1 -%>
23 <% end -%>
28 <% end -%>
24 </tbody>
29 </tbody>
25 </table>
30 </table>
@@ -73,12 +73,12 class RepositoriesControllerTest < Test::Unit::TestCase
73
73
74 assert_tag :td, :content => 'dlopper',
74 assert_tag :td, :content => 'dlopper',
75 :sibling => { :tag => 'td',
75 :sibling => { :tag => 'td',
76 :child => { :tag => 'select', :attributes => { :name => 'committers[dlopper]' },
76 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} },
77 :child => { :tag => 'option', :content => 'Dave Lopper',
77 :child => { :tag => 'option', :content => 'Dave Lopper',
78 :attributes => { :value => '3', :selected => 'selected' }}}}
78 :attributes => { :value => '3', :selected => 'selected' }}}}
79 assert_tag :td, :content => 'foo',
79 assert_tag :td, :content => 'foo',
80 :sibling => { :tag => 'td',
80 :sibling => { :tag => 'td',
81 :child => { :tag => 'select', :attributes => { :name => 'committers[foo]' }}}
81 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}}
82 assert_no_tag :td, :content => 'foo',
82 assert_no_tag :td, :content => 'foo',
83 :sibling => { :tag => 'td',
83 :sibling => { :tag => 'td',
84 :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
84 :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
@@ -90,7 +90,7 class RepositoriesControllerTest < Test::Unit::TestCase
90 c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
90 c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
91
91
92 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
92 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
93 post :committers, :id => 1, :committers => { 'foo' => '2', 'dlopper' => '3'}
93 post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
94 assert_redirected_to '/repositories/committers/ecookbook'
94 assert_redirected_to '/repositories/committers/ecookbook'
95 assert_equal User.find(2), c.reload.user
95 assert_equal User.find(2), c.reload.user
96 end
96 end
General Comments 0
You need to be logged in to leave comments. Login now