mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 09:46:02 +01:00
Export users list to CSV (#5957).
Contriubted by Mizuki ISHIKAWA and Yuki Kita. git-svn-id: http://svn.redmine.org/redmine/trunk@17463 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -64,6 +64,47 @@ class UsersControllerTest < Redmine::ControllerTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_csv
|
||||
with_settings :default_language => 'en' do
|
||||
get :index, :params => { :format => 'csv' }
|
||||
assert_response :success
|
||||
|
||||
assert_equal User.logged.status(1).count, response.body.chomp.split("\n").size - 1
|
||||
assert_include 'active', response.body
|
||||
assert_not_include 'locked', response.body
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_csv_with_status_filter
|
||||
with_settings :default_language => 'en' do
|
||||
get :index, :params => { :status => 3, :format => 'csv' }
|
||||
assert_response :success
|
||||
|
||||
assert_equal User.logged.status(3).count, response.body.chomp.split("\n").size - 1
|
||||
assert_include 'locked', response.body
|
||||
assert_not_include 'active', response.body
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_csv_with_name_filter
|
||||
get :index, :params => {:name => 'John', :format => 'csv'}
|
||||
assert_response :success
|
||||
|
||||
assert_equal User.logged.like('John').count, response.body.chomp.split("\n").size - 1
|
||||
assert_include 'John', response.body
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
end
|
||||
|
||||
def test_index_csv_with_group_filter
|
||||
get :index, :params => {:group_id => '10', :format => 'csv'}
|
||||
assert_response :success
|
||||
|
||||
assert_equal Group.find(10).users.count, response.body.chomp.split("\n").size - 1
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
end
|
||||
|
||||
def test_show
|
||||
@request.session[:user_id] = nil
|
||||
get :show, :params => {:id => 2}
|
||||
|
||||
Reference in New Issue
Block a user