mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Groundwork for user-selectable theme components
* Phase 0 for user-selectable theme components - Drops `key` column from the `themes` table - Drops `theme_key` column from the `user_options` table - Adds `theme_ids` (array of ints default []) column to the `user_options` table and migrates data from `theme_key` to the new column. - Removes the `default_theme_key` site setting and adds `default_theme_id` instead. - Replaces `theme_key` cookie with a new one called `theme_ids` - no longer need Theme.settings_for_client
This commit is contained in:
@@ -34,12 +34,12 @@ describe Middleware::AnonymousCache::Helper do
|
||||
it "handles theme keys" do
|
||||
theme = Theme.create(name: "test", user_id: -1, user_selectable: true)
|
||||
|
||||
with_bad_theme_key = new_helper("HTTP_COOKIE" => "theme_key=abc").cache_key
|
||||
with_bad_theme_key = new_helper("HTTP_COOKIE" => "theme_ids=abc").cache_key
|
||||
with_no_theme_key = new_helper().cache_key
|
||||
|
||||
expect(with_bad_theme_key).to eq(with_no_theme_key)
|
||||
|
||||
with_good_theme_key = new_helper("HTTP_COOKIE" => "theme_key=#{theme.key}").cache_key
|
||||
with_good_theme_key = new_helper("HTTP_COOKIE" => "theme_ids=#{theme.id}").cache_key
|
||||
|
||||
expect(with_good_theme_key).not_to eq(with_no_theme_key)
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ describe Stylesheet::Manager do
|
||||
expect(link).to eq("")
|
||||
|
||||
theme = Theme.create(name: "embedded", user_id: -1)
|
||||
SiteSetting.default_theme_key = theme.key
|
||||
SiteSetting.default_theme_id = theme.id
|
||||
|
||||
link = Stylesheet::Manager.stylesheet_link_tag(:embedded_theme)
|
||||
expect(link).not_to eq("")
|
||||
@@ -41,9 +41,9 @@ describe Stylesheet::Manager do
|
||||
|
||||
theme.add_child_theme!(child_theme)
|
||||
|
||||
old_link = Stylesheet::Manager.stylesheet_link_tag(:desktop_theme, 'all', theme.key)
|
||||
old_link = Stylesheet::Manager.stylesheet_link_tag(:desktop_theme, 'all', theme.id)
|
||||
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
||||
manager.compile(force: true)
|
||||
|
||||
css = File.read(manager.stylesheet_fullpath)
|
||||
@@ -57,7 +57,7 @@ describe Stylesheet::Manager do
|
||||
child_theme.set_field(target: :desktop, name: :scss, value: ".nothing{color: green;}")
|
||||
child_theme.save!
|
||||
|
||||
new_link = Stylesheet::Manager.stylesheet_link_tag(:desktop_theme, 'all', theme.key)
|
||||
new_link = Stylesheet::Manager.stylesheet_link_tag(:desktop_theme, 'all', theme.id)
|
||||
|
||||
expect(new_link).not_to eq(old_link)
|
||||
|
||||
@@ -77,12 +77,12 @@ describe Stylesheet::Manager do
|
||||
user_id: -1
|
||||
)
|
||||
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
||||
digest1 = manager.digest
|
||||
|
||||
DiscoursePluginRegistry.stylesheets.add "fake_file"
|
||||
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
||||
digest2 = manager.digest
|
||||
|
||||
expect(digest1).not_to eq(digest2)
|
||||
@@ -107,7 +107,7 @@ describe Stylesheet::Manager do
|
||||
type_id: ThemeField.types[:theme_upload_var]
|
||||
)
|
||||
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
||||
digest1 = manager.digest
|
||||
field.destroy!
|
||||
|
||||
@@ -121,7 +121,7 @@ describe Stylesheet::Manager do
|
||||
type_id: ThemeField.types[:theme_upload_var]
|
||||
)
|
||||
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
||||
digest2 = manager.digest
|
||||
|
||||
expect(digest1).not_to eq(digest2)
|
||||
@@ -137,7 +137,7 @@ describe Stylesheet::Manager do
|
||||
category1 = Fabricate(:category, uploaded_background_id: 123, updated_at: 1.week.ago)
|
||||
category2 = Fabricate(:category, uploaded_background_id: 456, updated_at: 2.days.ago)
|
||||
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.key)
|
||||
manager = Stylesheet::Manager.new(:desktop_theme, theme.id)
|
||||
|
||||
digest1 = manager.color_scheme_digest
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ describe Wizard::StepUpdater do
|
||||
updater.update
|
||||
expect(updater.success?).to eq(true)
|
||||
expect(wizard.completed_steps?('colors')).to eq(true)
|
||||
theme = Theme.find_by(key: SiteSetting.default_theme_key)
|
||||
theme = Theme.find_by(id: SiteSetting.default_theme_id)
|
||||
expect(theme.color_scheme.base_scheme_id).to eq('dark')
|
||||
end
|
||||
end
|
||||
@@ -203,7 +203,7 @@ describe Wizard::StepUpdater do
|
||||
expect(color_scheme).to be_present
|
||||
expect(color_scheme.colors).to be_present
|
||||
|
||||
theme = Theme.find_by(key: SiteSetting.default_theme_key)
|
||||
theme = Theme.find_by(id: SiteSetting.default_theme_id)
|
||||
expect(theme.color_scheme_id).to eq(color_scheme.id)
|
||||
|
||||
expect(Theme.where(user_selectable: true).count).to eq(2)
|
||||
|
||||
Reference in New Issue
Block a user