37157.patch

Yuichi HARADA, 2022-05-26 06:48

Download (1.91 KB)

View differences:

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, default: Setting.gravatar_default}) if Setting.gravatar_enabled?
12
  api.avatar_url gravatar_url(@user.mail, {rating: nil, size: nil, default: Setting.gravatar_default}) if @user.mail && Setting.gravatar_enabled?
13 13
  api.twofa_scheme      @user.twofa_scheme if User.current.admin? || (User.current == @user)
14 14
  api.api_key    @user.api_key if User.current.admin? || (User.current == @user)
15 15
  api.status     @user.status if User.current.admin?
test/integration/api_test/users_test.rb
96 96
    assert_select 'user avatar_url', :text => %r|\Ahttps://gravatar.com/avatar/\h{32}\?default=robohash|
97 97
  end
98 98

  
99
  test "GET /users/:id.xml should not return avatar_url when not set email address" do
100
    user = User.find(2)
101
    user.email_addresses.delete_all
102
    assert_equal 'jsmith', user.login
103
    assert_nil user.mail
104

  
105
    Redmine::Configuration.with 'avatar_server_url' => 'https://gravatar.com' do
106
      with_settings :gravatar_enabled => '1', :gravatar_default => 'robohash' do
107
        get '/users/2.xml'
108
      end
109
    end
110

  
111
    assert_response :success
112
    assert_select 'user id', :text => '2'
113
    assert_select 'user login', :text => 'jsmith'
114
    assert_select 'user avatar_url', :count => 0
115
  end
116

  
99 117
  test "GET /users/:id.json should return the user" do
100 118
    get '/users/2.json'
101 119