mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:09:18 +08:00
DEV: Remove unnecessary freedom patches
This patch removes two freedom patches: - `mail_disable_starttls.rb`: this has been fixed in the 2.8 release of the mail gem, so we don’t need it anymore. - `rails4.rb`: those methods have been deprecated for a while now and should have been dropped with Discourse v3.2.
This commit is contained in:
parent
9d5f4bf2f1
commit
86f1c177d6
|
@ -9,7 +9,7 @@ module ActiveRecordSerializationSafety
|
|||
message =
|
||||
"Serializing ActiveRecord models (#{self.class.name}) without specifying fields is not allowed. Use a Serializer, or pass the :only option to #serializable_hash. More info: https://meta.discourse.org/t/-/314495"
|
||||
|
||||
if Rails.env == "production"
|
||||
if Rails.env.production?
|
||||
Rails.logger.info(message)
|
||||
else
|
||||
raise BlockedSerializationError.new(message)
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Patch from
|
||||
# https://github.com/rails/rails/issues/44698#issuecomment-1069675285 to enable
|
||||
# previous behavior with Net::SMTP regarding TLS.
|
||||
#
|
||||
# This should be fixed in an upcoming release of the Mail gem (probably 2.8),
|
||||
# when this patch is merged: https://github.com/mikel/mail/pull/1435
|
||||
module FreedomPatches
|
||||
module MailDisableStarttls
|
||||
def build_smtp_session
|
||||
super.tap do |smtp|
|
||||
unless settings[:enable_starttls_auto]
|
||||
smtp.disable_starttls if smtp.respond_to?(:disable_starttls)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
::Mail::SMTP.prepend(self)
|
||||
end
|
||||
end
|
|
@ -1,27 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module FreedomPatches
|
||||
module Rails4
|
||||
def self.distance_of_time_in_words(*args)
|
||||
Discourse.deprecate(
|
||||
"FreedomPatches::Rails4.distance_of_time_in_words has moved to AgeWords.distance_of_time_in_words",
|
||||
output_in_test: true,
|
||||
since: "3.1.0.beta5",
|
||||
drop_from: "3.2.0.beta1",
|
||||
)
|
||||
|
||||
AgeWords.distance_of_time_in_words(*args)
|
||||
end
|
||||
|
||||
def self.time_ago_in_words(*args)
|
||||
Discourse.deprecate(
|
||||
"FreedomPatches::Rails4.time_ago_in_words has moved to AgeWords.time_ago_in_words",
|
||||
output_in_test: true,
|
||||
since: "3.1.0.beta5",
|
||||
drop_from: "3.2.0.beta1",
|
||||
)
|
||||
|
||||
AgeWords.time_ago_in_words(*args)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -19,7 +19,7 @@ module FreedomPatches
|
|||
buf << source
|
||||
end
|
||||
|
||||
if Rails.env.development? || Rails.env.test?
|
||||
if Rails.env.local?
|
||||
Sprockets.register_bundle_metadata_reducer "application/javascript",
|
||||
:data,
|
||||
proc { +"" },
|
||||
|
@ -28,7 +28,7 @@ module FreedomPatches
|
|||
end
|
||||
end
|
||||
|
||||
if Rails.env.development? || Rails.env.test?
|
||||
if Rails.env.local?
|
||||
ActiveSupport.on_load(:action_view) do
|
||||
def compute_asset_path(source, _options = {})
|
||||
"/assets/#{source}"
|
||||
|
|
|
@ -52,7 +52,7 @@ module I18n
|
|||
# load it
|
||||
I18n.backend.load_translations(I18n.load_path.grep(/\.#{Regexp.escape locale}\.yml\z/))
|
||||
|
||||
if Discourse.allow_dev_populate? || Rails.env.test? || Rails.env.development?
|
||||
if Discourse.allow_dev_populate? || Rails.env.local?
|
||||
I18n.backend.load_translations(
|
||||
I18n.load_path.grep(%r{.*faker.*/#{Regexp.escape locale}\.yml\z}),
|
||||
)
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe FreedomPatches::MailDisableStarttls do
|
||||
subject(:smtp_session) { smtp.build_smtp_session }
|
||||
|
||||
let(:smtp) { Mail::SMTP.new(options) }
|
||||
|
||||
context "when the starttls option is not provided" do
|
||||
let(:options) { {} }
|
||||
|
||||
it "doesn't disable starttls" do
|
||||
expect(smtp_session.starttls?).to eq(:auto)
|
||||
end
|
||||
end
|
||||
|
||||
context "when the starttls option is set to `false`" do
|
||||
let(:options) { { enable_starttls_auto: false } }
|
||||
|
||||
it "properly disables starttls" do
|
||||
expect(smtp_session.starttls?).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user