Skip to content

Commit a440e15

Browse files
authored
DEV: Remove experimental_objects_type_for_theme_settings site setting (#26507)
Why this change? Objects type for theme settings is no longer considered experimental so we are dropping the site setting.
1 parent 49409f4 commit a440e15

File tree

11 files changed

+11
-57
lines changed

11 files changed

+11
-57
lines changed

app/controllers/admin/themes_controller.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,9 @@ def update_single_setting
354354
end
355355

356356
def schema
357-
raise Discourse::InvalidAccess if !SiteSetting.experimental_objects_type_for_theme_settings
358357
end
359358

360359
def objects_setting_metadata
361-
raise Discourse::InvalidAccess if !SiteSetting.experimental_objects_type_for_theme_settings
362-
363360
theme = Theme.find_by(id: params[:id])
364361
raise Discourse::InvalidParameters.new(:id) unless theme
365362

app/models/theme_setting.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class ThemeSetting < ActiveRecord::Base
1111
MAXIMUM_JSON_VALUE_SIZE_BYTES = 0.5 * 1024 * 1024 # 0.5 MB
1212

1313
validates_presence_of :name, :theme
14-
before_validation :objects_type_enabled
1514
validates :data_type, inclusion: { in: TYPES_ENUM.values }
1615
validate :json_value_size, if: -> { self.data_type == TYPES_ENUM[:objects] }
1716
validates :name, length: { maximum: 255 }
@@ -49,13 +48,6 @@ def self.guess_type(value)
4948

5049
private
5150

52-
def objects_type_enabled
53-
if self.data_type == ThemeSetting.types[:objects] &&
54-
!SiteSetting.experimental_objects_type_for_theme_settings
55-
self.data_type = nil
56-
end
57-
end
58-
5951
def json_value_size
6052
if json_value.to_json.size > MAXIMUM_JSON_VALUE_SIZE_BYTES
6153
errors.add(

config/site_settings.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,9 +2366,6 @@ developer:
23662366
list_type: compact
23672367
allow_any: false
23682368
refresh: true
2369-
experimental_objects_type_for_theme_settings:
2370-
default: false
2371-
hidden: true
23722369

23732370
navigation:
23742371
navigation_menu:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveExperimentalObjectsTypeForThemeSettings < ActiveRecord::Migration[7.0]
4+
def up
5+
execute "DELETE FROM site_settings WHERE name = 'experimental_objects_type_for_theme_settings'"
6+
end
7+
8+
def down
9+
raise ActiveRecord::IrreversibleMigration
10+
end
11+
end

spec/lib/theme_settings_manager/objects_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
theme.settings
1111
end
1212

13-
before { SiteSetting.experimental_objects_type_for_theme_settings = true }
14-
1513
it "can store a list of objects" do
1614
new_value = [
1715
{

spec/models/theme_field_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
before do
88
SvgSprite.clear_plugin_svg_sprite_cache!
99
ThemeJavascriptCompiler.disable_terser!
10-
SiteSetting.experimental_objects_type_for_theme_settings = true
1110
end
1211

1312
after { ThemeJavascriptCompiler.enable_terser! }

spec/models/theme_setting_spec.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,7 @@
44
fab!(:theme)
55

66
context "for validations" do
7-
it "should be invalid when setting data_type to objects and `experimental_objects_type_for_theme_settings` is disabled" do
8-
SiteSetting.experimental_objects_type_for_theme_settings = false
9-
10-
theme_setting =
11-
ThemeSetting.new(name: "test", data_type: ThemeSetting.types[:objects], theme:)
12-
13-
expect(theme_setting.valid?).to eq(false)
14-
expect(theme_setting.errors[:data_type]).to contain_exactly("is not included in the list")
15-
end
16-
17-
it "should be valid when setting data_type to objects and `experimental_objects_type_for_theme_settings` is enabled" do
18-
SiteSetting.experimental_objects_type_for_theme_settings = true
19-
20-
theme_setting =
21-
ThemeSetting.new(name: "test", data_type: ThemeSetting.types[:objects], theme:)
22-
23-
expect(theme_setting.valid?).to eq(true)
24-
end
25-
267
it "should be invalid when json_value size is greater than the maximum allowed size" do
27-
SiteSetting.experimental_objects_type_for_theme_settings = true
28-
298
json_value = { "key" => "value" }
309
bytesize = json_value.to_json.bytesize
3110

spec/requests/admin/themes_controller_spec.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,6 @@
10641064
end
10651065

10661066
it "should return the right error when value used to update a theme setting of `objects` typed is invalid" do
1067-
SiteSetting.experimental_objects_type_for_theme_settings = true
1068-
10691067
field =
10701068
theme.set_field(
10711069
target: :settings,
@@ -1091,8 +1089,6 @@
10911089
end
10921090

10931091
it "should be able to update a theme setting of `objects` typed" do
1094-
SiteSetting.experimental_objects_type_for_theme_settings = true
1095-
10961092
field =
10971093
theme.set_field(
10981094
target: :settings,
@@ -1351,8 +1347,6 @@
13511347
theme.settings
13521348
end
13531349

1354-
before { SiteSetting.experimental_objects_type_for_theme_settings = true }
1355-
13561350
it "returns 404 if user is not an admin" do
13571351
get "/admin/themes/#{theme.id}/objects_setting_metadata/objects_with_categories.json"
13581352

@@ -1374,14 +1368,6 @@
13741368
context "when user is an admin" do
13751369
before { sign_in(admin) }
13761370

1377-
it "returns 403 if `experimental_objects_type_for_theme_settings` site setting is not enabled" do
1378-
SiteSetting.experimental_objects_type_for_theme_settings = false
1379-
1380-
get "/admin/themes/#{theme.id}/objects_setting_metadata/objects_with_categories.json"
1381-
1382-
expect(response.status).to eq(403)
1383-
end
1384-
13851371
it "returns 400 if the `id` param is not the id of a valid theme" do
13861372
get "/admin/themes/some_invalid_id/objects_setting_metadata/objects_with_categories.json"
13871373

spec/serializers/theme_objects_setting_metadata_serializer_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
theme.settings
1111
end
1212

13-
before { SiteSetting.experimental_objects_type_for_theme_settings = true }
14-
1513
describe "#property_descriptions" do
1614
let(:objects_setting_locale) do
1715
theme.set_field(

spec/serializers/theme_settings_serializer_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
theme.settings
1111
end
1212

13-
before { SiteSetting.experimental_objects_type_for_theme_settings = true }
14-
1513
describe "#objects_schema" do
1614
it "should include the attribute when theme setting is typed objects" do
1715
payload = ThemeSettingsSerializer.new(theme_setting[:objects_setting]).as_json

0 commit comments

Comments
 (0)