FIX: results of Wiki#search contains files out of page_file_dir

This commit is contained in:
Hiroshi Saito
2010-10-07 23:01:27 +09:00
parent fcdffc39ff
commit f8e7fcf2d2
2 changed files with 11 additions and 1 deletions
+5 -1
View File
@@ -246,7 +246,11 @@ module Gollum
# Returns an Array with Objects of page name and count of matches
def search(query)
# See: http://github.com/Sirupsen/gollum/commit/f0a6f52bdaf6bee8253ca33bb3fceaeb27bfb87e
search_output = @repo.git.grep({:c => query}, 'master')
if @page_file_dir
search_output = @repo.git.grep({:c => query}, 'master', '--', @page_file_dir)
else
search_output = @repo.git.grep({:c => query}, 'master')
end
search_output.split("\n").collect do |line|
result = line.split(':')
+6
View File
@@ -314,6 +314,12 @@ context "page_file_dir option" do
assert !@wiki.page("bar")
end
test "search results should be restricted in page filer dir" do
results = @wiki.search("Hello")
assert_equal 1, results.size
assert_equal "foo", results[0][:name]
end
teardown do
FileUtils.rm_r(@path)
end