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:
OsamaSayegh
2018-07-12 14:18:21 +10:00
committed by Sam
parent f13a7226db
commit decf1f27cf
45 changed files with 289 additions and 241 deletions
+5 -5
View File
@@ -7,18 +7,18 @@ describe Site do
json = Site.json_for(guardian)
parsed = JSON.parse(json)
expected = Theme.where('key = :default OR user_selectable',
default: SiteSetting.default_theme_key)
expected = Theme.where('id = :default OR user_selectable',
default: SiteSetting.default_theme_id)
.order(:name)
.pluck(:key, :name)
.map { |k, n| { "theme_key" => k, "name" => n, "default" => k == SiteSetting.default_theme_key } }
.pluck(:id, :name)
.map { |id, n| { "theme_id" => id, "name" => n, "default" => id == SiteSetting.default_theme_id } }
expect(parsed["user_themes"]).to eq(expected)
end
it "includes user themes and expires them as needed" do
default_theme = Theme.create!(user_id: -1, name: 'default')
SiteSetting.default_theme_key = default_theme.key
SiteSetting.default_theme_id = default_theme.id
user_theme = Theme.create!(user_id: -1, name: 'user theme', user_selectable: true)
anon_guardian = Guardian.new