2018-09-17 08:48:43 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Post do
|
|
|
|
|
|
|
|
before do
|
2019-03-14 10:47:38 -04:00
|
|
|
Jobs.run_immediately!
|
2018-09-17 08:48:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#local_dates' do
|
|
|
|
it "should have correct custom fields" do
|
|
|
|
post = Fabricate(:post, raw: <<~SQL)
|
2018-10-15 19:34:55 -04:00
|
|
|
[date=2018-09-17 time=01:39:00 format="LLL" timezone="Europe/Paris" timezones="Europe/Paris|America/Los_Angeles"]
|
2018-09-17 08:48:43 -04:00
|
|
|
SQL
|
|
|
|
CookedPostProcessor.new(post).post_process
|
|
|
|
|
2018-09-17 09:09:59 -04:00
|
|
|
expect(post.local_dates.count).to eq(1)
|
|
|
|
expect(post.local_dates[0]["date"]).to eq("2018-09-17")
|
|
|
|
expect(post.local_dates[0]["time"]).to eq("01:39:00")
|
2018-10-15 19:34:55 -04:00
|
|
|
expect(post.local_dates[0]["timezone"]).to eq("Europe/Paris")
|
2018-09-17 08:48:43 -04:00
|
|
|
|
|
|
|
post.raw = "Text removed"
|
|
|
|
post.save
|
|
|
|
CookedPostProcessor.new(post).post_process
|
|
|
|
|
|
|
|
expect(post.local_dates).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|