docbrown/spec/system/articles/user_visits_an_article_spec.rb
Mac Siri cea77663ad Fix flaky editor spec & change dev configs (#3022)
* Update .simplecov

* Downgrade factory_bot_rails

* Update flaky test

* Update .travis.yml

* Update user_edits_an_article_spec
2019-06-03 15:01:05 -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, 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