discourse/spec/models/child_theme_spec.rb
Sam Saffron 4ea21fa2d0 DEV: use #frozen_string_literal: true on all spec
This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
2019-04-30 10:27:42 +10:00

27 lines
1017 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
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