From fac041933c3e328ff73dc91faeaeb08182ae3c74 Mon Sep 17 00:00:00 2001 From: jona Date: Tue, 29 Nov 2016 09:14:03 +0100 Subject: [PATCH 1/4] fix date parsing in file names --- lib/jekyll/document.rb | 2 +- .../3940394-21-9393050-fifif1323-test.md | 5 ++++ test/test_document.rb | 29 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/source/_methods/3940394-21-9393050-fifif1323-test.md diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index f35cdb0e061..ad5884efb68 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -9,7 +9,7 @@ class Document YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$! - DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$! + DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d{4}-\d{2}-\d{2})-(.*)(\.[^.]+)$! # Create a new Document. # diff --git a/test/source/_methods/3940394-21-9393050-fifif1323-test.md b/test/source/_methods/3940394-21-9393050-fifif1323-test.md new file mode 100644 index 00000000000..848d0204cc4 --- /dev/null +++ b/test/source/_methods/3940394-21-9393050-fifif1323-test.md @@ -0,0 +1,5 @@ +--- +title: "this is a test!" +--- + +wheee diff --git a/test/test_document.rb b/test/test_document.rb index e4d7abbfdac..5b9156f3e39 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -492,4 +492,33 @@ def assert_equal_value(key, one, other) assert_equal true, File.file?(@dest_file) end end + + context "a document in a collection with dash-separated numeric file name" do + setup do + @site = fixture_site({ + "collections" => { + "methods" => { + "output" => true + } + } + }) + @site.process + @document = @site.collections["methods"].docs.find do |doc| + doc.relative_path == "_methods/3940394-21-9393050-fifif1323-test.md" + end + @dest_file = dest_dir("methods/3940394-21-9393050-fifif1323-test.html") + end + + should "produce the right URL" do + assert_equal "/methods/3940394-21-9393050-fifif1323-test.html", @document.url + end + + should "produce the right destination" do + assert_equal @dest_file, @document.destination(dest_dir) + end + + should "be output in the correct place" do + assert_equal true, File.file?(@dest_file) + end + end end From 4f4a628df81fc3490c4f4134c689eeed983d7c2c Mon Sep 17 00:00:00 2001 From: jona Date: Tue, 29 Nov 2016 13:37:10 +0100 Subject: [PATCH 2/4] fix tests --- ...8-9-23-categories.markdown => 2008-09-23-categories.markdown} | 0 ...8-9-23-categories.markdown => 2008-09-23-categories.markdown} | 0 test/test_collections.rb | 1 + 3 files changed, 1 insertion(+) rename test/source/category/_posts/{2008-9-23-categories.markdown => 2008-09-23-categories.markdown} (100%) rename test/source/z_category/_posts/{2008-9-23-categories.markdown => 2008-09-23-categories.markdown} (100%) diff --git a/test/source/category/_posts/2008-9-23-categories.markdown b/test/source/category/_posts/2008-09-23-categories.markdown similarity index 100% rename from test/source/category/_posts/2008-9-23-categories.markdown rename to test/source/category/_posts/2008-09-23-categories.markdown diff --git a/test/source/z_category/_posts/2008-9-23-categories.markdown b/test/source/z_category/_posts/2008-09-23-categories.markdown similarity index 100% rename from test/source/z_category/_posts/2008-9-23-categories.markdown rename to test/source/z_category/_posts/2008-09-23-categories.markdown diff --git a/test/test_collections.rb b/test/test_collections.rb index 45e2a51192b..0dca8443994 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -132,6 +132,7 @@ class TestCollections < JekyllUnitTest _methods/um_hi.md _methods/escape-+\ #%20[].md _methods/yaml_with_dots.md + _methods/3940394-21-9393050-fifif1323-test.md ), doc.relative_path end end From d7cdab16e2f67fe50515a3bb2021fa840444fa79 Mon Sep 17 00:00:00 2001 From: --global Date: Tue, 29 Nov 2016 14:07:07 +0100 Subject: [PATCH 3/4] fix cucumber tests --- features/collections.feature | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/features/collections.feature b/features/collections.feature index 60bba8a17fa..1310bdb1b65 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -77,8 +77,8 @@ Feature: Collections When I run jekyll build Then I should get a zero exit status Then the _site directory should exist - And I should see "Collections: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" unless Windows - And I should see "Collections: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/yaml_with_dots.md" in "_site/index.html" if on Windows + And I should see "Collections: _methods/3940394-21-9393050-fifif1323-test.md _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" unless Windows + And I should see "Collections: _methods/3940394-21-9393050-fifif1323-test.md _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/yaml_with_dots.md" in "_site/index.html" if on Windows Scenario: Collections specified as an hash Given I have an "index.html" page that contains "Collections: {% for method in site.methods %}{{ method.relative_path }} {% endfor %}" @@ -91,8 +91,8 @@ Feature: Collections When I run jekyll build Then I should get a zero exit status Then the _site directory should exist - And I should see "Collections: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" unless Windows - And I should see "Collections: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/yaml_with_dots.md" in "_site/index.html" if on Windows + And I should see "Collections: _methods/3940394-21-9393050-fifif1323-test.md _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" unless Windows + And I should see "Collections: _methods/3940394-21-9393050-fifif1323-test.md _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/yaml_with_dots.md" in "_site/index.html" if on Windows Scenario: All the documents Given I have an "index.html" page that contains "All documents: {% for doc in site.documents %}{{ doc.relative_path }} {% endfor %}" @@ -105,11 +105,11 @@ Feature: Collections When I run jekyll build Then I should get a zero exit status Then the _site directory should exist - And I should see "All documents: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" unless Windows - And I should see "All documents: _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/yaml_with_dots.md" in "_site/index.html" if on Windows + And I should see "All documents: _methods/3940394-21-9393050-fifif1323-test.md _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/um_hi.md" in "_site/index.html" unless Windows + And I should see "All documents: _methods/3940394-21-9393050-fifif1323-test.md _methods/collection/entries _methods/configuration.md _methods/escape-\+ #%20\[\].md _methods/sanitized_path.md _methods/site/generate.md _methods/site/initialize.md _methods/yaml_with_dots.md" in "_site/index.html" if on Windows Scenario: Documents have an output attribute, which is the converted HTML - Given I have an "index.html" page that contains "Second document's output: {{ site.documents[1].output }}" + Given I have an "index.html" page that contains "Second document's output: {{ site.documents[2].output }}" And I have fixture collections And I have a "_config.yml" file with content: """ @@ -145,7 +145,7 @@ Feature: Collections When I run jekyll build Then I should get a zero exit status And the _site directory should exist - And I should see "2. of 8:

