diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 81e7946401..8348339c4d 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -89,6 +89,10 @@ class UsersController < ApplicationController
: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
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index fabf91dae8..d349fcc652 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -72,6 +72,26 @@
issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id, :sort => sort_cond) %>
+ <% if User.current == @user %>
+
+
+ <%= link_to l(:label_watched_issues),
+ issues_path(:set_filter => 1, :watcher_id => @user.id, :sort => sort_cond) %>
+ |
+
+ <%= link_to @issue_counts[:watched][:open],
+ issues_path(:set_filter => 1, :watcher_id => @user.id, :sort => sort_cond) %>
+ |
+
+ <%= 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) %>
+ |
+
+ <%= link_to @issue_counts[:watched][:total],
+ issues_path(:set_filter => 1, :status_id => '*', :watcher_id => @user.id, :sort => sort_cond) %>
+ |
+
+<% end %>
diff --git a/test/fixtures/watchers.yml b/test/fixtures/watchers.yml
index 038318cccb..5fcbcc20d2 100644
--- a/test/fixtures/watchers.yml
+++ b/test/fixtures/watchers.yml
@@ -15,3 +15,7 @@ watchers_004:
watchable_type: WikiPage
watchable_id: 1
user_id: 1
+watchers_005:
+ watchable_type: Issue
+ watchable_id: 3
+ user_id: 2
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index c963bf248e..5382272a23 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -27,7 +27,7 @@ class UsersControllerTest < Redmine::ControllerTest
:auth_sources,
:enabled_modules,
:issues, :issue_statuses,
- :trackers
+ :trackers, :watchers
def setup
User.current = nil
@@ -247,6 +247,26 @@ class UsersControllerTest < Redmine::ControllerTest
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