diff --git a/app/models/alchemy/page.rb b/app/models/alchemy/page.rb index 9f611cd7d2..84d637c142 100644 --- a/app/models/alchemy/page.rb +++ b/app/models/alchemy/page.rb @@ -602,7 +602,7 @@ def attach_to_menu! end def should_attach_to_menu? - menu_id && nodes.none? + menu_id.present? && nodes.none? end end end diff --git a/spec/models/alchemy/page_spec.rb b/spec/models/alchemy/page_spec.rb index d0e652102d..0ace3ba976 100644 --- a/spec/models/alchemy/page_spec.rb +++ b/spec/models/alchemy/page_spec.rb @@ -2364,6 +2364,13 @@ module Alchemy expect { page.save }.not_to change { page.nodes.count } end end + + context 'if menu_id is empty' do + it 'does not raise error' do + page.menu_id = "" + expect { page.save }.not_to raise_error + end + end end describe '#nodes' do