docbrown/spec/system/articles/user_visits_an_article_spec.rb
Andy Zhao b953f17d0c New Feature: Subscribe to posts! (#3149)
* Add MVP of notification subscriptions

* Add rate limiting for notification subscriptions

* Show modal for logged out users on subscribe click

* Add enter key functionality for checkbox

* Add relationships for notification subscriptions

* Add model test for notification subscription

* Deprecated article mutes in favor of notification subscriptions

* Deprecated comment mutes in favor of notification subscriptions

* Move comment muting tests and logic over

* Merge comment and article muting into subscriptions

* Remove redundant check

* Use database to check for rate limit instead of cache

* Test for subscriptions handling notifications properly

* Fix notification model spec for subscriptions

* Fix tests for subscriptions

* Remove rate limiting

* Properly handle logged out users getting subscription status

* Fix test for new pattern

* Update reserved words

* Add config column to notification subscriptions

* Add logic for top level config and move tests

* Test for top level subscribers getting notified

* Fix logic mistake oops

* Add index and refactor comment_user_ids
2019-06-14 12:03:43 -04:00

39 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe "Views an article", type: :system do
let_it_be(:user) { create(:user) }
let_it_be(:article, reload: true) { create(:article, :with_notification_subscription, user: user) }
let(:timestamp) { "2019-03-04T10:00:00Z" }
before do
sign_in user
end
it "shows an article" do
visit "/#{user.username}/#{article.slug}"
expect(page).to have_content(article.title)
end
it "shows comments", js: true do
create_list(:comment, 3, commentable: article)
visit "/#{user.username}/#{article.slug}"
expect(page).to have_selector(".single-comment-node", visible: true, count: 3)
end
context "when showing the date" do
before do
article.update_column(:published_at, Time.zone.parse(timestamp))
end
it "shows the readable publish date", js: true do
visit "/#{user.username}/#{article.slug}"
expect(page).to have_selector("article time", text: "Mar 4")
end
it "embeds the published timestamp" do
visit "/#{user.username}/#{article.slug}"
selector = "article time[datetime='#{timestamp}']"
expect(page).to have_selector(selector)
end
end
end