mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 10:40:22 +08:00
FIX: Rescue and display import errors when updating theme via git
This commit is contained in:
parent
bfceb29db8
commit
9f49007b7b
|
@ -209,6 +209,8 @@ class Admin::ThemesController < Admin::AdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
rescue RemoteTheme::ImportError => e
|
||||||
|
render_json_error e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -311,7 +311,19 @@ describe Admin::ThemesController do
|
||||||
# Database correct
|
# Database correct
|
||||||
theme.reload
|
theme.reload
|
||||||
expect(theme.theme_translation_overrides.count).to eq(0)
|
expect(theme.theme_translation_overrides.count).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'handles import errors on update' do
|
||||||
|
theme.create_remote_theme!(remote_url: "https://example.com/repository")
|
||||||
|
|
||||||
|
# RemoteTheme is extensively tested, and setting up the test scaffold is a large overhead
|
||||||
|
# So use a stub here to test the controller
|
||||||
|
RemoteTheme.any_instance.stubs(:update_from_remote).raises(RemoteTheme::ImportError.new("error message"))
|
||||||
|
put "/admin/themes/#{theme.id}.json", params: {
|
||||||
|
theme: { remote_update: true }
|
||||||
|
}
|
||||||
|
expect(response.status).to eq(422)
|
||||||
|
expect(JSON.parse(response.body)["errors"].first).to eq("error message")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the right error message' do
|
it 'returns the right error message' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user