FIX: remote theme record not saved when checking for updates (#8054)
This commit is contained in:
parent
1a909c16eb
commit
ff8cc244d8
|
@ -186,22 +186,16 @@ class Admin::ThemesController < Admin::AdminController
|
||||||
update_translations
|
update_translations
|
||||||
handle_switch
|
handle_switch
|
||||||
|
|
||||||
save_remote = false
|
|
||||||
if params[:theme][:remote_check]
|
if params[:theme][:remote_check]
|
||||||
@theme.remote_theme.update_remote_version
|
@theme.remote_theme.update_remote_version
|
||||||
save_remote = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:theme][:remote_update]
|
if params[:theme][:remote_update]
|
||||||
@theme.remote_theme.update_from_remote
|
@theme.remote_theme.update_from_remote
|
||||||
save_remote = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @theme.save
|
if @theme.save
|
||||||
|
|
||||||
@theme.remote_theme.save! if save_remote
|
|
||||||
|
|
||||||
update_default_theme
|
update_default_theme
|
||||||
|
|
||||||
@theme.reload
|
@theme.reload
|
||||||
|
|
|
@ -106,6 +106,8 @@ class RemoteTheme < ActiveRecord::Base
|
||||||
self.updated_at = Time.zone.now
|
self.updated_at = Time.zone.now
|
||||||
self.remote_version, self.commits_behind = importer.commits_since(local_version)
|
self.remote_version, self.commits_behind = importer.commits_since(local_version)
|
||||||
self.last_error_text = nil
|
self.last_error_text = nil
|
||||||
|
ensure
|
||||||
|
self.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -119,6 +121,7 @@ class RemoteTheme < ActiveRecord::Base
|
||||||
importer.import!
|
importer.import!
|
||||||
rescue RemoteTheme::ImportError => err
|
rescue RemoteTheme::ImportError => err
|
||||||
self.last_error_text = err.message
|
self.last_error_text = err.message
|
||||||
|
self.save!
|
||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
self.last_error_text = nil
|
self.last_error_text = nil
|
||||||
|
@ -163,6 +166,7 @@ class RemoteTheme < ActiveRecord::Base
|
||||||
|
|
||||||
update_theme_color_schemes(theme, theme_info["color_schemes"]) unless theme.component
|
update_theme_color_schemes(theme, theme_info["color_schemes"]) unless theme.component
|
||||||
|
|
||||||
|
self.save!
|
||||||
self
|
self
|
||||||
ensure
|
ensure
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -330,6 +330,22 @@ describe Admin::ThemesController do
|
||||||
expect(theme.theme_translation_overrides.count).to eq(0)
|
expect(theme.theme_translation_overrides.count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'checking for updates saves the remote_theme record' do
|
||||||
|
theme.remote_theme = RemoteTheme.create!(remote_url: "http://discourse.org", remote_version: "a", local_version: "a", commits_behind: 0)
|
||||||
|
theme.save!
|
||||||
|
ThemeStore::GitImporter.any_instance.stubs(:import!)
|
||||||
|
ThemeStore::GitImporter.any_instance.stubs(:commits_since).returns(["b", 1])
|
||||||
|
|
||||||
|
put "/admin/themes/#{theme.id}.json", params: {
|
||||||
|
theme: {
|
||||||
|
remote_check: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theme.reload
|
||||||
|
expect(theme.remote_theme.remote_version).to eq("b")
|
||||||
|
expect(theme.remote_theme.commits_behind).to eq(1)
|
||||||
|
end
|
||||||
|
|
||||||
it 'can disable component' do
|
it 'can disable component' do
|
||||||
child = Fabricate(:theme, component: true)
|
child = Fabricate(:theme, component: true)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue