Skip to content

Commit

Permalink
bug with when there are no pages
Browse files Browse the repository at this point in the history
  • Loading branch information
GBH committed Dec 9, 2019
1 parent e8d02b2 commit b85e105
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/comfy/cms/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def self.options_for_select(site:, current_page: nil, exclude_self: false)
options = []

options_for_page = ->(page, depth = 0) do
return if page.nil?
return if exclude_self && page == current_page

options << ["#{'. . ' * depth}#{page.label}", page.id]
Expand Down
3 changes: 3 additions & 0 deletions test/models/page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ def test_options_for_select
exclude_self: true
).map(&:first)
assert_equal expected, actual

Comfy::Cms::Page.delete_all
assert_equal [], Comfy::Cms::Page.options_for_select(site: @site).map(&:first)
end

def test_fragments_attributes
Expand Down

0 comments on commit b85e105

Please sign in to comment.