Project

General

Profile

Feature #36303 » 36303-v2.patch

Go MAEDA, 2021-12-30 10:19

View differences:

app/views/users/index.api.rsb
11 11
      api.updated_on user.updated_on
12 12
      api.last_login_on     user.last_login_on
13 13
      api.passwd_changed_on user.passwd_changed_on
14
      api.avatar_url gravatar_url(user.mail, {rating: nil, size: nil}) if Setting.gravatar_enabled?
14 15
      api.twofa_scheme user.twofa_scheme
15 16

  
16 17
      render_api_custom_values user.visible_custom_field_values, api
app/views/users/show.api.rsb
9 9
  api.updated_on @user.updated_on
10 10
  api.last_login_on     @user.last_login_on
11 11
  api.passwd_changed_on @user.passwd_changed_on
12
  api.avatar_url gravatar_url(@user.mail, {rating: nil, size: nil}) if Setting.gravatar_enabled?
12 13
  api.twofa_scheme      @user.twofa_scheme if User.current.admin? || (User.current == @user)
13 14
  api.api_key    @user.api_key if User.current.admin? || (User.current == @user)
14 15
  api.status     @user.status if User.current.admin?
test/integration/api_test/users_test.rb
25 25
  test "GET /users.xml should return users" do
26 26
    users = User.active.order('login')
27 27
    users.last.update(twofa_scheme: 'totp')
28
    get '/users.xml', :headers => credentials('admin')
28
    Redmine::Configuration.with 'avatar_server_url' => 'https://gravatar.com' do
29
      with_settings :gravatar_enabled => '1' do
30
        get '/users.xml', :headers => credentials('admin')
31
      end
32
    end
29 33

  
30 34
    assert_response :success
31 35
    assert_equal 'application/xml', response.media_type
......
38 42

  
39 43
          # No one has changed password.
40 44
          assert_select user_element, 'passwd_changed_on', :text => ''
45
          assert_select user_element, 'avatar_url', :text => %r|\Ahttps://gravatar.com/avatar/\h{32}|
41 46

  
42 47
          if user == users.last
43 48
            assert_select user_element, 'twofa_scheme', :text => 'totp'
......
78 83
  end
79 84

  
80 85
  test "GET /users/:id.xml should return the user" do
81
    get '/users/2.xml'
86
    Redmine::Configuration.with 'avatar_server_url' => 'https://gravatar.com' do
87
      with_settings :gravatar_enabled => '1' do
88
        get '/users/2.xml'
89
      end
90
    end
82 91

  
83 92
    assert_response :success
84 93
    assert_select 'user id', :text => '2'
85 94
    assert_select 'user updated_on', :text => Time.zone.parse('2006-07-19T20:42:15Z').iso8601
86 95
    assert_select 'user passwd_changed_on', :text => ''
96
    assert_select 'user avatar_url', :text => %r|\Ahttps://gravatar.com/avatar/\h{32}|
87 97
  end
88 98

  
89 99
  test "GET /users/:id.json should return the user" do
(2-2/3)