diff --git a/lib/document/markdown_with_frontmatter.rb b/lib/document/markdown_with_frontmatter.rb index 3d9ba874..31ef1c95 100644 --- a/lib/document/markdown_with_frontmatter.rb +++ b/lib/document/markdown_with_frontmatter.rb @@ -40,8 +40,7 @@ def body end def slug - slug = frontmatter.slug - slug.empty? ? rawname : slug + rawname end private diff --git a/tests/document/finder.rb b/tests/document/finder.rb index accd6823..e2a4fa49 100644 --- a/tests/document/finder.rb +++ b/tests/document/finder.rb @@ -17,7 +17,8 @@ slug: a-slug ---' Dir.stub :glob, [new_tempfile(contents, filename)] do - finder.find_single.url.must_equal('/path/a-slug') + expected_slug = File.basename(Dir.glob[0], '.*') + finder.find_single.url.must_equal("/path/#{expected_slug}") end end diff --git a/tests/document/markdown_with_frontmatter.rb b/tests/document/markdown_with_frontmatter.rb index 72ef6aa9..677a7115 100644 --- a/tests/document/markdown_with_frontmatter.rb +++ b/tests/document/markdown_with_frontmatter.rb @@ -24,7 +24,8 @@ end it 'has a url' do - document.url.must_equal('/events/a-slug') + expected_slug = File.basename(document.send(:filename), '.*').gsub(/^1000-10-01-/, '') + document.url.must_equal("/events/#{expected_slug}") end it 'has a published field' do