Unify link to comment show specs

Note that, in all cases except in :legislation_annotation, the behavior for
click_link is now slightly different.

Previously, the click_link outsite of within block meant that we made sure there
was only one link with that text in the whole page. Now, in order to unify this
spec we change the behaviour.
This commit is contained in:
taitus
2023-12-14 10:56:00 +01:00
parent f2e4eec748
commit 0c58e7e3b4
8 changed files with 13 additions and 106 deletions

View File

@@ -6,21 +6,6 @@ describe "Commenting Budget::Investments" do
it_behaves_like "flaggable", :budget_investment_comment
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" do
parent_comment = create(:comment, body: "Main comment", commentable: investment)
child_comment = create(:comment,

View File

@@ -6,21 +6,6 @@ describe "Commenting debates" do
it_behaves_like "flaggable", :debate_comment
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" do
parent_comment = create(:comment, body: "Main comment", commentable: debate)
child_comment = create(:comment, body: "First subcomment", commentable: debate, parent: parent_comment)

View File

@@ -6,20 +6,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_annotation_comment
scenario "Link to comment show" do
comment = create(:comment, commentable: annotation, user: user)
visit polymorphic_path(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 #{annotation.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments" do
parent_comment = annotation.comments.first
child_comment = create(:comment,

View File

@@ -10,21 +10,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_question_comment
end
scenario "Link to comment show" do
comment = create(:comment, commentable: question, user: user)
visit legislation_process_question_path(question.process, 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 #{question.title}"
expect(page).to have_current_path(comment_path(comment))
end
scenario "Collapsable comments" do
parent_comment = create(:comment, body: "Main comment", commentable: question)
child_comment = create(:comment, body: "First subcomment", commentable: question, parent: parent_comment)

View File

@@ -4,21 +4,6 @@ describe "Commenting polls" do
let(:user) { create(:user) }
let(:poll) { create(:poll, author: create(:user)) }
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" do
parent_comment = create(:comment, body: "Main comment", commentable: poll)
child_comment = create(:comment, body: "First subcomment", commentable: poll, parent: parent_comment)

View File

@@ -6,21 +6,6 @@ describe "Commenting proposals" do
it_behaves_like "flaggable", :proposal_comment
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" do
parent_comment = create(:comment, body: "Main comment", commentable: proposal)
child_comment = create(:comment, body: "First subcomment", commentable: proposal, parent: parent_comment)

View File

@@ -6,23 +6,6 @@ describe "Commenting topics from proposals" do
it_behaves_like "flaggable", :topic_with_community_comment
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" do
community = proposal.community
topic = create(:topic, community: community)

View File

@@ -103,6 +103,19 @@ describe "Comments" do
end
end
scenario "Link to comment show" do
comment = create(:comment, commentable: resource, user: user)
visit polymorphic_path(resource)
within "#comment_#{comment.id}" do
click_link comment.created_at.strftime("%Y-%m-%d %T")
end
expect(page).to have_link "Go back to #{resource.title}"
expect(page).to have_current_path(comment_path(comment))
end
describe "Not logged user" do
scenario "can not see comments forms" do
create(:comment, commentable: resource)