* Add article decorator published_timestamp * Use time HTML5 element and refactor date in partial * Add published_timestamp to Article Adding `published_timestamp` to the homepage we can then use JS to render the full timestamp localized for the user. We've also added the timestamp to the index and the API * Display article published timestamp on hover * Use time also in the article show page * Add timestamp to bottom articles as well * Remove published_timestamp from index because it is not used * Fix broken specs * Add more article dates specs * Refactor date initializers
29 lines
771 B
Ruby
29 lines
771 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Viewing a comment", type: :system, js: true do
|
|
let(:user) { create(:user) }
|
|
let(:article) { create(:article, user_id: user.id, show_comments: true) }
|
|
let(:comment) { create(:comment, commentable: article, user: user) }
|
|
let!(:timestamp) { "2019-03-04T10:00:00Z" }
|
|
|
|
before do
|
|
Timecop.freeze(timestamp)
|
|
sign_in user
|
|
visit comment.path
|
|
end
|
|
|
|
after do
|
|
Timecop.return
|
|
end
|
|
|
|
context "when showing the date" do
|
|
it "shows the readable publish date" do
|
|
expect(page).to have_selector(".comment-date time", text: "Mar 4")
|
|
end
|
|
|
|
it "embeds the published timestamp" do
|
|
selector = ".comment-date time[datetime='#{timestamp}']"
|
|
expect(page).to have_selector(selector)
|
|
end
|
|
end
|
|
end
|