@@ -51,8 +51,9 class RepositoriesController < ApplicationController | |||
|
51 | 51 | @users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty? |
|
52 | 52 | @users.compact! |
|
53 | 53 | @users.sort! |
|
54 | if request.post? | |
|
55 | @repository.committer_ids = params[:committers] | |
|
54 | if request.post? && params[:committers].is_a?(Hash) | |
|
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 | 57 | flash[:notice] = l(:notice_successful_update) |
|
57 | 58 | redirect_to :action => 'committers', :id => @project |
|
58 | 59 | end |
@@ -15,11 +15,16 | |||
|
15 | 15 | </tr> |
|
16 | 16 | </thead> |
|
17 | 17 | <tbody> |
|
18 | <% i = 0 -%> | |
|
18 | 19 | <% @committers.each do |committer, user_id| -%> |
|
19 | 20 | <tr class="<%= cycle 'odd', 'even' %>"> |
|
20 | 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 | 26 | </tr> |
|
27 | <% i += 1 -%> | |
|
23 | 28 | <% end -%> |
|
24 | 29 | </tbody> |
|
25 | 30 | </table> |
@@ -73,12 +73,12 class RepositoriesControllerTest < Test::Unit::TestCase | |||
|
73 | 73 | |
|
74 | 74 | assert_tag :td, :content => 'dlopper', |
|
75 | 75 | :sibling => { :tag => 'td', |
|
76 |
:child => { :tag => 'select', :attributes => { :name => |
|
|
76 | :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }, | |
|
77 | 77 | :child => { :tag => 'option', :content => 'Dave Lopper', |
|
78 | 78 | :attributes => { :value => '3', :selected => 'selected' }}}} |
|
79 | 79 | assert_tag :td, :content => 'foo', |
|
80 | 80 | :sibling => { :tag => 'td', |
|
81 |
:child => { :tag => 'select', :attributes => { :name => |
|
|
81 | :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}} | |
|
82 | 82 | assert_no_tag :td, :content => 'foo', |
|
83 | 83 | :sibling => { :tag => 'td', |
|
84 | 84 | :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}} |
@@ -90,7 +90,7 class RepositoriesControllerTest < Test::Unit::TestCase | |||
|
90 | 90 | c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.') |
|
91 | 91 | |
|
92 | 92 | assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do |
|
93 |
post :committers, :id => 1, :committers => { ' |
|
|
93 | post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} | |
|
94 | 94 | assert_redirected_to '/repositories/committers/ecookbook' |
|
95 | 95 | assert_equal User.find(2), c.reload.user |
|
96 | 96 | end |
General Comments 0
You need to be logged in to leave comments.
Login now