diff --git a/app/views/users/edit.rhtml b/app/views/users/edit.rhtml index f5538c1670..0d9cb0133e 100644 --- a/app/views/users/edit.rhtml +++ b/app/views/users/edit.rhtml @@ -1,5 +1,5 @@
-<%= link_to l(:label_profile), {:controller => 'users', :action => 'show', :id => @user}, :class => 'icon icon-user' %> +<%= link_to l(:label_profile), user_path(@user), :class => 'icon icon-user' %> <%= change_status_link(@user) %>
diff --git a/app/views/users/index.rhtml b/app/views/users/index.rhtml index 804678959a..69ad737472 100644 --- a/app/views/users/index.rhtml +++ b/app/views/users/index.rhtml @@ -30,7 +30,7 @@ <% for user in @users -%> <%= %w(anon active registered locked)[user.status] %>"> - <%= avatar(user, :size => "14") %><%= link_to h(user.login), :action => 'edit', :id => user %> + <%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %> <%= h(user.firstname) %> <%= h(user.lastname) %> <%= mail_to(h(user.mail)) %> diff --git a/app/views/users/show.rhtml b/app/views/users/show.rhtml index a2f90226c3..afab71110a 100644 --- a/app/views/users/show.rhtml +++ b/app/views/users/show.rhtml @@ -1,5 +1,5 @@
-<%= link_to(l(:button_edit), {:controller => 'users', :action => 'edit', :id => @user}, :class => 'icon icon-edit') if User.current.admin? %> +<%= link_to(l(:button_edit), edit_user_path(@user), :class => 'icon icon-edit') if User.current.admin? %>

<%= avatar @user, :size => "50" %> <%=h @user.name %>

diff --git a/config/routes.rb b/config/routes.rb index a15f06a07d..7902fee32f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -138,23 +138,23 @@ ActionController::Routing::Routes.draw do |map| end map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' - + map.with_options :controller => 'users' do |users| - users.with_options :conditions => {:method => :get} do |user_views| - user_views.connect 'users', :action => 'index' - user_views.connect 'users/:id', :action => 'show', :id => /\d+/ - user_views.connect 'users/new', :action => 'new' - user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil - end + users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get} + users.with_options :conditions => {:method => :post} do |user_actions| - user_actions.connect 'users/new', :action => 'create' user_actions.connect 'users/:id/memberships', :action => 'edit_membership' user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' end - users.connect 'users/:id/edit', :action => 'update', :conditions => {:method => :put} end + map.resources :users, :member => { + :edit_membership => :post, + :destroy_membership => :post + }, + :except => [:destroy] + # For nice "roadmap" in the url for the index action map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' diff --git a/test/integration/admin_test.rb b/test/integration/admin_test.rb index 0b736199b3..1600f89bd8 100644 --- a/test/integration/admin_test.rb +++ b/test/integration/admin_test.rb @@ -35,7 +35,7 @@ class AdminTest < ActionController::IntegrationTest assert_kind_of User, logged_user assert_equal "Paul", logged_user.firstname - put "users/#{user.id}/edit", :id => user.id, :user => { :status => User::STATUS_LOCKED } + put "users/#{user.id}", :id => user.id, :user => { :status => User::STATUS_LOCKED } assert_redirected_to "/users/#{ user.id }/edit" locked_user = User.try_to_login("psmith", "psmith09") assert_equal nil, locked_user @@ -44,6 +44,6 @@ class AdminTest < ActionController::IntegrationTest test "Add a user as an anonymous user should fail" do post '/users/create', :user => { :login => 'psmith', :firstname => 'Paul'}, :password => "psmith09", :password_confirmation => "psmith09" assert_response :redirect - assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fusers%2Fnew" + assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fusers" end end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 030f6b18a4..b42468ffbd 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -250,12 +250,12 @@ class RoutingTest < ActionController::IntegrationTest should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444' should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership' - should_route :post, "/users/new", :controller => 'users', :action => 'create' + should_route :post, "/users", :controller => 'users', :action => 'create' should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123' should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55' should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12' - should_route :put, "/users/444/edit", :controller => 'users', :action => 'update', :id => '444' + should_route :put, "/users/444", :controller => 'users', :action => 'update', :id => '444' end # TODO: should they all be scoped under /projects/:project_id ?