diff --git a/lib/gollum/committer.rb b/lib/gollum/committer.rb index ada599c9..16fef19b 100644 --- a/lib/gollum/committer.rb +++ b/lib/gollum/committer.rb @@ -91,7 +91,7 @@ module Gollum fullpath = ::File.join(*[@wiki.page_file_dir, dir, path].compact) fullpath = fullpath[1..-1] if fullpath =~ /^\// - if index.current_tree && tree = index.current_tree / dir + if index.current_tree && tree = index.current_tree / (@wiki.page_file_dir || '/') / dir downpath = path.downcase.sub(/\.\w+$/, '') tree.blobs.each do |blob| diff --git a/test/test_app.rb b/test/test_app.rb index 301c808d..e1f9f8d8 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -192,3 +192,35 @@ context "Frontend" do Precious::App end end + +context "Frontend with page-file-dir" do + include Rack::Test::Methods + + setup do + @path = cloned_testpath("examples/page_file_dir.git") + @wiki = Gollum::Wiki.new(@path, { :page_file_dir => "docs" }) + Precious::App.set(:gollum_path, @path) + Precious::App.set(:wiki_options, { :page_file_dir => "docs" }) + end + + teardown do + FileUtils.rm_rf(@path) + end + + test "open existing parent" do + get "/" + assert last_response.ok? + + post "/create", :content => "asdf", :page => "bar", + :format => 'markdown' + follow_redirect! + assert last_response.ok? + + # Assert not match. + assert_equal true, /Duplicate page/.match(last_response.body) == nil + end + + def app + Precious::App + end +end