Project

General

Profile

Patch #31066 » 31066-group-memberships-by-project.patch

Go MAEDA, 2019-03-26 03:37

View differences:

app/views/users/show.html.erb
77 77

  
78 78
<% unless @memberships.empty? %>
79 79
<h3><%=l(:label_project_plural)%></h3>
80
<ul>
81
<% for membership in @memberships %>
82
  <li><%= link_to_project(membership.project) %>
83
    (<%= membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)</li>
80
<table class="list">
81
<thead>
82
  <tr>
83
    <th><%=l(:label_project)%></th>
84
    <th><%=l(:label_role_plural)%></th>
85
    <th><%=l(:label_registered_on)%></th>
86
  </tr>
87
</thead>
88
<tbody>
89
<% memberships_by_project = @memberships.group_by(&:project) %>
90
<% project_tree(memberships_by_project.keys, :init_level => true) do |project, level| %>
91
  <% membership = memberships_by_project[project].first %>
92
  <tr class="<%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
93
    <td class="name"><span><%= link_to_project(project) %></span></td>
94
    <td class="roles"><%= membership.roles.sort.collect(&:to_s).join(', ') %></td>
95
    <td><%= format_date(membership.created_on) %></td>
96
  </tr>
84 97
<% end %>
85
</ul>
98
</tbody>
99
</table>
86 100
<% end %>
87 101

  
88 102
<% if (User.current == @user || User.current.admin?) && @user.groups.any? %>
test/functional/users_controller_test.rb
173 173
    get :show, :params => {:id => 2}
174 174
    assert_response :success
175 175

  
176
    # membership of private project admin can see
177
    assert_select 'li a', :text => "OnlineStore"
176
    assert_select 'table.list.memberships>tbody' do
177
      assert_select 'tr:nth-of-type(1)' do
178
        assert_select 'td:nth-of-type(1)>span>a', :text => 'eCookbook'
179
        assert_select 'td:nth-of-type(2)', :text => 'Manager'
180
      end
181
      assert_select 'tr:nth-of-type(2)' do
182
        assert_select 'td:nth-of-type(1)>span>a', :text => 'Private child of eCookbook'
183
        assert_select 'td:nth-of-type(2)', :text => 'Manager'
184
      end
185
      assert_select 'tr:nth-of-type(3)' do
186
        assert_select 'td:nth-of-type(1)>span>a', :text => 'OnlineStore'
187
        assert_select 'td:nth-of-type(2)', :text => 'Developer'
188
      end
189
    end
178 190
  end
179 191

  
180 192
  def test_show_current_should_require_authentication
(8-8/8)