mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 13:31:44 +08:00
c9dab6fd08
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors. By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
24 lines
984 B
Ruby
24 lines
984 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe ThemeSerializer do
|
|
describe "load theme settings" do
|
|
it 'should add error message when settings format is invalid' do
|
|
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
|
|
|
|
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
|
|
end
|
|
end
|