Unify errors on reply comments specs

Note that the click_link "Reply" is now inside a "within".

This is due to the case of "legislation_annotation" before in the original test
no comment was created as it simply took the one created by default when creating
a "legislation_annotation".

```
comment = annotation.comments.first
```

Now to try to unify this test, we always create a comment, and in this case as we
also created the "legislation_annotation" we have 2 comments, so it is necessary
to add the "click_link" inside the "within".
This commit is contained in:
taitus
2023-12-19 18:45:10 +01:00
parent f4c3e740e6
commit f0fa004f85
8 changed files with 16 additions and 119 deletions

View File

@@ -1,25 +1,10 @@
require "rails_helper"
describe "Commenting Budget::Investments" do
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }
it_behaves_like "flaggable", :budget_investment_comment
scenario "Errors on reply" do
comment = create(:comment, commentable: investment, user: user)
login_as(user)
visit budget_investment_path(investment.budget, investment)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
parent = create(:comment, commentable: investment)

View File

@@ -112,20 +112,6 @@ describe "Commenting debates" do
end
end
scenario "Errors on reply" do
comment = create(:comment, commentable: debate, user: user)
login_as(user)
visit debate_path(debate)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
parent = create(:comment, commentable: debate)

View File

@@ -6,20 +6,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_annotation_comment
scenario "Errors on reply" do
comment = annotation.comments.first
login_as(user)
visit polymorphic_path(annotation)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
parent = create(:comment, commentable: annotation)

View File

@@ -10,20 +10,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_question_comment
end
scenario "Errors on reply" do
comment = create(:comment, commentable: question, user: user)
login_as(user)
visit legislation_process_question_path(question.process, question)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
parent = create(:comment, commentable: question)

View File

@@ -4,20 +4,6 @@ describe "Commenting polls" do
let(:user) { create(:user) }
let(:poll) { create(:poll, author: create(:user)) }
scenario "Errors on reply" do
comment = create(:comment, commentable: poll, user: user)
login_as(user)
visit poll_path(poll)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
parent = create(:comment, commentable: poll)

View File

@@ -1,25 +1,10 @@
require "rails_helper"
describe "Commenting proposals" do
let(:user) { create(:user) }
let(:proposal) { create(:proposal) }
it_behaves_like "flaggable", :proposal_comment
scenario "Errors on reply" do
comment = create(:comment, commentable: proposal, user: user)
login_as(user)
visit proposal_path(proposal)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
parent = create(:comment, commentable: proposal)

View File

@@ -1,27 +1,10 @@
require "rails_helper"
describe "Commenting topics from proposals" do
let(:user) { create(:user) }
let(:proposal) { create(:proposal) }
it_behaves_like "flaggable", :topic_with_community_comment
scenario "Errors on reply" do
community = proposal.community
topic = create(:topic, community: community)
comment = create(:comment, commentable: topic, user: user)
login_as(user)
visit community_topic_path(community, topic)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
community = proposal.community
topic = create(:topic, community: community)
@@ -274,22 +257,6 @@ describe "Commenting topics from budget investments" do
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }
scenario "Errors on reply" do
community = investment.community
topic = create(:topic, community: community)
comment = create(:comment, commentable: topic, user: user)
login_as(user)
visit community_topic_path(community, topic)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "N replies" do
community = investment.community
topic = create(:topic, community: community)

View File

@@ -361,6 +361,22 @@ describe "Comments" do
end
end
scenario "Errors on reply" do
comment = create(:comment, commentable: resource, user: user)
login_as(user)
visit polymorphic_path(resource)
within "#comment_#{comment.id}" do
click_link "Reply"
end
within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end
scenario "Errors on create" do
login_as(user)
visit polymorphic_path(resource)