Unify 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". ``` annotation = create(:legislation_annotation, author: citizen) 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:
@@ -6,28 +6,6 @@ describe "Commenting Budget::Investments" do
|
|||||||
|
|
||||||
it_behaves_like "flaggable", :budget_investment_comment
|
it_behaves_like "flaggable", :budget_investment_comment
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, username: "Manuela")
|
|
||||||
comment = create(:comment, commentable: investment, user: citizen)
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit budget_investment_path(investment.budget, investment)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your comment", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
comment = create(:comment, commentable: investment)
|
comment = create(:comment, commentable: investment)
|
||||||
|
|
||||||
|
|||||||
@@ -77,28 +77,6 @@ describe "Commenting debates" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, username: "Manuela")
|
|
||||||
comment = create(:comment, commentable: debate, user: citizen)
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit debate_path(debate)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your comment", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Reply to reply" do
|
scenario "Reply to reply" do
|
||||||
create(:comment, commentable: debate, body: "Any estimates?")
|
create(:comment, commentable: debate, body: "Any estimates?")
|
||||||
|
|
||||||
|
|||||||
@@ -6,29 +6,6 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
it_behaves_like "flaggable", :legislation_annotation_comment
|
it_behaves_like "flaggable", :legislation_annotation_comment
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, username: "Manuela")
|
|
||||||
annotation = create(:legislation_annotation, author: citizen)
|
|
||||||
comment = annotation.comments.first
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit polymorphic_path(annotation)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your comment", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
manuela = create(:user, :level_two, username: "Manuela")
|
||||||
annotation = create(:legislation_annotation)
|
annotation = create(:legislation_annotation)
|
||||||
|
|||||||
@@ -10,28 +10,6 @@ describe "Commenting legislation questions" do
|
|||||||
it_behaves_like "flaggable", :legislation_question_comment
|
it_behaves_like "flaggable", :legislation_question_comment
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
|
||||||
comment = create(:comment, commentable: question, user: citizen)
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit legislation_process_question_path(question.process, question)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your answer", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
manuela = create(:user, :level_two, username: "Manuela")
|
||||||
comment = create(:comment, commentable: question)
|
comment = create(:comment, commentable: question)
|
||||||
|
|||||||
@@ -4,28 +4,6 @@ describe "Commenting polls" do
|
|||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:poll) { create(:poll, author: create(:user)) }
|
let(:poll) { create(:poll, author: create(:user)) }
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, username: "Manuela")
|
|
||||||
comment = create(:comment, commentable: poll, user: citizen)
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit poll_path(poll)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your comment", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
comment = create(:comment, commentable: poll)
|
comment = create(:comment, commentable: poll)
|
||||||
|
|
||||||
|
|||||||
@@ -6,28 +6,6 @@ describe "Commenting proposals" do
|
|||||||
|
|
||||||
it_behaves_like "flaggable", :proposal_comment
|
it_behaves_like "flaggable", :proposal_comment
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, username: "Manuela")
|
|
||||||
comment = create(:comment, commentable: proposal, user: citizen)
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit proposal_path(proposal)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your comment", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
comment = create(:comment, commentable: proposal)
|
comment = create(:comment, commentable: proposal)
|
||||||
|
|
||||||
|
|||||||
@@ -6,30 +6,6 @@ describe "Commenting topics from proposals" do
|
|||||||
|
|
||||||
it_behaves_like "flaggable", :topic_with_community_comment
|
it_behaves_like "flaggable", :topic_with_community_comment
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
community = proposal.community
|
|
||||||
topic = create(:topic, community: community)
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, username: "Manuela")
|
|
||||||
comment = create(:comment, commentable: topic, user: citizen)
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit community_topic_path(community, topic)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your comment", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
community = proposal.community
|
community = proposal.community
|
||||||
topic = create(:topic, community: community)
|
topic = create(:topic, community: community)
|
||||||
@@ -334,30 +310,6 @@ describe "Commenting topics from budget investments" do
|
|||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:investment) { create(:budget_investment) }
|
let(:investment) { create(:budget_investment) }
|
||||||
|
|
||||||
scenario "Reply" do
|
|
||||||
community = investment.community
|
|
||||||
topic = create(:topic, community: community)
|
|
||||||
citizen = create(:user, username: "Ana")
|
|
||||||
manuela = create(:user, username: "Manuela")
|
|
||||||
comment = create(:comment, commentable: topic, user: citizen)
|
|
||||||
|
|
||||||
login_as(manuela)
|
|
||||||
visit community_topic_path(community, topic)
|
|
||||||
|
|
||||||
click_link "Reply"
|
|
||||||
|
|
||||||
within "#js-comment-form-comment_#{comment.id}" do
|
|
||||||
fill_in "Leave your comment", with: "It will be done next week."
|
|
||||||
click_button "Publish reply"
|
|
||||||
end
|
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
|
||||||
expect(page).to have_content "It will be done next week."
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Errors on reply" do
|
scenario "Errors on reply" do
|
||||||
community = investment.community
|
community = investment.community
|
||||||
topic = create(:topic, community: community)
|
topic = create(:topic, community: community)
|
||||||
|
|||||||
@@ -306,6 +306,28 @@ describe "Comments" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Reply" do
|
||||||
|
comment = create(:comment, commentable: resource)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit polymorphic_path(resource)
|
||||||
|
|
||||||
|
within "#comment_#{comment.id}" do
|
||||||
|
click_link "Reply"
|
||||||
|
end
|
||||||
|
|
||||||
|
within "#js-comment-form-comment_#{comment.id}" do
|
||||||
|
fill_in fill_text, with: "It will be done next week."
|
||||||
|
click_button "Publish reply"
|
||||||
|
end
|
||||||
|
|
||||||
|
within "#comment_#{comment.id}" do
|
||||||
|
expect(page).to have_content "It will be done next week."
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Errors on create" do
|
scenario "Errors on create" do
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit polymorphic_path(resource)
|
visit polymorphic_path(resource)
|
||||||
|
|||||||
Reference in New Issue
Block a user