A platform for community discussion. Free, open, simple.
DEV: Skip converting local dates as json
Vinoth Kannanb13b6e30d62c
diff --git a/plugins/discourse-local-dates/plugin.rb b/plugins/discourse-local-dates/plugin.rbindex cb243194d77..bb4daab5af3 100644--- a/plugins/discourse-local-dates/plugin.rb+++ b/plugins/discourse-local-dates/plugin.rb@@ -37,7 +37,7 @@ after_initialize doendif dates.present?- post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD] = dates.to_json+ post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD] = datespost.save_custom_fieldselsif !post.custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD].nil?post.custom_fields.delete(DiscourseLocalDates::POST_CUSTOM_FIELD)diff --git a/plugins/discourse-local-dates/spec/models/post_spec.rb b/plugins/discourse-local-dates/spec/models/post_spec.rbnew file mode 100644index 00000000000..15da7f75fd6--- /dev/null+++ b/plugins/discourse-local-dates/spec/models/post_spec.rb@@ -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