mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
UX: Use local timezone for insert date modal result
This commit is contained in:
@ -5,9 +5,9 @@ RSpec.describe "Local Dates" do
|
||||
freeze_time
|
||||
end
|
||||
|
||||
it "should work" do
|
||||
it "should work without timezone" do
|
||||
post = Fabricate(:post, raw: <<~SQL)
|
||||
[date=2018-05-08 time=22:00 format="L LTS" forceTimezone="UTC" timezones="Europe/Paris|America/Los_Angeles"]
|
||||
[date=2018-05-08 time=22:00 format="L LTS" timezones="Europe/Paris|America/Los_Angeles"]
|
||||
SQL
|
||||
|
||||
cooked = post.cooked
|
||||
@ -15,7 +15,7 @@ RSpec.describe "Local Dates" do
|
||||
expect(cooked).to include('class="discourse-local-date"')
|
||||
expect(cooked).to include('data-date="2018-05-08"')
|
||||
expect(cooked).to include('data-format="L LTS"')
|
||||
expect(cooked).to include('data-force-timezone="UTC"')
|
||||
expect(cooked).not_to include('data-force-timezone=')
|
||||
|
||||
expect(cooked).to include(
|
||||
'data-timezones="Europe/Paris|America/Los_Angeles"'
|
||||
@ -25,6 +25,18 @@ RSpec.describe "Local Dates" do
|
||||
expect(cooked).to include('05/09/2018 12:00:00 AM (Europe: Paris)')
|
||||
end
|
||||
|
||||
it "should work with timezone" do
|
||||
post = Fabricate(:post, raw: <<~SQL)
|
||||
[date=2018-05-08 time=22:00 format="L LTS" timezone="Asia/Calcutta" timezones="Europe/Paris|America/Los_Angeles"]
|
||||
SQL
|
||||
|
||||
cooked = post.cooked
|
||||
|
||||
expect(cooked).to include('data-force-timezone="Asia/Calcutta"')
|
||||
expect(cooked).to include('05/08/2018 9:30:00 AM (America: Los Angeles)')
|
||||
expect(cooked).to include('05/08/2018 6:30:00 PM (Europe: Paris)')
|
||||
end
|
||||
|
||||
it 'requires the right attributes to convert to a local date' do
|
||||
post = Fabricate(:post, raw: <<~SQL)
|
||||
[date]
|
||||
@ -33,6 +45,6 @@ RSpec.describe "Local Dates" do
|
||||
cooked = post.cooked
|
||||
|
||||
expect(post.cooked).to include("<p>[date]</p>")
|
||||
expect(cooked).to_not include('data-force-timezone=')
|
||||
expect(cooked).to_not include('data-date=')
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user