discourse/spec/models/child_theme_spec.rb
David Taylor c9dab6fd08
DEV: Automatically require 'rails_helper' in all specs (#16077)
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.
2022-03-01 17:50:50 +00:00

25 lines
993 B
Ruby

# frozen_string_literal: true
describe ChildTheme do
describe "validations" do
it "doesn't allow children to become parents or parents to become children" do
theme = Fabricate(:theme)
child = Fabricate(:theme, component: true)
child_theme = ChildTheme.new(parent_theme: theme, child_theme: child)
expect(child_theme.valid?).to eq(true)
child_theme.save!
grandchild = Fabricate(:theme, component: true)
child_theme = ChildTheme.new(parent_theme: child, child_theme: grandchild)
expect(child_theme.valid?).to eq(false)
expect(child_theme.errors.full_messages).to contain_exactly(I18n.t("themes.errors.no_multilevels_components"))
grandparent = Fabricate(:theme)
child_theme = ChildTheme.new(parent_theme: grandparent, child_theme: theme)
expect(child_theme.valid?).to eq(false)
expect(child_theme.errors.full_messages).to contain_exactly(I18n.t("themes.errors.no_multilevels_components"))
end
end
end