--- /dev/null
+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
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
--- /dev/null
+<turbo-frame id="pagination" target="_top" data-turbo="false">
+ <table class="table table-striped" width="100%">
+ <thead>
+ <tr>
+ <th width="25%"><%= t ".changeset" %></th>
+ <th width="25%"><%= t ".when" %></th>
+ <th width="50%"><%= t ".comment" %></th>
+ </tr>
+ </thead>
+ <% @comments.each do |comment| -%>
+ <tr>
+ <td width="25%" class="<%= "text-muted" unless comment.visible? %>"><%= link_to comment.changeset.id, changeset_path(comment.changeset) %></td>
+ <td width="25%" class="<%= "text-muted" unless comment.visible? %>"><span title="<%= l comment.created_at, :format => :friendly %>"><%= time_ago_in_words(comment.created_at, :scope => :"datetime.distance_in_words_ago") %></span></td>
+ <td width="50%" class="richtext text-break<%= " text-muted" unless comment.visible? %>"><%= comment.body.to_html %></td>
+ </tr>
+ <% end -%>
+ </table>
+
+ <%= render "shared/pagination",
+ :newer_id => @newer_comments_id,
+ :older_id => @older_comments_id %>
+</turbo-frame>
<h1><%= t ".heading_html", :user => link_to(@user.display_name, @user) %></h1>
<ul class="nav nav-tabs">
<li class="nav-item">
- <a class="nav-link active"><%= t ".diary_entries" %></a>
+ <%= link_to t(".diary_entries"), user_diary_comments_path, :class => ["nav-link", { "active" => controller_name == "diary_comments" }] %>
+ </li>
+ <li class="nav-item">
+ <%= link_to t(".changesets"), user_changeset_comments_path, :class => ["nav-link", { "active" => controller_name == "changeset_comments" }] %>
</li>
</ul>
<% end %>
preview: Preview
help: Help
pagination:
+ changeset_comments:
+ older: Older Comments
+ newer: Newer Comments
diary_comments:
older: Older Comments
newer: Newer Comments
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}"
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
--- /dev/null
+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