2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-03 17:03:06 -04:00
|
|
|
RSpec.describe ThemeSerializer do
|
|
|
|
describe "load theme settings" do
|
2021-04-28 18:00:37 -04:00
|
|
|
it 'should add error message when settings format is invalid' do
|
2018-10-03 17:03:06 -04:00
|
|
|
theme = Fabricate(:theme)
|
|
|
|
Theme.any_instance.stubs(:settings).raises(ThemeSettingsParser::InvalidYaml, I18n.t("themes.settings_errors.invalid_yaml"))
|
|
|
|
serialized = ThemeSerializer.new(theme).as_json[:theme]
|
|
|
|
expect(serialized[:settings]).to be_nil
|
|
|
|
expect(serialized[:errors].count).to eq(1)
|
|
|
|
expect(serialized[:errors][0]).to eq(I18n.t("themes.settings_errors.invalid_yaml"))
|
|
|
|
end
|
2021-04-28 18:00:37 -04:00
|
|
|
|
|
|
|
it 'should add errors messages from theme fields' do
|
|
|
|
error = "error when compiling theme field"
|
|
|
|
theme = Fabricate(:theme)
|
|
|
|
theme_field = Fabricate(:theme_field, error: error, theme: theme)
|
|
|
|
serialized = ThemeSerializer.new(theme.reload).as_json[:theme]
|
|
|
|
expect(serialized[:errors].count).to eq(1)
|
|
|
|
expect(serialized[:errors][0]).to eq(error)
|
|
|
|
end
|
2018-10-03 17:03:06 -04:00
|
|
|
end
|
|
|
|
end
|