Unify hide comments specs

This commit is contained in:
taitus
2023-12-20 00:28:14 +01:00
parent 8ba16c2330
commit 8da4c60c2a
2 changed files with 53 additions and 52 deletions

View File

@@ -6,58 +6,6 @@ describe "Commenting debates" do
it_behaves_like "flaggable", :debate_comment it_behaves_like "flaggable", :debate_comment
describe "Hide" do
scenario "Without replies" do
create(:comment, commentable: debate, user: user, body: "This was a mistake")
login_as(user)
visit debate_path(debate)
accept_confirm("Are you sure? This action will delete this comment. You can't undo this action.") do
within(".comment-body", text: "This was a mistake") { click_link "Delete comment" }
end
expect(page).not_to have_content "This was a mistake"
expect(page).not_to have_link "Delete comment"
visit debate_path(debate)
expect(page).not_to have_content "This was a mistake"
expect(page).not_to have_link "Delete comment"
logout
login_as(create(:administrator).user)
visit admin_hidden_comments_path
expect(page).to have_content "This was a mistake"
end
scenario "With replies" do
comment = create(:comment, commentable: debate, user: user, body: "Wrong comment")
create(:comment, commentable: debate, parent: comment, body: "Right reply")
login_as(user)
visit debate_path(debate)
accept_confirm("Are you sure? This action will delete this comment. You can't undo this action.") do
within(".comment-body", text: "Wrong comment") { click_link "Delete comment" }
end
within "#comments > .comment-list > li", text: "Right reply" do
expect(page).to have_content "This comment has been deleted"
expect(page).not_to have_content "Wrong comment"
end
visit debate_path(debate)
within "#comments > .comment-list > li", text: "Right reply" do
expect(page).to have_content "This comment has been deleted"
expect(page).not_to have_content "Wrong comment"
end
end
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?")

View File

@@ -325,6 +325,59 @@ describe "Comments" do
end end
end end
describe "Hide" do
scenario "Without replies" do
create(:comment, commentable: resource, user: user, body: "This was a mistake")
admin = create(:administrator).user
login_as(user)
visit polymorphic_path(resource)
accept_confirm("Are you sure? This action will delete this comment. You can't undo this action.") do
within(".comment-body", text: "This was a mistake") { click_link "Delete comment" }
end
expect(page).not_to have_content "This was a mistake"
expect(page).not_to have_link "Delete comment"
refresh
expect(page).not_to have_content "This was a mistake"
expect(page).not_to have_link "Delete comment"
logout
login_as(admin)
visit admin_hidden_comments_path
expect(page).to have_content "This was a mistake"
end
scenario "With replies" do
comment = create(:comment, commentable: resource, user: user, body: "Wrong comment")
create(:comment, commentable: resource, parent: comment, body: "Right reply")
login_as(user)
visit polymorphic_path(resource)
accept_confirm("Are you sure? This action will delete this comment. You can't undo this action.") do
within(".comment-body", text: "Wrong comment") { click_link "Delete comment" }
end
within "#comments > .comment-list > li", text: "Right reply" do
expect(page).to have_content "This comment has been deleted"
expect(page).not_to have_content "Wrong comment"
end
refresh
within "#comments > .comment-list > li", text: "Right reply" do
expect(page).to have_content "This comment has been deleted"
expect(page).not_to have_content "Wrong comment"
end
end
end
scenario "Reply" do scenario "Reply" do
comment = create(:comment, commentable: resource) comment = create(:comment, commentable: resource)