Skip to content

Commit fdfcdaf

Browse files
authored
fix: Use named deprecator (#1406)
* fix: Use named deprecator * fix: Youtube title changed
1 parent 00d6989 commit fdfcdaf

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

app/controllers/concerns/spina/current_spina_account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module CurrentSpinaAccount
1111
private
1212

1313
def current_account
14-
ActiveSupport::Deprecation.warn(
14+
Spina.deprecator.warn(
1515
"#current_account is deprecated, due to a common authentication namespace conflict. \n" \
1616
"Please use #current_spina_account instead."
1717
)

app/models/spina/account.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def self.serialized_attr_accessor(*args)
2323
args.each do |method_name|
2424
define_method method_name do
2525
if preferences.try(:[], method_name.to_sym).present?
26-
ActiveSupport::Deprecation.warn("#{method_name} is stored as a symbol. Please set and save it again using #{method_name}= on your Spina::Account model to store it as a string. You can do this from the UI by saving your account preferences.")
26+
Spina.deprecator.warn("#{method_name} is stored as a symbol. Please set and save it again using #{method_name}= on your Spina::Account model to store it as a string. You can do this from the UI by saving your account preferences.")
2727
end
2828

2929
preferences.try(:[], method_name.to_s) ||
@@ -78,7 +78,7 @@ def find_or_create_custom_pages(theme)
7878
parent_page = Page.find_by(name: page[:parent])
7979
ancestry = [parent_page&.ancestry, parent_page&.id].compact.join("/")
8080
end
81-
81+
8282
Page.where(name: page[:name])
8383
.first_or_create(title: page[:title])
8484
.update(view_template: page[:view_template], deletable: page[:deletable], ancestry: ancestry)

lib/spina.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ def config
9090
config_obj = config_original
9191

9292
def config_obj.tailwind_purge_content
93-
ActiveSupport::Deprecation.warn("config.tailwind_purge_content has been renamed to config.tailwind_content")
93+
deprecator.warn("config.tailwind_purge_content has been renamed to config.tailwind_content")
9494
tailwind_content
9595
end
9696

9797
def config_obj.tailwind_purge_content=(paths)
98-
ActiveSupport::Deprecation.warn("config.tailwind_purge_content has been renamed to config.tailwind_content")
98+
deprecator.warn("config.tailwind_purge_content has been renamed to config.tailwind_content")
9999
self.tailwind_content = paths
100100
end
101101

102102
def config_obj.embedded_image_size=(image_size)
103103
if image_size.is_a? String
104-
ActiveSupport::Deprecation.warn("Spina embedded_image_size should be set to an array of arguments to be passed to the :resize_to_limit ImageProcessing macro. https://github.com/janko/image_processing/blob/master/doc/minimagick.md#resize_to_limit")
104+
deprecator.warn("Spina embedded_image_size should be set to an array of arguments to be passed to the :resize_to_limit ImageProcessing macro. https://github.com/janko/image_processing/blob/master/doc/minimagick.md#resize_to_limit")
105105
end
106106

107107
self[:embedded_image_size] = image_size
@@ -110,6 +110,10 @@ def config_obj.embedded_image_size=(image_size)
110110
config_obj
111111
end
112112

113+
def deprecator
114+
ActiveSupport::Deprecation.new("", "Spina")
115+
end
116+
113117
def mounted_at
114118
Spina::Engine.routes.find_script_name({})
115119
end

lib/spina/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Engine < ::Rails::Engine
2121
config.to_prepare do
2222
unless Spina.config.disable_decorator_load
2323
Dir.glob(Rails.root + "app/decorators/**/*_decorator.rb").each do |decorator|
24-
ActiveSupport::Deprecation.warn("using app/decorators is deprecated in favor of app/overrides. Read more about overriding Spina at spinacms.com/guides")
24+
Spina.deprecator.warn("using app/decorators is deprecated in favor of app/overrides. Read more about overriding Spina at spinacms.com/guides")
2525
require_dependency(decorator)
2626
end
2727
end

test/system/spina/admin/editing_pages_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Admin::EditingPagesTest < ApplicationSystemTestCase
3737
assert_selector "label", text: "Youtube URL", wait: 5
3838
fill_in "embeddable[url]", with: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
3939
click_button "Embed component"
40-
assert_selector "trix-editor spina-embed", text: "Rick Astley - Never Gonna Give You Up (Official Music Video)", wait: 5
40+
assert_selector "trix-editor spina-embed", text: "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)", wait: 5
4141
click_button "Save changes"
4242
assert_selector "turbo-frame", text: "Page saved"
4343
visit "/"

0 commit comments

Comments
 (0)