Add link to comment path on comment date

This commit is contained in:
decabeza
2019-05-30 00:34:18 +02:00
parent 5fd493cd2c
commit 0154bc556d
8 changed files with 114 additions and 1 deletions

View File

@@ -61,7 +61,12 @@
<% end %> <% end %>
&nbsp;&bull;&nbsp;<span><%= l comment.created_at.to_datetime, format: :datetime %></span> &nbsp;&bull;&nbsp;
<span>
<%= link_to comment_path(comment) do %>
<%= l comment.created_at.to_datetime, format: :datetime %>
<% end %>
</span>
</div> </div>
<div class="comment-user <div class="comment-user

View File

@@ -44,6 +44,21 @@ describe "Commenting Budget::Investments" do
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
end end
scenario "Link to comment show" do
comment = create(:comment, commentable: investment, user: user)
visit budget_investment_path(investment.budget, investment)
within "#comment_#{comment.id}" do
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
end
click_link comment.created_at.strftime("%Y-%m-%d %T")
expect(page).to have_link "Go back to #{investment.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments", :js do scenario "Collapsable comments", :js do
parent_comment = create(:comment, body: "Main comment", commentable: investment) parent_comment = create(:comment, body: "Main comment", commentable: investment)
child_comment = create(:comment, body: "First subcomment", commentable: investment, parent: parent_comment) child_comment = create(:comment, body: "First subcomment", commentable: investment, parent: parent_comment)

View File

@@ -39,6 +39,21 @@ describe "Commenting debates" do
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
end end
scenario "Link to comment show" do
comment = create(:comment, commentable: debate, user: user)
visit debate_path(debate)
within "#comment_#{comment.id}" do
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
end
click_link comment.created_at.strftime("%Y-%m-%d %T")
expect(page).to have_link "Go back to #{debate.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments", :js do scenario "Collapsable comments", :js do
parent_comment = create(:comment, body: "Main comment", commentable: debate) parent_comment = create(:comment, body: "Main comment", commentable: debate)
child_comment = create(:comment, body: "First subcomment", commentable: debate, parent: parent_comment) child_comment = create(:comment, body: "First subcomment", commentable: debate, parent: parent_comment)

View File

@@ -44,6 +44,22 @@ describe "Commenting legislation questions" do
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
end end
scenario "Link to comment show" do
comment = create(:comment, commentable: legislation_annotation, user: user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
within "#comment_#{comment.id}" do
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
click_link comment.created_at.strftime("%Y-%m-%d %T")
end
expect(page).to have_link "Go back to #{legislation_annotation.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments", :js do scenario "Collapsable comments", :js do
parent_comment = legislation_annotation.comments.first parent_comment = legislation_annotation.comments.first
child_comment = create(:comment, body: "First subcomment", commentable: legislation_annotation, parent: parent_comment) child_comment = create(:comment, body: "First subcomment", commentable: legislation_annotation, parent: parent_comment)

View File

@@ -46,6 +46,21 @@ describe "Commenting legislation questions" do
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
end end
scenario "Link to comment show" do
comment = create(:comment, commentable: legislation_question, user: user)
visit legislation_process_question_path(legislation_question.process, legislation_question)
within "#comment_#{comment.id}" do
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
end
click_link comment.created_at.strftime("%Y-%m-%d %T")
expect(page).to have_link "Go back to #{legislation_question.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments", :js do scenario "Collapsable comments", :js do
parent_comment = create(:comment, body: "Main comment", commentable: legislation_question) parent_comment = create(:comment, body: "Main comment", commentable: legislation_question)
child_comment = create(:comment, body: "First subcomment", commentable: legislation_question, parent: parent_comment) child_comment = create(:comment, body: "First subcomment", commentable: legislation_question, parent: parent_comment)

View File

@@ -40,6 +40,21 @@ describe "Commenting polls" do
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
end end
scenario "Link to comment show" do
comment = create(:comment, commentable: poll, user: user)
visit poll_path(poll)
within "#comment_#{comment.id}" do
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
end
click_link comment.created_at.strftime("%Y-%m-%d %T")
expect(page).to have_link "Go back to #{poll.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments", :js do scenario "Collapsable comments", :js do
parent_comment = create(:comment, body: "Main comment", commentable: poll) parent_comment = create(:comment, body: "Main comment", commentable: poll)
child_comment = create(:comment, body: "First subcomment", commentable: poll, parent: parent_comment) child_comment = create(:comment, body: "First subcomment", commentable: poll, parent: parent_comment)

View File

@@ -38,6 +38,21 @@ describe "Commenting proposals" do
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1) expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
end end
scenario "Link to comment show" do
comment = create(:comment, commentable: proposal, user: user)
visit proposal_path(proposal)
within "#comment_#{comment.id}" do
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
end
click_link comment.created_at.strftime("%Y-%m-%d %T")
expect(page).to have_link "Go back to #{proposal.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments", :js do scenario "Collapsable comments", :js do
parent_comment = create(:comment, body: "Main comment", commentable: proposal) parent_comment = create(:comment, body: "Main comment", commentable: proposal)
child_comment = create(:comment, body: "First subcomment", commentable: proposal, parent: parent_comment) child_comment = create(:comment, body: "First subcomment", commentable: proposal, parent: parent_comment)

View File

@@ -39,6 +39,23 @@ describe "Commenting topics from proposals" do
expect(page).to have_link "Go back to #{topic.title}", href: community_topic_path(community, topic) expect(page).to have_link "Go back to #{topic.title}", href: community_topic_path(community, topic)
end end
scenario "Link to comment show" do
community = proposal.community
topic = create(:topic, community: community)
comment = create(:comment, commentable: topic, user: user)
visit community_topic_path(community, topic)
within "#comment_#{comment.id}" do
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
end
click_link comment.created_at.strftime("%Y-%m-%d %T")
expect(page).to have_link "Go back to #{topic.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments", :js do scenario "Collapsable comments", :js do
community = proposal.community community = proposal.community
topic = create(:topic, community: community) topic = create(:topic, community: community)