mirror of
https://github.com/jekyll/jekyll.git
synced 2026-02-12 15:45:21 -05:00
Added path in url.
Page#dir was returning the wrong dir ('/') for pages in directories.
This commit is contained in:
5
test/source/contacts/bar.html
Normal file
5
test/source/contacts/bar.html
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
title: Contact Information
|
||||
---
|
||||
|
||||
Contact Information
|
||||
5
test/source/contacts/index.html
Normal file
5
test/source/contacts/index.html
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
title: Contact Information
|
||||
---
|
||||
|
||||
Contact Information
|
||||
@@ -1,8 +1,10 @@
|
||||
require 'helper'
|
||||
|
||||
class TestPage < Test::Unit::TestCase
|
||||
def setup_page(file)
|
||||
@page = Page.new(@site, source_dir, '', file)
|
||||
def setup_page(*args)
|
||||
dir, file = args
|
||||
dir, file = ['', dir] if file.nil?
|
||||
@page = Page.new(@site, source_dir, dir, file)
|
||||
end
|
||||
|
||||
def do_render(page)
|
||||
@@ -23,6 +25,18 @@ class TestPage < Test::Unit::TestCase
|
||||
assert_equal "/contacts.html", @page.url
|
||||
end
|
||||
|
||||
context "in a directory hierarchy" do
|
||||
should "create url based on filename" do
|
||||
@page = setup_page('/contacts', 'bar.html')
|
||||
assert_equal "/contacts/bar.html", @page.url
|
||||
end
|
||||
|
||||
should "create index url based on filename" do
|
||||
@page = setup_page('/contacts', 'index.html')
|
||||
assert_equal "/contacts/index.html", @page.url
|
||||
end
|
||||
end
|
||||
|
||||
should "deal properly with extensions" do
|
||||
@page = setup_page('deal.with.dots.html')
|
||||
assert_equal ".html", @page.ext
|
||||
@@ -47,6 +61,23 @@ class TestPage < Test::Unit::TestCase
|
||||
@page = setup_page('index.html')
|
||||
assert_equal '/', @page.dir
|
||||
end
|
||||
|
||||
context "in a directory hierarchy" do
|
||||
should "create url based on filename" do
|
||||
@page = setup_page('/contacts', 'index.html')
|
||||
assert_equal "/contacts/index.html", @page.url
|
||||
end
|
||||
|
||||
should "return dir correctly" do
|
||||
@page = setup_page('/contacts', 'bar.html')
|
||||
assert_equal '/contacts/bar/', @page.dir
|
||||
end
|
||||
|
||||
should "return dir correctly for index page" do
|
||||
@page = setup_page('/contacts', 'index.html')
|
||||
assert_equal '/contacts', @page.dir
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with any other url style" do
|
||||
@@ -111,6 +142,36 @@ class TestPage < Test::Unit::TestCase
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '.htaccess'))
|
||||
end
|
||||
|
||||
context "in a directory hierarchy" do
|
||||
should "write properly the index" do
|
||||
page = setup_page('/contacts', 'index.html')
|
||||
do_render(page)
|
||||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts', 'index.html'))
|
||||
end
|
||||
|
||||
should "write properly" do
|
||||
page = setup_page('/contacts', 'bar.html')
|
||||
do_render(page)
|
||||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts', 'bar.html'))
|
||||
end
|
||||
|
||||
should "write properly without html extension" do
|
||||
page = setup_page('/contacts', 'bar.html')
|
||||
page.site.permalink_style = :pretty
|
||||
do_render(page)
|
||||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, 'contacts', 'bar', 'index.html'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user