diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-27 10:47:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-27 10:47:36 +0000 |
commit | f680e7f8acc14257bb585ef43a0a0572bdef0bdd (patch) | |
tree | e0fe19b2c70adaf75dd79b46f784c002ffcb9748 | |
parent | 1ebe9640a6b7a8d06627bb73452955d09cd965e0 (diff) | |
download | redmine-f680e7f8acc14257bb585ef43a0a0572bdef0bdd.tar.gz redmine-f680e7f8acc14257bb585ef43a0a0572bdef0bdd.zip |
Adds routes for group users.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7946 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/groups_controller.rb | 2 | ||||
-rw-r--r-- | app/views/groups/_users.html.erb | 9 | ||||
-rw-r--r-- | config/routes.rb | 5 | ||||
-rw-r--r-- | test/functional/groups_controller_test.rb | 2 | ||||
-rw-r--r-- | test/integration/routing_test.rb | 5 |
5 files changed, 15 insertions, 8 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index c5f0b3e37..bcb25012d 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -125,7 +125,7 @@ class GroupsController < ApplicationController def remove_user @group = Group.find(params[:id]) - @group.users.delete(User.find(params[:user_id])) if request.post? + @group.users.delete(User.find(params[:user_id])) if request.delete? respond_to do |format| format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} } diff --git a/app/views/groups/_users.html.erb b/app/views/groups/_users.html.erb index ad6262249..310777dee 100644 --- a/app/views/groups/_users.html.erb +++ b/app/views/groups/_users.html.erb @@ -10,9 +10,7 @@ <tr id="user-<%= user.id %>" class="<%= cycle 'odd', 'even' %>"> <td class="user"><%= link_to_user user %></td> <td class="buttons"> - <%= link_to_remote l(:button_delete), { :url => { :controller => 'groups', :action => 'remove_user', :id => @group, :user_id => user }, - :method => :post }, - :class => 'icon icon-del' %> + <%= link_to_remote l(:button_delete), { :url => group_user_path(@group, :user_id => user), :method => :delete }, :class => 'icon icon-del' %> </td> </tr> <% end %> @@ -26,14 +24,15 @@ <div class="splitcontentright"> <% users = User.active.not_in_group(@group).all(:limit => 100) %> <% if users.any? %> - <% remote_form_for(:group, @group, :url => {:controller => 'groups', :action => 'add_users', :id => @group}, :method => :post) do |f| %> + <% remote_form_for(@group, :url => group_users_path(@group), :html => {:method => :post}) do |f| %> <fieldset><legend><%=l(:label_user_new)%></legend> <p><%= label_tag "user_search", l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p> <%= observe_field(:user_search, :frequency => 0.5, :update => :users, - :url => { :controller => 'groups', :action => 'autocomplete_for_user', :id => @group }, + :url => autocomplete_for_user_group_path(@group), + :method => :get, :with => 'q') %> diff --git a/config/routes.rb b/config/routes.rb index 9d3a2175c..dd21ef27b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,7 +221,10 @@ ActionController::Routing::Routes.draw do |map| map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ - map.resources :groups + map.resources :groups, :member => {:autocomplete_for_user => :get} + map.group_users 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :conditions => {:method => :post} + map.group_user 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :conditions => {:method => :delete} + map.resources :trackers, :except => :show map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post} diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb index ab53f0d95..c28ebbdea 100644 --- a/test/functional/groups_controller_test.rb +++ b/test/functional/groups_controller_test.rb @@ -90,7 +90,7 @@ class GroupsControllerTest < ActionController::TestCase def test_remove_user assert_difference 'Group.find(10).users.count', -1 do - post :remove_user, :id => 10, :user_id => '8' + delete :remove_user, :id => 10, :user_id => '8' end end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 7fb277808..e163b02d5 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -55,6 +55,11 @@ class RoutingTest < ActionController::IntegrationTest should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567' should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567' end + + context "groups" do + should_route :post, "/groups/567/users", :controller => 'groups', :action => 'add_users', :id => '567' + should_route :delete, "/groups/567/users/12", :controller => 'groups', :action => 'remove_user', :id => '567', :user_id => '12' + end context "issues" do # REST actions |