Merge pull request #5780 from jekyll/dont-include-in-load-path-if-nil
Merge pull request 5780
This commit is contained in:
		
						commit
						b5d1be4dcf
					
				| 
						 | 
				
			
			@ -435,7 +435,7 @@ module Jekyll
 | 
			
		|||
    private
 | 
			
		||||
    def configure_include_paths
 | 
			
		||||
      @includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s))
 | 
			
		||||
      @includes_load_paths << theme.includes_path if self.theme
 | 
			
		||||
      @includes_load_paths << theme.includes_path if theme && theme.includes_path
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    private
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,6 +74,10 @@ module DirectoryHelpers
 | 
			
		|||
    test_dir("source", *subdirs)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def theme_dir(*subdirs)
 | 
			
		||||
    test_dir("fixtures", "test-theme", *subdirs)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_dir(*subdirs)
 | 
			
		||||
    root_dir("test", *subdirs)
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,6 +49,18 @@ class TestSite < JekyllUnitTest
 | 
			
		|||
      site = Site.new(site_configuration({ "baseurl" => "/blog" }))
 | 
			
		||||
      assert_equal "/blog", site.baseurl
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "only include theme includes_path if the path exists" do
 | 
			
		||||
      site = fixture_site({ "theme" => "test-theme" })
 | 
			
		||||
      assert_equal [source_dir("_includes"), theme_dir("_includes")],
 | 
			
		||||
        site.includes_load_paths
 | 
			
		||||
 | 
			
		||||
      allow(File).to receive(:directory?).with(theme_dir("_sass")).and_return(true)
 | 
			
		||||
      allow(File).to receive(:directory?).with(theme_dir("_layouts")).and_return(true)
 | 
			
		||||
      allow(File).to receive(:directory?).with(theme_dir("_includes")).and_return(false)
 | 
			
		||||
      site = fixture_site({ "theme" => "test-theme" })
 | 
			
		||||
      assert_equal [source_dir("_includes")], site.includes_load_paths
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  context "creating sites" do
 | 
			
		||||
    setup do
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,6 @@ require "helper"
 | 
			
		|||
class TestTheme < JekyllUnitTest
 | 
			
		||||
  def setup
 | 
			
		||||
    @theme = Theme.new("test-theme")
 | 
			
		||||
    @expected_root = File.expand_path "./fixtures/test-theme", File.dirname(__FILE__)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context "initializing" do
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +12,7 @@ class TestTheme < JekyllUnitTest
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    should "know the theme root" do
 | 
			
		||||
      assert_equal @expected_root, @theme.root
 | 
			
		||||
      assert_equal theme_dir, @theme.root
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "know the theme version" do
 | 
			
		||||
| 
						 | 
				
			
			@ -36,13 +35,13 @@ class TestTheme < JekyllUnitTest
 | 
			
		|||
  context "path generation" do
 | 
			
		||||
    [:assets, :_layouts, :_includes, :_sass].each do |folder|
 | 
			
		||||
      should "know the #{folder} path" do
 | 
			
		||||
        expected = File.expand_path(folder.to_s, @expected_root)
 | 
			
		||||
        expected = theme_dir(folder.to_s)
 | 
			
		||||
        assert_equal expected, @theme.public_send("#{folder.to_s.tr("_", "")}_path")
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "generate folder paths" do
 | 
			
		||||
      expected = File.expand_path("./_sass", @expected_root)
 | 
			
		||||
      expected = theme_dir("_sass")
 | 
			
		||||
      assert_equal expected, @theme.send(:path_for, :_sass)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -58,7 +57,7 @@ class TestTheme < JekyllUnitTest
 | 
			
		|||
      # no support for symlinks on Windows
 | 
			
		||||
      skip_if_windows "Jekyll does not currently support symlinks on Windows."
 | 
			
		||||
 | 
			
		||||
      expected = File.expand_path("./_layouts", @expected_root)
 | 
			
		||||
      expected = theme_dir("_layouts")
 | 
			
		||||
      assert_equal expected, @theme.send(:path_for, :_symlink)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue