UX: emphasizes on local-dates being UTC in excerpts (#8208)

This commit is contained in:
Joffrey JAFFEUX 2019-10-17 16:18:06 +02:00 committed by Robin Ward
parent ecfba0bb37
commit 54bc2bdba7
2 changed files with 15 additions and 0 deletions

View File

@ -53,6 +53,12 @@ after_initialize do
custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD] || []
end
on(:reduce_excerpt) do |fragment, post|
fragment.css('.discourse-local-date').each do |container|
container.content = "#{container.content} (UTC)"
end
end
on(:reduce_cooked) do |fragment|
fragment.css('.discourse-local-date').each do |container|
if container.attributes['data-email-preview']

View File

@ -71,4 +71,13 @@ describe PrettyText do
end
end
end
context 'excerpt simplified rendering' do
let(:post) { Fabricate(:post, raw: '[date=2019-10-16 time=14:00:00 format="LLLL" timezone="America/New_York"]') }
it 'adds UTC' do
excerpt = PrettyText.excerpt(post.cooked, 200)
expect(excerpt).to eq("Wednesday, October 16, 2019 6:00 PM (UTC)")
end
end
end