./test/dolt/views/blob_test.rb in dolt-0.1.0 vs ./test/dolt/views/blob_test.rb in dolt-0.1.1
- old
+ new
@@ -26,68 +26,80 @@
@repo = Dolt::Git::Repository.new("the-dolt")
@template_root = File.join(File.dirname(__FILE__), "..", "..", "..", "views")
end
def render(blob, options = {})
+ options[:attributes] = options[:attributes] || {}
+ attrs = options[:attributes]
+ if !attrs.key?(:multi_repo_mode); attrs[:multi_repo_mode] = true; end
renderer = Dolt::TemplateRenderer.new(@template_root, options)
renderer.helper(Dolt::View)
renderer.render(:blob, {
:blob => blob,
:repository => @repo,
:ref => options[:ref] || "master"
})
end
it "renders blob without errors" do
- blob = Dolt::Blob.new("file.txt", "Something something")
+ blob = Dolt::Git::Blob.new("file.txt", "Something something")
markup = render(blob)
assert_match /Something something/, markup
end
it "renders blob with line numbers" do
- blob = Dolt::Blob.new("file.txt", "One\nTwo\nThree")
+ blob = Dolt::Git::Blob.new("file.txt", "One\nTwo\nThree")
markup = render(blob)
assert_match /<li.*One.*<\/li>/, markup
assert_match /<li.*Two.*<\/li>/, markup
assert_match /<li.*Three.*<\/li>/, markup
end
it "renders blob with layout" do
- blob = Dolt::Blob.new("file.txt", "Something something")
+ blob = Dolt::Git::Blob.new("file.txt", "Something something")
markup = render(blob, :layout => "layout")
assert_match /Something something/, markup
end
it "renders repo title in page" do
- blob = Dolt::Blob.new("file.txt", "Something something")
+ blob = Dolt::Git::Blob.new("file.txt", "Something something")
markup = render(blob, :layout => "layout")
assert_match @repo.name, markup
end
it "renders links to other views" do
- blob = Dolt::Blob.new("file.txt", "Something something")
+ blob = Dolt::Git::Blob.new("file.txt", "Something something")
markup = render(blob)
assert_match "/the-dolt/blame/master:file.txt", markup
assert_match "/the-dolt/history/master:file.txt", markup
assert_match "/the-dolt/raw/master:file.txt", markup
end
+ it "renders links to other views in single repo mode" do
+ blob = Dolt::Git::Blob.new("file.txt", "Something something")
+ markup = render(blob, { :attributes => { :multi_repo_mode => false } })
+
+ assert_match "\"/blame/master:file.txt", markup
+ assert_match "\"/history/master:file.txt", markup
+ assert_match "\"/raw/master:file.txt", markup
+ end
+
it "renders links to other views for correct ref" do
- blob = Dolt::Blob.new("file.txt", "Something something")
+ blob = Dolt::Git::Blob.new("file.txt", "Something something")
markup = render(blob, :ref => "123bc21")
assert_match "/the-dolt/blame/123bc21:file.txt", markup
assert_match "/the-dolt/history/123bc21:file.txt", markup
assert_match "/the-dolt/raw/123bc21:file.txt", markup
end
it "renders the path clickable" do
- blob = Dolt::Blob.new("some/deeply/nested/file.txt", "Something something")
+ blob = Dolt::Git::Blob.new("some/deeply/nested/file.txt", "Something something")
markup = render(blob)
assert_match 'href="/the-dolt/tree/master:some"', markup
assert_match 'href="/the-dolt/tree/master:some/deeply"', markup
assert_match 'href="/the-dolt/tree/master:some/deeply/nested"', markup