mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 05:43:16 +08:00
DEV: Skip converting local dates as json
This commit is contained in:
parent
4481836de2
commit
b13b6e30d6
|
@ -37,7 +37,7 @@ after_initialize do
|
|||
end
|
||||
|
||||
if dates.present?
|
||||
post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD] = dates.to_json
|
||||
post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD] = dates
|
||||
post.save_custom_fields
|
||||
elsif !post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD].nil?
|
||||
post.custom_fields.delete(DiscourseLocalDates::POST_CUSTOM_FIELD)
|
||||
|
|
26
plugins/discourse-local-dates/spec/models/post_spec.rb
Normal file
26
plugins/discourse-local-dates/spec/models/post_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Post do
|
||||
|
||||
before do
|
||||
SiteSetting.queue_jobs = false
|
||||
end
|
||||
|
||||
describe '#local_dates' do
|
||||
it "should have correct custom fields" do
|
||||
post = Fabricate(:post, raw: <<~SQL)
|
||||
[date=2018-09-17 time=01:39:00 format="LLL" timezones="Europe/Paris|America/Los_Angeles"]
|
||||
SQL
|
||||
CookedPostProcessor.new(post).post_process
|
||||
|
||||
expect(post.local_dates).to eq([{"date"=>"2018-09-17", "time"=>"01:39:00"}])
|
||||
|
||||
post.raw = "Text removed"
|
||||
post.save
|
||||
CookedPostProcessor.new(post).post_process
|
||||
|
||||
expect(post.local_dates).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user