Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/helpers/comments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ def title_for_comment_page(commentable)
else
title = link_to(commentable.commentable_name, commentable)
end
(ts('Reading Comments on ') + title).html_safe
t("comments_helper.page_heading.reading_comments_html", commentable_link: title)
end

def title_for_new_comment_page(commentable)
title = if commentable.commentable_name.blank?
""
elsif commentable.is_a?(Tag)
link_to_tag(commentable)
else
link_to(commentable.commentable_name, commentable)
end
t("comments_helper.page_heading.new_comment_html", commentable_link: title)
end

def link_to_comment_ultimate_parent(comment)
Expand Down
17 changes: 6 additions & 11 deletions app/views/comments/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= ts("New comment on %{name}", :name => @name) %></h2>
<h2 class="heading"><%= title_for_new_comment_page(@commentable) %></h2>
<%= error_messages_for :comment %>
<!--/descriptions-->

<!--main content-->
<%= render :partial => 'comments/comment_form', :locals => {
:comment => @comment,
:commentable => @commentable,
:button_name => ts("Comment")
}
%>
<%= render partial: "comments/comment_form", locals: {
comment: @comment,
commentable: @commentable,
button_name: t(".actions.comment")
} %>
<!--/content-->

<!--subnav-->
<p class="navigation actions" role="navigation"><!--TODO: INVESTIGATE this baffling link--><%= link_to ts("Back"), @commentable.is_a?(Tag) ? tag_path(@commentable) : polymorphic_path(@commentable) %></p>
<!--/subnav-->
3 changes: 3 additions & 0 deletions config/locales/helpers/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ en:
on_tag_html: Comment on the tag %{name}
on_unknown: Comment on unknown item
on_work_html: Comment on the work %{title}
page_heading:
new_comment_html: New Comment on %{commentable_link}
reading_comments_html: Reading Comments on %{commentable_link}
inbox_helper:
comment_link_with_chapter_number: Chapter %{position} of %{title}
qr_code_helper:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,9 @@ en:
page_heading: Editing comment
show: Show
update: Update
new:
actions:
comment: Comment
show:
comment_on_html: Comment on %{commentable_link}
single_comment:
Expand Down
11 changes: 9 additions & 2 deletions features/comments_and_kudos/add_comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ Feature: Comment on work
As a reader
I'd like to comment on a work

Scenario: Comment links from downloads and static pages
Scenario: Reading comments page for a work displays correctly
Given the work "Generic Work"
When I am logged in as "commenter"
And I visit the comments page for the work "Generic Work"
Then I should see "Reading Comments on"
And I should see a page link to the work "Generic Work" within ".comments-index h2.heading"

Scenario: New comment page for a work displays correctly
Given the work "Generic Work"
Comment on lines +7 to 15
Copy link
Copy Markdown
Contributor

@slavalamp slavalamp Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also just a nitpick since i'm already requesting other changes, but the empty lines after scenario descriptions aren't needed, so you can remove them in these two tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! fixed on d2d7dba

When I am logged in as "commenter"
And I visit the new comment page for the work "Generic Work"
Then I should see the comment form
Then I should see "New Comment on"
And I should see a page link to the work "Generic Work" within ".comments-new h2.heading"

Scenario: When logged in I can comment on a work

Expand Down
9 changes: 5 additions & 4 deletions features/step_definitions/comment_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@
step "I should see \"Last Edited #{nowish}\""
end

Then /^I should see the comment form$/ do
step %{I should see "New comment on"}
end

Then /^I should see the reply to comment form$/ do
step %{I should see "Comment as" within ".odd"}
end
Expand Down Expand Up @@ -199,6 +195,11 @@
end
end

When "I visit the comments page for the work {string}" do |work|
work = Work.find_by(title: work)
visit work_comments_path(work, only_path: false)
end

When /^I visit the new comment page for the work "([^"]+)"$/ do |work|
work = Work.find_by(title: work)
visit new_work_comment_path(work, only_path: false)
Expand Down
Loading