diff --git a/lib/gollum/views/latest_changes.rb b/lib/gollum/views/latest_changes.rb index 8707e489..e217ce6d 100644 --- a/lib/gollum/views/latest_changes.rb +++ b/lib/gollum/views/latest_changes.rb @@ -23,7 +23,6 @@ module Precious :date_full => v.authored_date, :files => v.stats.files.map { |f,*rest| page_path = extract_renamed_path_destination(f) - page_path = remove_page_extentions(page_path) { :file => f, :link => "#{page_path}/#{v.id}" } @@ -32,13 +31,6 @@ module Precious end end - def remove_page_extentions(page_path) - Gollum::Markup.formats.values.each do |format| - page_path = page_path.gsub(/\.#{format[:regexp]}$/, '') - end - return page_path - end - def extract_renamed_path_destination(file) return file.gsub(/{.* => (.*)}/, '\1').gsub(/.* => (.*)/, '\1') end diff --git a/test/examples/lotr.git/logs/HEAD b/test/examples/lotr.git/logs/HEAD index 2b0e49e0..31af843f 100644 --- a/test/examples/lotr.git/logs/HEAD +++ b/test/examples/lotr.git/logs/HEAD @@ -9,3 +9,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc 7d6aeab8b84c895f21f6c66b84a457b0fced9693 563cc3701db990caf63e4ce9c3697a062890ca48 James Dabbs 1361843315 -0500 push 563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence 1363478075 -0400 push 874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe 1421012322 -0500 push +7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto 1492034760 +0200 push diff --git a/test/examples/lotr.git/logs/refs/heads/master b/test/examples/lotr.git/logs/refs/heads/master index 2b0e49e0..31af843f 100644 --- a/test/examples/lotr.git/logs/refs/heads/master +++ b/test/examples/lotr.git/logs/refs/heads/master @@ -9,3 +9,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc 7d6aeab8b84c895f21f6c66b84a457b0fced9693 563cc3701db990caf63e4ce9c3697a062890ca48 James Dabbs 1361843315 -0500 push 563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence 1363478075 -0400 push 874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe 1421012322 -0500 push +7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto 1492034760 +0200 push diff --git a/test/examples/lotr.git/objects/2c/e9aa9509f2ac35921e2900a922cfeb5bed76ae b/test/examples/lotr.git/objects/2c/e9aa9509f2ac35921e2900a922cfeb5bed76ae new file mode 100644 index 00000000..37314bd5 Binary files /dev/null and b/test/examples/lotr.git/objects/2c/e9aa9509f2ac35921e2900a922cfeb5bed76ae differ diff --git a/test/examples/lotr.git/objects/72/39e2921c2962365509b2f6950da6a85931f30e b/test/examples/lotr.git/objects/72/39e2921c2962365509b2f6950da6a85931f30e new file mode 100644 index 00000000..5003c645 Binary files /dev/null and b/test/examples/lotr.git/objects/72/39e2921c2962365509b2f6950da6a85931f30e differ diff --git a/test/examples/lotr.git/objects/f8/03c64d11407b23797325e3843f3f378b78f611 b/test/examples/lotr.git/objects/f8/03c64d11407b23797325e3843f3f378b78f611 new file mode 100644 index 00000000..427d87e5 --- /dev/null +++ b/test/examples/lotr.git/objects/f8/03c64d11407b23797325e3843f3f378b78f611 @@ -0,0 +1,3 @@ +x1 +0 E; 8R:t(LMBߐ#tx:ϓ:wM0 1ST Y˄ a;&Br.Nҕ +1>'Ec_,nX{|zB| =\-ZkR޼*W6? K \ No newline at end of file diff --git a/test/examples/lotr.git/refs/heads/master b/test/examples/lotr.git/refs/heads/master index 81879653..3a743f29 100644 --- a/test/examples/lotr.git/refs/heads/master +++ b/test/examples/lotr.git/refs/heads/master @@ -1 +1 @@ -7bdfe65face6f7cf9877d8c1d8c1dd974a63745e +f803c64d11407b23797325e3843f3f378b78f611 diff --git a/test/helper.rb b/test/helper.rb index d4dd54ac..228f7369 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -90,15 +90,4 @@ def context(*args, &block) klass.class_eval &block end -$contexts = [] - -# Commit file to wiki, overwriting previous versions of that file -def commit_test_file(wiki, dir, filename, ext, content) - committer = Gollum::Committer.new(wiki, :message => "Added testfile", :parent => wiki.repo.head.commit) - committer.add_to_index(dir, filename, ext, content, true) - committer.after_commit do |committer, sha| - wiki.clear_cache - committer.update_working_dir(dir, filename, ext) - end - committer.commit -end +$contexts = [] \ No newline at end of file diff --git a/test/test_app.rb b/test/test_app.rb index ec884f5e..9882387f 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -123,7 +123,7 @@ context "Frontend" do post "/edit/A", :header => 'header', :footer => 'footer', :page => "A", :sidebar => 'sidebar', :message => 'def' follow_redirect! - assert_equal "/A", last_request.fullpath + assert_equal "/A.md", last_request.fullpath assert last_response.ok? @wiki.clear_cache @@ -150,7 +150,7 @@ context "Frontend" do post "/rename/B", :rename => "/C", :message => 'def' follow_redirect! - assert_equal '/C', last_request.fullpath + assert_equal '/C.md', last_request.fullpath assert last_response.ok? @wiki.clear_cache @@ -189,7 +189,7 @@ context "Frontend" do post "/rename/G/H", :rename => "/I/C", :message => 'def' follow_redirect! - assert_equal '/I/C', last_request.fullpath + assert_equal '/I/C.md', last_request.fullpath assert last_response.ok? @wiki.clear_cache @@ -206,7 +206,7 @@ context "Frontend" do post "/rename/G/H", :rename => "K/C", :message => 'def' follow_redirect! - assert_equal '/G/K/C', last_request.fullpath + assert_equal '/G/K/C.md', last_request.fullpath assert last_response.ok? @wiki.clear_cache @@ -272,7 +272,7 @@ context "Frontend" do end test "create redirects to page if already exists" do - name = "A" + name = "A.md" get "/create/#{name}" follow_redirect! assert_equal "/#{name}", last_request.fullpath @@ -548,19 +548,6 @@ context "Frontend" do assert_match /meta name="robots" content="noindex, nofollow"/, last_response.body end - test "show revision of specific file" do - shas = {} - ["First revision of testfile", "Second revision of testfile"].each do |content| - new_commit = commit_test_file(@wiki, "revisions", "testfile", "log", content) - shas[new_commit] = content - end - shas.each do |sha, content| - get "revisions/testfile.log/#{sha}" - assert last_response.ok? - assert_match /#{content}/, last_response.body - end - end - def app Precious::App end @@ -689,12 +676,25 @@ context "Frontend with lotr" do post "/edit/Mordor/Orc", :content => 'not so big smelly creatures', :page => 'Orc', :path => 'Mordor', :message => 'minor edit' - assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location'] + assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location'] get "/Mordor/Orc" assert_match /not so big smelly creatures/, last_response.body end + test "show revision of specific file" do + old_sha = "df26e61e707116f81ebc6b935ec6d1676b7e96c4" + update_sha = "f803c64d11407b23797325e3843f3f378b78f611" + + get "Data.csv/#{old_sha}" + assert last_response.ok? + assert_no_match /Samwise,Gamgee/, last_response.body + + get "Data.csv/#{update_sha}" + assert last_response.ok? + assert_match /Samwise,Gamgee/, last_response.body + end + test "existing emoji" do get "/emoji/heart" assert_equal 200, last_response.status diff --git a/test/test_latest_changes_view.rb b/test/test_latest_changes_view.rb index fe6d08de..5d4e2f41 100644 --- a/test/test_latest_changes_view.rb +++ b/test/test_latest_changes_view.rb @@ -21,10 +21,10 @@ context "Precious::Views::LatestChanges" do body = last_response.body assert body.include?('Charles Pence'), "/latest_changes should include the Author Charles Pence" - assert body.include?('a8ad3c0'), "/latest_changes should include the :latest_changes_count commit" - assert !body.include?('60f12f4'), "/latest_changes should not include more than latest_changes_count commits" + assert body.include?('1db89eb'), "/latest_changes should include the :latest_changes_count commit" + assert !body.include?('a8ad3c0'), "/latest_changes should not include more than latest_changes_count commits" assert body.include?('Data-Two.csv'), "/latest_changes include links to modified files in #{body}" - assert body.include?('Hobbit.md'), "/latest_changes should include links to modified pages in #{body}" + assert body.include?('Hobbit.md'), "/latest_changes should include links to modified pages in #{body}" end test "extract destination file name in case of path renaming" do @@ -33,13 +33,6 @@ context "Precious::Views::LatestChanges" do assert_equal "newDirectoryName/fileName.md", view.extract_renamed_path_destination("{oldDirectoryName => newDirectoryName}/fileName.md") end - test "remove page extentions" do - view = Precious::Views::LatestChanges.new - assert_equal "page", view.remove_page_extentions("page.wiki") - assert_equal "page-wiki", view.remove_page_extentions("page-wiki.md") - assert_equal "file.any_extention", view.remove_page_extentions("file.any_extention") - end - teardown do FileUtils.rm_rf(@path) end diff --git a/test/test_page_view.rb b/test/test_page_view.rb index 9d2c16db..1565b29e 100644 --- a/test/test_page_view.rb +++ b/test/test_page_view.rb @@ -58,7 +58,7 @@ EOS @view = Precious::Views::Page.new @view.instance_variable_set :@page, page - assert_equal "345e6aef713208c8d50cdea23b85e6ad831f0449", @view.sha + assert_equal "594e928cc5dcb6d833dfb86bb36076fd4a84eea7", @view.id end test "h1 title can be disabled" do