A platform for community discussion. Free, open, simple.
FIX: update theme fields when updating from ThemesInstallTask (#10143)
Mark VanLandinghamd00e83eab143
diff --git a/app/services/themes_install_task.rb b/app/services/themes_install_task.rbindex 9999de7ab80..6c601a5889e 100644--- a/app/services/themes_install_task.rb+++ b/app/services/themes_install_task.rb@@ -61,6 +61,7 @@ class ThemesInstallTaskdef update@remote_theme.update_from_remote+ @theme.saveadd_component_to_all_themesenddiff --git a/spec/services/themes_spec.rb b/spec/services/themes_spec.rbindex bc8e8a59521..5a2f0d7741d 100644--- a/spec/services/themes_spec.rb+++ b/spec/services/themes_spec.rb@@ -3,6 +3,7 @@require 'rails_helper'describe ThemesInstallTask do+ fab!(:admin) { Fabricate(:admin) }before doDiscourse::Application.load_tasks@@ -139,8 +140,33 @@ describe ThemesInstallTask doexpect(ChildTheme.find_by(parent_theme_id: parent_theme.id, child_theme_id: theme.id).nil?).to eq(false)endend++ it 'updates theme fields' do+ ThemesInstallTask.install({ "some_theme": component_repo })+ theme = Theme.find_by(name: THEME_NAME)+ remote = theme.remote_theme++ scss = "body { background-color: black; }"++ expect(theme.theme_fields.find_by(name: 'scss', value: scss)).to be_nil++ File.write("#{component_repo}/common/common.scss", scss)++ `cd #{component_repo} && git add common/common.scss`+ `cd #{component_repo} && git commit -am "update"`++ remote.update_remote_version+ expect(remote.commits_behind).to eq(1)+ expect(remote.remote_version).to eq(`cd #{component_repo} && git rev-parse HEAD`.strip)++ ThemesInstallTask.install({ "some_theme": component_repo })++ expect(theme.theme_fields.find_by(name: 'scss', value: scss)).not_to be_nil+ expect(remote.reload.commits_behind).to eq(0)+ endendend+describe '#theme_exists?' doit 'can use https or ssh and find the same repo' doremote_theme = RemoteTheme.create!(@@ -149,7 +175,7 @@ describe ThemesInstallTask doremote_version: "21122230dbfed804067849393c3332083ddd0c07",commits_behind: 2)- Fabricate(:theme, remote_theme: remote_theme)+ Fabricate(:theme, remote_theme: remote_theme, user: admin)# httpsinstaller = ThemesInstallTask.new({ "url": "https://github.com/org/testtheme" })