Merge pull request #4873 from mlocher/bug-post-url

Merge pull request 4873
This commit is contained in:
jekyllbot 2016-10-05 11:40:04 -07:00 committed by GitHub
commit 3de78877c0
2 changed files with 37 additions and 2 deletions

View File

@ -14,7 +14,8 @@ module Jekyll
"'#{name}' does not contain valid date and/or title." "'#{name}' does not contain valid date and/or title."
end end
@name_regex = %r!^#{path}#{date}-#{slug}\.[^.]+! @name_regex = %r!^_posts/#{path}#{date}-#{slug}\.[^.]+|
^#{path}_posts/?#{date}-#{slug}\.[^.]+!x
end end
def post_date def post_date
@ -23,7 +24,7 @@ module Jekyll
end end
def ==(other) def ==(other)
other.basename.match(@name_regex) other.relative_path.match(@name_regex)
end end
def deprecated_equality(other) def deprecated_equality(other)

View File

@ -589,6 +589,40 @@ CONTENT
end end
end end
context "simple page with nested post linking and path not used in `post_url`" do
setup do
content = <<CONTENT
---
title: Deprecated Post linking
---
- 1 {% post_url 2008-11-21-nested %}
CONTENT
create_post(content, {
"permalink" => "pretty",
"source" => source_dir,
"destination" => dest_dir,
"read_posts" => true
})
end
should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result)
end
should "have the url to the \"nested\" post from 2008-11-21" do
assert_match %r!1\s/2008/11/21/nested/!, @result
end
should "throw a deprecation warning" do
deprecation_warning = " Deprecation: A call to "\
"'{{ post_url 2008-11-21-nested }}' did not match a post using the new matching "\
"method of checking name (path-date-slug) equality. Please make sure that you "\
"change this tag to match the post's name exactly."
assert_includes Jekyll.logger.messages, deprecation_warning
end
end
context "simple page with invalid post name linking" do context "simple page with invalid post name linking" do
should "cause an error" do should "cause an error" do
content = <<CONTENT content = <<CONTENT