mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 19:53:51 +08:00
FIX: update theme fields when updating from ThemesInstallTask (#10143)
This commit is contained in:
parent
3de1cf128c
commit
67cc6731c6
|
@ -61,6 +61,7 @@ class ThemesInstallTask
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@remote_theme.update_from_remote
|
@remote_theme.update_from_remote
|
||||||
|
@theme.save
|
||||||
add_component_to_all_themes
|
add_component_to_all_themes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe ThemesInstallTask do
|
describe ThemesInstallTask do
|
||||||
|
fab!(:admin) { Fabricate(:admin) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Discourse::Application.load_tasks
|
Discourse::Application.load_tasks
|
||||||
|
@ -139,8 +140,33 @@ describe ThemesInstallTask do
|
||||||
expect(ChildTheme.find_by(parent_theme_id: parent_theme.id, child_theme_id: theme.id).nil?).to eq(false)
|
expect(ChildTheme.find_by(parent_theme_id: parent_theme.id, child_theme_id: theme.id).nil?).to eq(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#theme_exists?' do
|
describe '#theme_exists?' do
|
||||||
it 'can use https or ssh and find the same repo' do
|
it 'can use https or ssh and find the same repo' do
|
||||||
remote_theme = RemoteTheme.create!(
|
remote_theme = RemoteTheme.create!(
|
||||||
|
@ -149,7 +175,7 @@ describe ThemesInstallTask do
|
||||||
remote_version: "21122230dbfed804067849393c3332083ddd0c07",
|
remote_version: "21122230dbfed804067849393c3332083ddd0c07",
|
||||||
commits_behind: 2
|
commits_behind: 2
|
||||||
)
|
)
|
||||||
Fabricate(:theme, remote_theme: remote_theme)
|
Fabricate(:theme, remote_theme: remote_theme, user: admin)
|
||||||
|
|
||||||
# https
|
# https
|
||||||
installer = ThemesInstallTask.new({ "url": "https://github.com/org/testtheme" })
|
installer = ThemesInstallTask.new({ "url": "https://github.com/org/testtheme" })
|
||||||
|
|
Loading…
Reference in New Issue
Block a user