From a13d6178f73594b5fd8a4c487fe0f7593c151ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Norl=C3=A9n?= Date: Fri, 21 Feb 2020 16:21:36 +0100 Subject: [PATCH] fix page tagging menu attach cond --- app/models/alchemy/page.rb | 2 +- spec/models/alchemy/page_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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