Project

General

Profile

Feature #2714 » 2714.patch

Takenori TAKAKI, 2021-06-25 10:00

View differences:

app/controllers/users_controller.rb
:total => Issue.visible.where(:author_id => @user.id).count,
:open => Issue.visible.open.where(:author_id => @user.id).count
}
@issue_counts[:watched] = {
:total => Issue.visible.watched_by(@user.id).count,
:open => Issue.visible.open.watched_by(@user.id).count
}
respond_to do |format|
format.html do
app/views/users/show.html.erb
issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id, :sort => sort_cond) %>
</td>
</tr>
<% if User.current == @user %>
<tr>
<td class="name">
<%= link_to l(:label_watched_issues),
issues_path(:set_filter => 1, :watcher_id => @user.id, :sort => sort_cond) %>
</td>
<td>
<%= link_to @issue_counts[:watched][:open],
issues_path(:set_filter => 1, :watcher_id => @user.id, :sort => sort_cond) %>
</td>
<td>
<%= link_to @issue_counts[:watched][:total] - @issue_counts[:watched][:open],
issues_path(:set_filter => 1, :status_id => 'c', :watcher_id => @user.id, :sort => sort_cond) %>
</td>
<td class="total">
<%= link_to @issue_counts[:watched][:total],
issues_path(:set_filter => 1, :status_id => '*', :watcher_id => @user.id, :sort => sort_cond) %>
</td>
</tr>
<% end %>
</tbody>
</table>
test/fixtures/watchers.yml
watchable_type: WikiPage
watchable_id: 1
user_id: 1
watchers_005:
watchable_type: Issue
watchable_id: 3
user_id: 2
test/functional/users_controller_test.rb
:auth_sources,
:enabled_modules,
:issues, :issue_statuses,
:trackers
:trackers, :watchers
def setup
User.current = nil
......
assert_select 'td:nth-of-type(3)>a', :text => '2' # closed
assert_select 'td:nth-of-type(4)>a', :text => '13' # total
end
assert_select 'tr:nth-of-type(3)' do
assert_select 'td:nth-of-type(1)>a', :text => 'Watched issues'
assert_select 'td:nth-of-type(2)>a', :text => '1' # open
assert_select 'td:nth-of-type(3)>a', :text => '0' # closed
assert_select 'td:nth-of-type(4)>a', :text => '1' # total
end
end
end
def test_show_issues_count_except_watcher
@request.session[:user_id] = 2
get :show, :params => {:id => 3}
assert_select 'table.list.issue-report>tbody' do
assert_select 'tr:nth-of-type(1)' do
assert_select 'td:nth-of-type(1)>a', :text => 'Assigned issues'
end
assert_select 'tr:nth-of-type(2)' do
assert_select 'td:nth-of-type(1)>a', :text => 'Reported issues'
end
assert_select 'tr:nth-of-type(3)', :count => 0
end
end
(2-2/2)