Unified UsersController#list and #index.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2991 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e64fb6a728
commit
92ec35e657
|
@ -24,11 +24,6 @@ class UsersController < ApplicationController
|
||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
|
|
||||||
def index
|
def index
|
||||||
list
|
|
||||||
render :action => 'list' unless request.xhr?
|
|
||||||
end
|
|
||||||
|
|
||||||
def list
|
|
||||||
sort_init 'login', 'asc'
|
sort_init 'login', 'asc'
|
||||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||||
|
|
||||||
|
@ -49,7 +44,7 @@ class UsersController < ApplicationController
|
||||||
:limit => @user_pages.items_per_page,
|
:limit => @user_pages.items_per_page,
|
||||||
:offset => @user_pages.current.offset
|
:offset => @user_pages.current.offset
|
||||||
|
|
||||||
render :action => "list", :layout => false if request.xhr?
|
render :layout => !request.xhr?
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -157,7 +157,6 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
|
|
||||||
map.with_options :controller => 'users' do |users|
|
map.with_options :controller => 'users' do |users|
|
||||||
users.with_options :conditions => {:method => :get} do |user_views|
|
users.with_options :conditions => {:method => :get} do |user_views|
|
||||||
user_views.connect 'users', :action => 'list'
|
|
||||||
user_views.connect 'users', :action => 'index'
|
user_views.connect 'users', :action => 'index'
|
||||||
user_views.connect 'users/:id', :action => 'show', :id => /\d+/
|
user_views.connect 'users/:id', :action => 'show', :id => /\d+/
|
||||||
user_views.connect 'users/new', :action => 'add'
|
user_views.connect 'users/new', :action => 'add'
|
||||||
|
|
|
@ -35,40 +35,39 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_routing
|
def test_index_routing
|
||||||
#TODO: unify with list
|
|
||||||
assert_generates(
|
assert_generates(
|
||||||
'/users',
|
'/users',
|
||||||
:controller => 'users', :action => 'index'
|
:controller => 'users', :action => 'index'
|
||||||
)
|
)
|
||||||
|
assert_routing(
|
||||||
|
{:method => :get, :path => '/users'},
|
||||||
|
:controller => 'users', :action => 'index'
|
||||||
|
)
|
||||||
|
assert_recognizes(
|
||||||
|
{:controller => 'users', :action => 'index'},
|
||||||
|
{:method => :get, :path => '/users'}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index
|
def test_index
|
||||||
get :index
|
get :index
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'list'
|
assert_template 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_list_routing
|
def test_index
|
||||||
#TODO: rename action to index
|
get :index
|
||||||
assert_routing(
|
|
||||||
{:method => :get, :path => '/users'},
|
|
||||||
:controller => 'users', :action => 'list'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_list
|
|
||||||
get :list
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'list'
|
assert_template 'index'
|
||||||
assert_not_nil assigns(:users)
|
assert_not_nil assigns(:users)
|
||||||
# active users only
|
# active users only
|
||||||
assert_nil assigns(:users).detect {|u| !u.active?}
|
assert_nil assigns(:users).detect {|u| !u.active?}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_list_with_name_filter
|
def test_index_with_name_filter
|
||||||
get :list, :name => 'john'
|
get :index, :name => 'john'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template 'list'
|
assert_template 'index'
|
||||||
users = assigns(:users)
|
users = assigns(:users)
|
||||||
assert_not_nil users
|
assert_not_nil users
|
||||||
assert_equal 1, users.size
|
assert_equal 1, users.size
|
||||||
|
|
Loading…
Reference in New Issue