docbrown/spec/system/user/view_user_comments_spec.rb
Alex 393ba00221
Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606)
* Attempt number 1

* Fix rack_attack specs

* Fix users_searches_users spec

* Fix display_users_search_spec

* Fix comment typo

* Remove search:destroy task from cypress

* Remove port 9300 from gitpod

* Stub response in attack_spec
2021-05-03 11:09:45 -04:00

36 lines
1.2 KiB
Ruby

require "rails_helper"
RSpec.describe "User comments", type: :system do
let!(:user) { create(:user, username: "user3000") }
let!(:article) { create(:article, user: user) }
let!(:comment) { create(:comment, user: user, commentable: create(:article)) }
let!(:comment2) { create(:comment, user: user, commentable: create(:article)) }
context "when user is unauthorized" do
before { visit "/user3000/comments" }
it "does not show user's articles" do
within("#substories") do
expect(page).not_to have_content(article.title)
end
end
it "shows user's comments", js: true do
within("#substories div.profile-comment-card") do
expect(page).to have_content("All 2 comments")
expect(page).to have_link(nil, href: comment.path)
expect(page).to have_link(nil, href: comment2.path)
end
end
end
context "when user has too many comments" do
it "show user's last comments ", js: true do
stub_const("CommentsHelper::MAX_COMMENTS_TO_RENDER", 1)
visit "/user3000/comments"
within("#substories div.profile-comment-card") do
expect(page).to have_content("Last 1 comments")
end
end
end
end