diff options
Diffstat (limited to 'test/integration/api_test')
-rw-r--r-- | test/integration/api_test/users_test.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb index 81ac487ac..5b52f6d3b 100644 --- a/test/integration/api_test/users_test.rb +++ b/test/integration/api_test/users_test.rb @@ -82,6 +82,44 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base end end + test "GET /users.json with legacy filter params" do + get '/users.json', :headers => credentials('admin'), params: { status: 3 } + assert_response :success + json = ActiveSupport::JSON.decode(response.body) + assert json.key?('users') + users = User.where(status: 3) + assert_equal users.size, json['users'].size + + get '/users.json', :headers => credentials('admin'), params: { name: 'jsmith' } + assert_response :success + json = ActiveSupport::JSON.decode(response.body) + assert json.key?('users') + assert_equal 1, json['users'].size + assert_equal 2, json['users'][0]['id'] + + get '/users.json', :headers => credentials('admin'), params: { group_id: '10' } + assert_response :success + json = ActiveSupport::JSON.decode(response.body) + assert json.key?('users') + assert_equal 1, json['users'].size + assert_equal 8, json['users'][0]['id'] + + # there should be an implicit filter for status = 1 + User.where(id: [2, 8]).update_all status: 3 + + get '/users.json', :headers => credentials('admin'), params: { name: 'jsmith' } + assert_response :success + json = ActiveSupport::JSON.decode(response.body) + assert json.key?('users') + assert_equal 0, json['users'].size + + get '/users.json', :headers => credentials('admin'), params: { group_id: '10' } + assert_response :success + json = ActiveSupport::JSON.decode(response.body) + assert json.key?('users') + assert_equal 0, json['users'].size + end + test "GET /users/:id.xml should return the user" do Redmine::Configuration.with 'avatar_server_url' => 'https://gravatar.com' do with_settings :gravatar_enabled => '1', :gravatar_default => 'robohash' do |