Project

General

Profile

Defect #33601 » 33601.patch

Go MAEDA, 2020-06-22 16:15

View differences:

app/helpers/users_helper.rb
60 60
    end
61 61
  end
62 62

  
63
  def user_emails(user)
64
    emails = [user.mail]
65
    emails += user.email_addresses.order(:id).where(:is_default => false).pluck(:address)
66
    emails.map {|email| mail_to(email, nil)}.join(', ').html_safe
67
  end
68

  
63 69
  def user_settings_tabs
64 70
    tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
65 71
            {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
app/views/users/show.html.erb
9 9
<ul>
10 10
  <li><%=l(:field_login)%>: <%= @user.login %></li>
11 11
  <% unless @user.pref.hide_mail %>
12
    <li><%=l(:field_mail)%>: <%= mail_to(@user.mail, nil, :encode => 'javascript') %></li>
12
    <li><%=l(:field_mail)%>: <%= user_emails(@user) %></li>
13 13
  <% end %>
14 14
  <% @user.visible_custom_field_values.each do |custom_value| %>
15 15
  <% if !custom_value.value.blank? %>
test/functional/users_controller_test.rb
255 255
    end
256 256
  end
257 257

  
258
  def test_show_should_list_all_emails
259
    EmailAddress.create!(user_id: 3, address: 'dlopper@example.net')
260
    EmailAddress.create!(user_id: 3, address: 'dlopper@example.org')
261

  
262
    @request.session[:user_id] = 1
263
    get :show, params: {id: 3}
264

  
265
    assert_select 'li', text: /Email:/ do
266
      assert_select 'a:nth-of-type(1)', text: 'dlopper@somenet.foo'
267
      assert_select 'a:nth-of-type(2)', text: 'dlopper@example.net'
268
      assert_select 'a:nth-of-type(3)', text: 'dlopper@example.org'
269
    end
270
  end
271

  
258 272
  def test_new
259 273
    get :new
260 274
    assert_response :success
(2-2/2)