Skip to content

Commit 2c088e2

Browse files
committed
Update tests for EntryFilter#filter fix and add comments for it
1 parent a8b91de commit 2c088e2

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

lib/jekyll/entry_filter.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ def relative_to_source(entry)
3131

3232
def filter(entries)
3333
entries.reject do |e|
34+
# Reject this entry if it is a symlink.
3435
next true if symlink?(e)
36+
# Do not reject this entry if it is included.
3537
next false if included?(e)
38+
# Reject this entry if it is special, a backup file, or excluded.
3639
special?(e) || backup?(e) || excluded?(e)
3740
end
3841
end

test/test_entry_filter.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class TestEntryFilter < JekyllUnitTest
66
context "Filtering entries" do
77
setup do
8-
@site = Site.new(site_configuration)
8+
@site = fixture_site
99
end
1010

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

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

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

102-
site = Site.new(site_configuration)
103-
104-
site.reader.read_directories("symlink-test")
105-
refute_equal [], site.pages
106-
refute_equal [], site.static_files
102+
@site.reader.read_directories("symlink-test")
103+
refute_equal [], @site.pages
104+
refute_equal [], @site.static_files
107105
end
108106

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

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

116114
assert_equal %w(main.scss symlinked-file).length, site.pages.length

test/test_layout_reader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class TestLayoutReader < JekyllUnitTest
4848
should "only read the layouts which are in the site" do
4949
layouts = LayoutReader.new(@site).read
5050

51-
refute layouts.keys.include?("symlink"), "Should not read the symlinked layout"
51+
refute layouts.key?("symlink"), "Should not read the symlinked layout"
5252
end
5353
end
5454

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

72-
refute layouts.keys.include?("theme-symlink"), "Should not read symlinked layout from theme"
72+
refute layouts.key?("theme-symlink"), "Should not read symlinked layout from theme"
7373
end
7474
end
7575
end

0 commit comments

Comments
 (0)