Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove unnecessary freedom patches

Loïc Guitaut86f1c177d699
diff --git a/lib/freedom_patches/active_record_disable_serialization.rb b/lib/freedom_patches/active_record_disable_serialization.rb
index 47d50042d82..7718f557e3a 100644
--- a/lib/freedom_patches/active_record_disable_serialization.rb
+++ b/lib/freedom_patches/active_record_disable_serialization.rb
@@ -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)
diff --git a/lib/freedom_patches/mail_disable_starttls.rb b/lib/freedom_patches/mail_disable_starttls.rb
deleted file mode 100644
index a8a60bda86e..00000000000
--- a/lib/freedom_patches/mail_disable_starttls.rb
+++ /dev/null
@@ -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
diff --git a/lib/freedom_patches/rails4.rb b/lib/freedom_patches/rails4.rb
deleted file mode 100644
index e5751d63130..00000000000
--- a/lib/freedom_patches/rails4.rb
+++ /dev/null
@@ -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
diff --git a/lib/freedom_patches/sprockets_patches.rb b/lib/freedom_patches/sprockets_patches.rb
index 00d646af47d..928d714bf25 100644
--- a/lib/freedom_patches/sprockets_patches.rb
+++ b/lib/freedom_patches/sprockets_patches.rb
@@ -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}"
diff --git a/lib/freedom_patches/translate_accelerator.rb b/lib/freedom_patches/translate_accelerator.rb
index cd47e5d3db0..fafa982118a 100644
--- a/lib/freedom_patches/translate_accelerator.rb
+++ b/lib/freedom_patches/translate_accelerator.rb
@@ -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}),
)
diff --git a/spec/lib/freedom_patches/mail_disable_starttls_spec.rb b/spec/lib/freedom_patches/mail_disable_starttls_spec.rb
deleted file mode 100644
index 86aa6b87bd8..00000000000
--- a/spec/lib/freedom_patches/mail_disable_starttls_spec.rb
+++ /dev/null
@@ -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