2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-08 00:46:34 -04:00
|
|
|
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)
|
2018-08-23 21:30:00 -04:00
|
|
|
child = Fabricate(:theme, component: true)
|
2018-08-08 00:46:34 -04:00
|
|
|
|
|
|
|
child_theme = ChildTheme.new(parent_theme: theme, child_theme: child)
|
|
|
|
expect(child_theme.valid?).to eq(true)
|
|
|
|
child_theme.save!
|
|
|
|
|
2018-08-23 21:30:00 -04:00
|
|
|
grandchild = Fabricate(:theme, component: true)
|
2018-08-08 00:46:34 -04:00
|
|
|
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
|