File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
app/controllers/comfy/admin/cms
test/controllers/admin/comfy Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,15 @@ def destroy
55
55
def build_layout
56
56
@layout = @site . layouts . new ( layout_params )
57
57
@layout . parent ||= ::Comfy ::Cms ::Layout . find_by_id ( params [ :parent_id ] )
58
- @layout . app_layout ||= @layout . parent . try ( :app_layout )
59
58
@layout . content ||= "{{ cms:wysiwyg content }}"
59
+
60
+ if !@layout . app_layout . blank?
61
+ @layout . app_layout = @layout . app_layout
62
+ elsif !@layout . parent . nil?
63
+ @layout . app_layout = @layout . parent . app_layout
64
+ else
65
+ @layout . app_layout = "website"
66
+ end
60
67
end
61
68
62
69
def load_layout
Original file line number Diff line number Diff line change @@ -66,6 +66,16 @@ class Comfy::Admin::Cms::LayoutsControllerTest < ActionDispatch::IntegrationTest
66
66
assert_select "form[action='/admin/sites/#{ site . id } /layouts']"
67
67
end
68
68
69
+ test "default website layout should be used if a newly-created layout has no app_layout and parent" do
70
+ @user . update ( can_access_admin : true , can_manage_web : true )
71
+ sign_in ( @user )
72
+ get new_comfy_admin_cms_site_layout_url ( subdomain : @restarone_subdomain , site_id : @site . id )
73
+
74
+ assert_response :success
75
+ assert assigns ( :layout )
76
+ assert_equal "website" , assigns ( :layout ) . app_layout
77
+ end
78
+
69
79
test 'denies #new if not permissioned' do
70
80
sign_in ( @user )
71
81
get new_comfy_admin_cms_site_layout_url ( subdomain : @restarone_subdomain , site_id : @site . id )
You can’t perform that action at this time.
0 commit comments