Page without title.

" in "_site/index.html" unless Windows + And I should see "2. of 9:

Page without title.

" in "_site/index.html" unless Windows And I should see "2. of 7:

Page without title.

" in "_site/index.html" if on Windows Scenario: Sort by relative_path @@ -159,8 +159,8 @@ Feature: Collections When I run jekyll build Then I should get a zero exit status Then the _site directory should exist - And I should see "Collections: Collection#entries, Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, Initialize, Site#generate," in "_site/index.html" unless Windows - And I should see "Collections: Collection#entries, Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, Initialize, YAML with Dots" in "_site/index.html" if on Windows + And I should see "Collections: this is a test!, Collection#entries, Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, Initialize, Site#generate, YAML with Dots" in "_site/index.html" unless Windows + And I should see "Collections: this is a test!, Collection#entries, Jekyll.configuration, Jekyll.escape, Jekyll.sanitized_path, Site#generate, Initialize, YAML with Dots" in "_site/index.html" if on Windows Scenario: Rendered collection with date/dateless filename Given I have an "index.html" page that contains "Collections: {% for method in site.thanksgiving %}{{ method.title }} {% endfor %}" From 6cbcaa99ad56c85633626500e69f7fadc6b2cba4 Mon Sep 17 00:00:00 2001 From: --global Date: Tue, 29 Nov 2016 14:17:56 +0100 Subject: [PATCH 4/4] fix collection cucumber for windows --- features/collections.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/collections.feature b/features/collections.feature index 1310bdb1b65..de5e2a22ed7 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -146,7 +146,7 @@ Feature: Collections Then I should get a zero exit status And the _site directory should exist And I should see "2. of 9:

Page without title.

" in "_site/index.html" unless Windows - And I should see "2. of 7:

Page without title.

" in "_site/index.html" if on Windows + And I should see "2. of 8:

Page without title.

" in "_site/index.html" if on Windows Scenario: Sort by relative_path Given I have an "index.html" page that contains "Collections: {% assign methods = site.methods | sort: 'relative_path' %}{{ methods | map:"title" | join: ", " }}"