Unify hide comments specs
This commit is contained in:
@@ -325,6 +325,59 @@ describe "Comments" do
|
||||
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
|
||||
comment = create(:comment, commentable: resource)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user