fixes routes for users

pull/1186/head
Jens Ulferts 12 years ago
parent 7e8691177b
commit 14afaab6c2
  1. 23
      config/routes.rb
  2. 92
      test/integration/routing_test.rb

@ -262,23 +262,18 @@ OpenProject::Application.routes.draw do
match '/projects/:id/members/new' => 'members#new'
resources :users, :member => {
:edit_membership => :post,
:destroy_membership => :post,
:deletion_info => :get
}
scope :controller => 'users' do
match '/users/:id/edit/:tab', :action => 'edit', :tab => nil, :via => :get
scope :via => :post do
match '/users/:id/memberships', :action => 'edit_membership'
match '/users/:id/memberships/:membership_id', :action => 'edit_membership'
match '/users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
resources :users do
member do
match '/edit/:tab' => 'users#edit', :via => :get
match '/memberships/:membership_id/destroy' => 'users#destroy_membership', :via => :post
match '/memberships/:membership_id' => 'users#edit_membership', :via => :post
match '/memberships' => 'users#edit_membership', :via => :post
post :edit_membership
post :destroy_membership
get :deletion_info
end
end
match '/news' => 'news#index', :as => 'all_news'
match '/news.:format' => 'news#index', :as => 'formatted_all_news'
match '/news/preview' => 'previews#news', :as => 'preview_news'

@ -578,28 +578,76 @@ class RoutingTest < ActionController::IntegrationTest
:project_id => '567',
:format => 'csv' )
end
#
# context "users" do
# should route(:get, "/users").to( :controller => 'users', :action => 'index')
# should route(:get, "/users.xml").to( :controller => 'users', :action => 'index', :format => 'xml')
# should route(:get, "/users/44").to( :controller => 'users', :action => 'show', :id => '44')
# should route(:get, "/users/44.xml").to( :controller => 'users', :action => 'show', :id => '44', :format => 'xml')
# should route(:get, "/users/current").to( :controller => 'users', :action => 'show', :id => 'current')
# should route(:get, "/users/current.xml").to( :controller => 'users', :action => 'show', :id => 'current', :format => 'xml')
# should route(:get, "/users/new").to( :controller => 'users', :action => 'new')
# should route(:get, "/users/444/edit").to( :controller => 'users', :action => 'edit', :id => '444')
# should route(:get, "/users/222/edit/membership").to( :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership')
#
# should route(:post, "/users").to( :controller => 'users', :action => 'create')
# should route(:post, "/users.xml").to( :controller => 'users', :action => 'create', :format => 'xml')
# should route(:post, "/users/123/memberships").to( :controller => 'users', :action => 'edit_membership', :id => '123')
# should route(:post, "/users/123/memberships/55").to( :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55')
# should route(:post, "/users/567/memberships/12/destroy").to( :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12')
#
# should route(:put, "/users/444").to( :controller => 'users', :action => 'update', :id => '444')
# should route(:put, "/users/444.xml").to( :controller => 'users', :action => 'update', :id => '444', :format => 'xml')
# end
#
context "users" do
should route(:get, "/users").to( :controller => 'users',
:action => 'index' )
should route(:get, "/users.xml").to( :controller => 'users',
:action => 'index',
:format => 'xml' )
should route(:get, "/users/44").to( :controller => 'users',
:action => 'show',
:id => '44' )
should route(:get, "/users/44.xml").to( :controller => 'users',
:action => 'show',
:id => '44',
:format => 'xml' )
should route(:get, "/users/current").to( :controller => 'users',
:action => 'show',
:id => 'current' )
should route(:get, "/users/current.xml").to( :controller => 'users',
:action => 'show',
:id => 'current',
:format => 'xml' )
should route(:get, "/users/new").to( :controller => 'users',
:action => 'new' )
should route(:get, "/users/444/edit").to( :controller => 'users',
:action => 'edit',
:id => '444' )
should route(:get, "/users/222/edit/membership").to( :controller => 'users',
:action => 'edit',
:id => '222',
:tab => 'membership' )
should route(:post, "/users").to( :controller => 'users',
:action => 'create' )
should route(:post, "/users.xml").to( :controller => 'users',
:action => 'create',
:format => 'xml' )
should route(:post, "/users/123/memberships").to( :controller => 'users',
:action => 'edit_membership',
:id => '123' )
should route(:post, "/users/123/memberships/55").to( :controller => 'users',
:action => 'edit_membership',
:id => '123',
:membership_id => '55' )
should route(:post, "/users/567/memberships/12/destroy").to( :controller => 'users',
:action => 'destroy_membership',
:id => '567',
:membership_id => '12' )
should route(:put, "/users/444").to( :controller => 'users',
:action => 'update',
:id => '444' )
should route(:put, "/users/444.xml").to( :controller => 'users',
:action => 'update',
:id => '444',
:format => 'xml' )
end
context "versions" do
should route(:get, "/versions/1").to( :controller => 'versions',
:action => 'show',

Loading…
Cancel
Save