discourse/plugins/discourse-local-dates/spec/models/post_spec.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

32 lines
813 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe Post do
before do
Jobs.run_immediately!
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" timezone="Europe/Paris" timezones="Europe/Paris|America/Los_Angeles"]
SQL
CookedPostProcessor.new(post).post_process
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")
expect(post.local_dates[0]["timezone"]).to eq("Europe/Paris")
post.raw = "Text removed"
post.save
CookedPostProcessor.new(post).post_process
expect(post.local_dates).to eq([])
end
end
end