Skip to content

Commit

Permalink
Update tests for EntryFilter#filter fix and add comments for it
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Sep 7, 2018
1 parent a8b91de commit 2c088e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions lib/jekyll/entry_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ def relative_to_source(entry)

def filter(entries)
entries.reject do |e|
# Reject this entry if it is a symlink.
next true if symlink?(e)
# Do not reject this entry if it is included.
next false if included?(e)
# Reject this entry if it is special, a backup file, or excluded.
special?(e) || backup?(e) || excluded?(e)
end
end
Expand Down
14 changes: 6 additions & 8 deletions test/test_entry_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class TestEntryFilter < JekyllUnitTest
context "Filtering entries" do
setup do
@site = Site.new(site_configuration)
@site = fixture_site
end

should "filter entries" do
Expand Down Expand Up @@ -87,7 +87,7 @@ class TestEntryFilter < JekyllUnitTest
# no support for symlinks on Windows
skip_if_windows "Jekyll does not currently support symlinks on Windows."

site = Site.new(site_configuration("safe" => true))
site = fixture_site("safe" => true)
site.reader.read_directories("symlink-test")

assert_equal %w(main.scss symlinked-file).length, site.pages.length
Expand All @@ -99,18 +99,16 @@ class TestEntryFilter < JekyllUnitTest
# no support for symlinks on Windows
skip_if_windows "Jekyll does not currently support symlinks on Windows."

site = Site.new(site_configuration)

site.reader.read_directories("symlink-test")
refute_equal [], site.pages
refute_equal [], site.static_files
@site.reader.read_directories("symlink-test")
refute_equal [], @site.pages
refute_equal [], @site.static_files
end

should "include only safe symlinks in safe mode even when included" do
# no support for symlinks on Windows
skip_if_windows "Jekyll does not currently support symlinks on Windows."

site = Site.new(site_configuration("safe" => true, "include" => ["symlinked-file-outside-source"]))
site = fixture_site("safe" => true, "include" => ["symlinked-file-outside-source"])
site.reader.read_directories("symlink-test")

assert_equal %w(main.scss symlinked-file).length, site.pages.length
Expand Down
4 changes: 2 additions & 2 deletions test/test_layout_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestLayoutReader < JekyllUnitTest
should "only read the layouts which are in the site" do
layouts = LayoutReader.new(@site).read

refute layouts.keys.include?("symlink"), "Should not read the symlinked layout"
refute layouts.key?("symlink"), "Should not read the symlinked layout"
end
end

Expand All @@ -69,7 +69,7 @@ class TestLayoutReader < JekyllUnitTest
should "not read a symlink'd theme" do
layouts = LayoutReader.new(@site).read

refute layouts.keys.include?("theme-symlink"), "Should not read symlinked layout from theme"
refute layouts.key?("theme-symlink"), "Should not read symlinked layout from theme"
end
end
end
Expand Down

0 comments on commit 2c088e2

Please sign in to comment.