diff --git a/app/controllers/users/changeset_comments_controller.rb b/app/controllers/users/changeset_comments_controller.rb
new file mode 100644
index 000000000..2b8b367fe
--- /dev/null
+++ b/app/controllers/users/changeset_comments_controller.rb
@@ -0,0 +1,14 @@
+module Users
+ class ChangesetCommentsController < CommentsController
+ def index
+ @title = t ".title", :user => @user.display_name
+
+ comments = ChangesetComment.where(:author => @user)
+ comments = comments.visible unless current_user&.moderator?
+
+ @params = params.permit(:display_name, :before, :after)
+
+ @comments, @newer_comments_id, @older_comments_id = get_page_items(comments, :includes => [:author])
+ end
+ end
+end
diff --git a/app/models/changeset_comment.rb b/app/models/changeset_comment.rb
index 3bc9483fa..22d158e82 100644
--- a/app/models/changeset_comment.rb
+++ b/app/models/changeset_comment.rb
@@ -25,6 +25,8 @@ class ChangesetComment < ApplicationRecord
belongs_to :changeset
belongs_to :author, :class_name => "User"
+ scope :visible, -> { where(:visible => true) }
+
validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true }
validates :changeset, :associated => true
diff --git a/app/views/users/changeset_comments/_page.html.erb b/app/views/users/changeset_comments/_page.html.erb
new file mode 100644
index 000000000..d06159081
--- /dev/null
+++ b/app/views/users/changeset_comments/_page.html.erb
@@ -0,0 +1,22 @@
+
diff --git a/app/views/users/comments/index.html.erb b/app/views/users/comments/index.html.erb
index 9bd23df31..db8ff1553 100644
--- a/app/views/users/comments/index.html.erb
+++ b/app/views/users/comments/index.html.erb
@@ -4,7 +4,10 @@
<%= t ".heading_html", :user => link_to(@user.display_name, @user) %>
-
- <%= t ".diary_entries" %>
+ <%= link_to t(".diary_entries"), user_diary_comments_path, :class => ["nav-link", { "active" => controller_name == "diary_comments" }] %>
+
+ -
+ <%= link_to t(".changesets"), user_changeset_comments_path, :class => ["nav-link", { "active" => controller_name == "changeset_comments" }] %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 247416b7d..80558e672 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1939,6 +1939,9 @@ en:
preview: Preview
help: Help
pagination:
+ changeset_comments:
+ older: Older Comments
+ newer: Newer Comments
diary_comments:
older: Older Comments
newer: Newer Comments
@@ -2875,8 +2878,16 @@ en:
comments:
index:
heading_html: "%{user}'s Comments"
+ changesets: "Changesets"
diary_entries: "Diary entries"
no_comments: "No comments"
+ changeset_comments:
+ index:
+ title: "Changeset Comments added by %{user}"
+ page:
+ changeset: Changeset
+ when: When
+ comment: Comment
diary_comments:
index:
title: "Diary Comments added by %{user}"
diff --git a/config/routes.rb b/config/routes.rb
index 5b0da5d89..eb107ab26 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -268,6 +268,7 @@ OpenStreetMap::Application.routes.draw do
resource :role, :controller => "user_roles", :path => "roles/:role", :only => [:create, :destroy]
scope :module => :users do
resources :diary_comments, :only => :index
+ resources :changeset_comments, :only => :index
resource :issued_blocks, :path => "blocks_by", :only => :show
resource :received_blocks, :path => "blocks", :only => [:show, :edit, :destroy]
resource :status, :only => :update
diff --git a/test/controllers/users/changeset_comments_controller_test.rb b/test/controllers/users/changeset_comments_controller_test.rb
new file mode 100644
index 000000000..db2646bfc
--- /dev/null
+++ b/test/controllers/users/changeset_comments_controller_test.rb
@@ -0,0 +1,37 @@
+require "test_helper"
+
+module Users
+ class ChangesetCommentsControllerTest < ActionDispatch::IntegrationTest
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/user/username/changeset_comments", :method => :get },
+ { :controller => "users/changeset_comments", :action => "index", :user_display_name => "username" }
+ )
+ end
+
+ def test_index
+ user = create(:user)
+ other_user = create(:user)
+ changeset = create(:changeset, :closed)
+ create_list(:changeset_comment, 3, :changeset => changeset, :author => user)
+ create_list(:changeset_comment, 2, :changeset => changeset, :author => other_user)
+
+ get user_changeset_comments_path(user)
+ assert_response :success
+ assert_select "table.table-striped tbody" do
+ assert_select "tr", :count => 3
+ end
+
+ create(:changeset_comment, :changeset => changeset, :author => user)
+ create(:changeset_comment, :changeset => changeset, :author => user, :visible => false)
+
+ get user_changeset_comments_path(user)
+ assert_response :success
+ assert_select "table.table-striped tbody" do
+ assert_select "tr", :count => 4
+ end
+ end
+ end
+end